private object[] GetCustomAttributeValues <T>(ConstructorInfo ctor, CsvParser <T> csvParser) { object[] parameters = new object[paramAttrs.Length]; for (int i = 0; i < paramAttrs.Length; i++) { ConfiguratorAttribute attr = paramAttrs[i]; parameters[i] = csvParser.GetParsedValue(Parameters[i].ParameterType, csvParser.CurrentLine().ElementAt(attr.GetCol())); } return(parameters); }
/// <summary> /// Configures the repository using information from the assembly. /// </summary> /// <param name="assembly">The assembly containing <see cref="T:log4net.Config.ConfiguratorAttribute" /> /// attributes which define the configuration for the repository.</param> /// <param name="repository">The repository to configure.</param> /// <exception cref="T:System.ArgumentNullException"> /// <para><paramref name="assembly" /> is <see langword="null" />.</para> /// <para>-or-</para> /// <para><paramref name="repository" /> is <see langword="null" />.</para> /// </exception> private void ConfigureRepository(Assembly assembly, ILoggerRepository repository) { if ((object)assembly == null) { throw new ArgumentNullException("assembly"); } if (repository == null) { throw new ArgumentNullException("repository"); } object[] array = assembly.GetCustomAttributes(typeof(ConfiguratorAttribute)).ToArray(); if (array != null && array.Length != 0) { Array.Sort(array); object[] array2 = array; for (int i = 0; i < array2.Length; i++) { ConfiguratorAttribute configuratorAttribute = (ConfiguratorAttribute)array2[i]; if (configuratorAttribute != null) { try { configuratorAttribute.Configure(assembly, repository); } catch (Exception exception) { LogLog.Error(declaringType, "Exception calling [" + configuratorAttribute.GetType().FullName + "] .Configure method.", exception); } } } } if (!(repository.Name == "log4net-default-repository")) { return; } string appSetting = SystemInfo.GetAppSetting("log4net.Config"); if (appSetting == null || appSetting.Length <= 0) { return; } string text = null; try { text = SystemInfo.ApplicationBaseDirectory; } catch (Exception exception2) { LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. appSettings log4net.Config path [" + appSetting + "] will be treated as an absolute URI", exception2); } string text2 = appSetting; if (text != null) { text2 = Path.Combine(text, appSetting); } bool result = false; bool.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out result); if (result) { FileInfo configFile = null; try { configFile = new FileInfo(text2); } catch (Exception exception3) { LogLog.Error(declaringType, "DefaultRepositorySelector: Exception while parsing log4net.Config file physical path [" + text2 + "]", exception3); } try { LogLog.Debug(declaringType, "Loading and watching configuration for default repository from AppSettings specified Config path [" + text2 + "]"); XmlConfigurator.ConfigureAndWatch(repository, configFile); } catch (Exception exception4) { LogLog.Error(declaringType, "DefaultRepositorySelector: Exception calling XmlConfigurator.ConfigureAndWatch method with ConfigFilePath [" + text2 + "]", exception4); } return; } Uri uri = null; try { uri = new Uri(text2); } catch (Exception exception5) { LogLog.Error(declaringType, "Exception while parsing log4net.Config file path [" + appSetting + "]", exception5); } if (uri != null) { LogLog.Debug(declaringType, "Loading configuration for default repository from AppSettings specified Config URI [" + uri.ToString() + "]"); try { XmlConfigurator.Configure(repository, uri); } catch (Exception exception6) { LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri [" + uri + "]", exception6); } } }