Initialize() public method

Initializes the ClientHelper.
Initialize() is to be called by user-code directly only if the ClientHelper is not consumed through the designer surface of the IDE.
public Initialize ( ) : void
return void
コード例 #1
0
ファイル: ServiceClientBase.cs プロジェクト: avs009/gsf
        /// <summary>
        /// Initializes the remoting client, client helper, and error logger.
        /// </summary>
        public void Initialize()
        {
            CategorizedSettingsElementCollection remotingClientSettings;

            try
            {
                remotingClientSettings = ConfigurationFile.Current.Settings["remotingClient"];
            }
            catch
            {
                remotingClientSettings = null;
            }

            if ((object)remotingClientSettings != null)
            {
                if (remotingClientSettings.Cast<CategorizedSettingsElement>().Any(element => element.Name.Equals("EnabledSslProtocols", StringComparison.OrdinalIgnoreCase) && !element.Value.Equals("None", StringComparison.OrdinalIgnoreCase)))
                    m_remotingClient = InitializeTlsClient();
                else
                    m_remotingClient = InitializeTcpClient();
            }
            else
            {
                m_remotingClient = InitializeTlsClient();
            }

            m_clientHelper = new ClientHelper();
            m_clientHelper.PersistSettings = true;
            m_clientHelper.RemotingClient = m_remotingClient;
            m_clientHelper.Initialize();

            m_errorLogger = new ErrorLogger();
            m_errorLogger.ErrorLog.FileName = "ServiceClient.ErrorLog.txt";
            m_errorLogger.LogToEventLog = false;
            m_errorLogger.LogToUI = true;
            m_errorLogger.PersistSettings = true;
            m_errorLogger.ErrorLog.Initialize();
            m_errorLogger.Initialize();
        }
コード例 #2
0
        /// <summary>
        /// Initializes the remoting client, client helper, and error logger.
        /// </summary>
        public void Initialize()
        {
            CategorizedSettingsElementCollection remotingClientSettings;
            string[] args;
            string filter;

            try
            {
                remotingClientSettings = ConfigurationFile.Current.Settings["remotingClient"];
            }
            catch
            {
                remotingClientSettings = null;
            }

            if ((object)remotingClientSettings != null)
            {
                if (remotingClientSettings.Cast<CategorizedSettingsElement>().Any(element => element.Name.Equals("EnabledSslProtocols", StringComparison.OrdinalIgnoreCase) && !element.Value.Equals("None", StringComparison.OrdinalIgnoreCase)))
                    m_remotingClient = InitializeTlsClient();
                else
                    m_remotingClient = InitializeTcpClient();
            }
            else
            {
                m_remotingClient = InitializeTlsClient();
            }

            args = Arguments.ToArgs(Environment.CommandLine);

            filter = Enumerable.Range(0, args.Length)
                .Where(index => args[index].StartsWith("--filter=", StringComparison.OrdinalIgnoreCase))
                .Select(index => Regex.Replace(args[index], "^--filter=", "", RegexOptions.IgnoreCase))
                .FirstOrDefault() ?? ClientHelper.DefaultStatusMessageFilter;

            m_clientHelper = new ClientHelper();
            m_clientHelper.PersistSettings = true;
            m_clientHelper.RemotingClient = m_remotingClient;
            m_clientHelper.StatusMessageFilter = filter;
            m_clientHelper.Initialize();

            m_errorLogger = new ErrorLogger();
            m_errorLogger.ErrorLog.FileName = "ServiceClient.ErrorLog.txt";
            m_errorLogger.LogToEventLog = false;
            m_errorLogger.LogToUI = true;
            m_errorLogger.PersistSettings = true;
            m_errorLogger.ErrorLog.Initialize();
            m_errorLogger.Initialize();
        }