Ejemplo n.º 1
0
        /// <summary>
        /// The main application entry point.
        /// </summary>
        protected override void Main()
        {
            // Initialize the environment.

            SysLog.LogProvider = new SwitchLogProvider();

            var assembly = Assembly.GetExecutingAssembly();

            Helper.InitializeApp(assembly);
            Config.SetConfigPath(assembly);
            CorePerf.Initialize();

            CoreApp.InstallPath = Helper.GetAssemblyFolder(Helper.GetEntryAssembly());

            // Initialize the global NeonSwitch related variables.

            Switch.SetGlobal(SwitchGlobal.NeonSwitchVersion, Build.Version);
            Switch.SetGlobal(SwitchGlobal.FreeSwitchVersion, Helper.GetVersionString(Assembly.GetAssembly(typeof(freeswitch))));

            // Load the application configuration settings.

            CoreApp.Config         = new Config("NeonSwitch");
            CoreApp.BkTaskInterval = CoreApp.Config.Get("BkTaskInterval", TimeSpan.FromSeconds(1));

            // Load the switch subcommand handlers.

            Switch.RegisterAssemblySubcommands(assembly);

            // Create a service host for the application service and launch it.

            var logProvider =
                new CompositeSysLogProvider(
                    new NativeSysLogProvider(SwitchConst.NeonSwitchName),
                    new SwitchLogProvider());

            serviceHost = new SwitchServiceHost();
            serviceHost.Initialize(new string[0], new CoreAppService(), logProvider, true);
        }