12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using InABox.Configuration;
- using InABox.Core;
- using Microsoft.Win32;
- using PRS.Shared;
- using PRSClasses;
- using PRSServer;
- namespace PRSServer
- {
- public class ServerSettings : /*RegistryConfigurationSettings, */LocalConfigurationSettings
- {
- //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()
- {
- if (Type == ServerType.Database)
- return Serialization.Deserialize<DatabaseServerProperties>(Properties);
- if (Type == ServerType.GPS)
- return Serialization.Deserialize<GPSServerProperties>(Properties);
- if (Type == ServerType.AutoDiscovery)
- return Serialization.Deserialize<AutoDiscoveryServerProperties>(Properties);
- if (Type == ServerType.Schedule)
- return Serialization.Deserialize<ScheduleServerProperties>(Properties);
- if (Type == ServerType.Web)
- return Serialization.Deserialize<WebServerProperties>(Properties);
- if (Type == ServerType.Certificate)
- return Serialization.Deserialize<CertificateEngineProperties>(Properties);
- 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);
- }*/
- }
- }
|