Example #1
0
        private static void GetLogProvider()
        {
            if (LogProvider == null)
            {
                lock (_syncObject)
                {
                    if (LogProvider == null)
                    {
                        ProviderSetting currentProviderSetting = null;
                        ProviderConfigurationSection section   = (ProviderConfigurationSection)System.Configuration.ConfigurationManager.GetSection("LoggingProvider");
                        ProviderCollection           providers = section.Providers;

                        foreach (ProviderSetting ps in providers)
                        {
                            if (ps.Name == section.DefaultProvider)
                            {
                                currentProviderSetting = ps;
                                break;
                            }
                        }

                        if (currentProviderSetting != null)
                        {
                            Type t = Type.GetType(currentProviderSetting.Type);

                            if (t != null)
                            {
                                Type[] paramTypes = new Type[1]
                                {
                                    typeof(string)
                                };
                                ConstructorInfo providerConstructorInfo = t.GetConstructor(paramTypes);

                                object[] paramValues = new object[1]
                                {
                                    currentProviderSetting.LoggerName
                                };

                                LogProvider = (ILogProvider)providerConstructorInfo.Invoke(paramValues);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        protected override object GetElementKey(ConfigurationElement element)
        {
            ProviderSetting provider = element as ProviderSetting;

            return(provider.Name);
        }