/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { Config = JacoServConfigurationReader.BuildConfiguration(args[0]); Listener server = new Listener(Config.Port); server.MessageRecieved += listener_OnMessageRecieved; Thread.Sleep(Timeout.Infinite); }
/// <summary> /// Builds the configuration. /// </summary> /// <returns>The configuration.</returns> /// <param name="filePath">File path.</param> public static JacoServConfiguration BuildConfiguration(string filePath) { JacoServConfiguration config = new JacoServConfiguration { RootPath = Directory.GetCurrentDirectory(), FileNotFoundPath = "", Port = 80 }; foreach (string line in File.ReadAllLines(filePath)) { if (line == null || line == "" || line == "\n" || line.Trim().StartsWith("#")) continue; string[] parts = line.Split(' '); switch (parts[0].ToLower()) { case "rootpath": config.RootPath = parts[1]; break; case "filenotfoundpath": config.FileNotFoundPath = parts[1]; break; case "port": config.Port = Convert.ToInt32(parts[1]); break; case "extensionspath": foreach (string extensionLine in File.ReadAllLines(parts[1])) { string[] extensionParts = extensionLine.Split(' '); string[] extensions = extensionParts[0].Split(','); foreach (string extension in extensions) config.Applications.Add(extension, extensionParts[1]); } break; case "rootfile": foreach (string fileName in parts[1].Split(',')) config.RootFiles.Add(fileName); break; } } return config; }