1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using InABox.Configuration;
- using InABox.Core;
- using Microsoft.Win32;
- using PRS.Shared;
- using PRSClasses;
- using PRSServer;
- namespace PRSServer
- {
- public class ServerSettings : /*RegistryConfigurationSettings, */ILocalConfigurationSettings
- {
- //public long Sequence { get; set; }
- public ServerType Type { get; set; }
- public string Properties { get; set; }
- public Server CreateServer(string key)
- {
- var result = new Server();
- result.Key = key;
- result.Type = Type;
- //result.Sequence = Sequence == 0 ? DateTime.Now.Ticks : Sequence;
- var properties = DeserializeServerProperties();
- if (properties != null)
- {
- result.Properties = properties;
- result.Name = result.Properties.Name;
- }
- result.CommitChanges();
- return result;
- }
- public ServerProperties? DeserializeServerProperties()
- {
- switch (Type)
- {
- case ServerType.Database:
- return Serialization.Deserialize<DatabaseServerProperties>(Properties);
- case ServerType.GPS:
- return Serialization.Deserialize<GPSServerProperties>(Properties);
- case ServerType.AutoDiscovery:
- return Serialization.Deserialize<AutoDiscoveryServerProperties>(Properties);
-
- case ServerType.Schedule:
- return Serialization.Deserialize<ScheduleServerProperties>(Properties);
-
- case ServerType.Web:
- return Serialization.Deserialize<WebServerProperties>(Properties);
-
- case ServerType.Certificate:
- return Serialization.Deserialize<CertificateEngineProperties>(Properties);
-
- default:
- return null;
- }
- }
- /*public override void Load(RegistryKey key)
- {
- Type = (ServerType)Enum.Parse(typeof(ServerType), key.GetValue("Type") as string);
- Properties = key.GetValue("Properties") as string;
- }
- public override void Save(RegistryKey key)
- {
- key.SetValue("Type", Type.ToString());
- key.SetValue("Properties", Properties);
- }*/
- }
- }
|