Exemplo n.º 1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Read the config file
            string JsonString;

            try
            {
                JsonString = File.ReadAllText(MyProgramDir_Config);
            }
            catch (IOException)
            {
                JsonString = "";
            }

            ProgramConfig ConfigInstance = new ProgramConfig();

            try
            {
                JToken Config = JToken.Parse(JsonString);
                JToken Config_ServedInterfaceList = Config["ServedInterfaceList"];
                foreach (JToken Config_ServedInterface_Item in Config_ServedInterfaceList)
                {
                    ConfigInstance.LanInterfaceList.Add(new ProgramConfigLanInterface(
                                                            Config_ServedInterface_Item["Id"].Value <string>(),
                                                            Config_ServedInterface_Item["NetworkId"].Value <UInt16>()
                                                            ));
                }
                JToken Config_WanInterfaceList = Config["WanInterfaceList"];
                foreach (JToken Config_WanInterface_Item in Config_WanInterfaceList)
                {
                    ConfigInstance.WanInterfaceList.Add(Config_WanInterface_Item["Id"].Value <string>());
                }
            }
            catch (JsonReaderException)
            {
            }
            catch (ArgumentException)
            {
            }

            LogLocalInterfaces();

            // Run services
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new Service(ConfigInstance)
            };
            ServiceBase.Run(ServicesToRun);
        }
Exemplo n.º 2
0
 public Service(ProgramConfig Config)
 {
     this.ProgramConfigInstance = Config;
     InitializeComponent();
 }