Exemplo n.º 1
0
 public HttpServer(SettingsModel settings)
     : base(settings.webPort)
 {
     serverName = "HttpServer";
     this.settings = settings;
     router = new ClientRouter(this);
 }
Exemplo n.º 2
0
 public ControlServer(SettingsModel settings)
     : base(settings.controlPort)
 {
     serverName = "ControlServer";
     this.settings = settings;
     router = new AdminRouter(this);
 }
Exemplo n.º 3
0
 public static void SerializeSettingsXML(SettingsModel settings)
 {
     XmlSerializer SerializerObj = new XmlSerializer(typeof(SettingsModel));
     string root = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
     TextWriter WriteFileStream = new StreamWriter(root + "/XML/settings.xml");
     SerializerObj.Serialize(WriteFileStream, settings);
     WriteFileStream.Close();
 }
Exemplo n.º 4
0
 public static string SerializeJSON(SettingsModel settings)
 {
     MemoryStream stream = new MemoryStream();
     DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SettingsModel));
     ser.WriteObject(stream, settings);
     stream.Position = 0;
     StreamReader sr = new StreamReader(stream);
     string str = sr.ReadToEnd();
     return str;
 }
Exemplo n.º 5
0
 public void UpdateSettingsModel(Dictionary<string, string> dict)
 {
     SettingsModel settings = new SettingsModel();
     foreach (KeyValuePair<string, string> entry in dict)
     {
         //if (!new Regex(@"^\w+$").IsMatch(entry.Value)) return;
         switch (entry.Key)
         {
             case "controlPort":
                 int cport = 0;
                 if (!int.TryParse(entry.Value, out cport)) return;
                 settings.controlPort = cport;
                 break;
             case "defaultPage":
                 settings.defaultPage = entry.Value;
                 break;
             case "dirListing":
                 settings.dirListing = entry.Value == "on" ? settings.dirListing = "true" : settings.dirListing = "false";
                 break;
             case "webPort":
                 int wport = 0;
                 if (!int.TryParse(entry.Value, out wport)) return;
                 settings.webPort = wport;
                 break;
             case "webRoot":
                 settings.webRoot = System.Net.WebUtility.UrlDecode(entry.Value);
                 break;
             default:
                 settings.dirListing = entry.Value == "on" ? settings.dirListing = "true" : settings.dirListing = "false";
                 break;
         }
     }
     XMLParser.SerializeSettingsXML(settings);
     this.settings = settings;
 }