GSF.ServiceProcess.ServiceHelper.Initialize C# (CSharp) Method

Initialize() public method

Initializes the ServiceHelper.
Initialize() is to be called by user-code directly only if the ServiceHelper object is not consumed through the designer surface of the IDE.
public Initialize ( ) : void
return void
        public void Initialize()
        {
            if (m_initialized)
                return;

            LoadSettings();         // Load settings from the config file.
            m_initialized = true;   // Initialize only once.
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Initializes the service helper.
        /// </summary>
        public void InitializeServiceHelper()
        {
            CategorizedSettingsElementCollection remotingServerSettings = ConfigurationFile.Current.Settings["remotingServer"];

            m_serviceHelper = new ServiceHelper();

            if (remotingServerSettings.Cast<CategorizedSettingsElement>().Any(element => element.Name.Equals("EnabledSslProtocols", StringComparison.OrdinalIgnoreCase) && !element.Value.Equals("None", StringComparison.OrdinalIgnoreCase)))
                m_remotingServer = InitializeTlsServer();
            else
                m_remotingServer = InitializeTcpServer();

            m_serviceHelper.ErrorLogger.ErrorLog.FileName = "ErrorLog.txt";
            m_serviceHelper.ErrorLogger.ErrorLog.PersistSettings = true;
            m_serviceHelper.ErrorLogger.ErrorLog.SettingsCategory = "ErrorLog";
            m_serviceHelper.ErrorLogger.ErrorLog.Initialize();

            m_serviceHelper.ErrorLogger.LogToEventLog = false;
            m_serviceHelper.ErrorLogger.PersistSettings = true;
            m_serviceHelper.ErrorLogger.SmtpServer = "";
            m_serviceHelper.ErrorLogger.Initialize();

            m_serviceHelper.ProcessScheduler.PersistSettings = true;
            m_serviceHelper.ProcessScheduler.SettingsCategory = "ProcessScheduler";
            m_serviceHelper.ProcessScheduler.Initialize();

            m_serviceHelper.StatusLog.FileName = "StatusLog.txt";
            m_serviceHelper.StatusLog.PersistSettings = true;
            m_serviceHelper.StatusLog.SettingsCategory = "StatusLog";
            m_serviceHelper.StatusLog.Initialize();

            m_serviceHelper.ParentService = this;
            m_serviceHelper.PersistSettings = true;
            m_serviceHelper.RemotingServer = m_remotingServer;
            m_serviceHelper.Initialize();
        }
ServiceHelper