PRSLicensingService.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using InABox.Configuration;
  2. using InABox.Core;
  3. using PRSServer;
  4. using PRSServices;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PRSLicensing;
  10. internal class PRSLicensingService : PRSService
  11. {
  12. public PRSLicensingService(string serviceName) : base(serviceName)
  13. {
  14. }
  15. protected override ServerSettings GetSettings(string serviceName)
  16. {
  17. var configuration = GetConfiguration().Load();
  18. return new ServerSettings
  19. {
  20. Type = ServerType.Other,
  21. Properties = configuration.Properties
  22. };
  23. }
  24. public static IConfiguration<LicensingConfiguration> GetConfiguration()
  25. {
  26. return new LocalConfiguration<LicensingConfiguration>(CoreUtils.GetCommonAppData(), "");
  27. }
  28. protected override Server CreateServer(ServerSettings settings, string serviceName)
  29. {
  30. var result = new Server();
  31. result.Key = serviceName;
  32. result.Type = ServerType.Other;
  33. //result.Sequence = Sequence == 0 ? DateTime.Now.Ticks : Sequence;
  34. var properties = Serialization.Deserialize<LicensingEngineProperties>(settings.Properties);
  35. if (properties != null)
  36. {
  37. result.Properties = properties;
  38. result.Name = result.Properties.Name;
  39. }
  40. result.CommitChanges();
  41. return result;
  42. }
  43. protected override IEngine? CreateEngine(ServerSettings settings)
  44. {
  45. return new LicensingEngine();
  46. }
  47. }