PRSLicensingService.cs 1.5 KB

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