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(Properties); if (Type == ServerType.GPS) return Serialization.Deserialize(Properties); if (Type == ServerType.AutoDiscovery) return Serialization.Deserialize(Properties); if (Type == ServerType.Schedule) return Serialization.Deserialize(Properties); if (Type == ServerType.Web) return Serialization.Deserialize(Properties); if (Type == ServerType.Certificate) return Serialization.Deserialize(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); }*/ } }