/// <summary> /// Carga la configuración a partir de <paramref name="section"/> /// </summary> /// <param name="section">Sección de configuración del archivo de configuración</param> private static void LoadConfigurationFromConfigurationSection( ExceptionHandlingSection section) { foreach (ExceptionPolicyElement policyElement in section.PolicyCollection) { PolicyConfiguration policyConf = new PolicyConfiguration() { Name = policyElement.Name, Log = policyElement.IsLogged, ExceptionPolicyList = new List <ExceptionPolicyConfiguration>() }; foreach (ExceptionTypeElement exTypeElement in policyElement.ExceptionTypeCollection) { ExceptionPolicyConfiguration politicaExcepcion = new ExceptionPolicyConfiguration() { Name = exTypeElement.Name, Action = exTypeElement.HandlingAction, NewExceptionMessage = exTypeElement.NewExceptionMessage, ExceptionType = exTypeElement.ExceptionType, NewExceptionType = exTypeElement.NewExceptionType }; policyConf.ExceptionPolicyList.Add(politicaExcepcion); } ExceptionPolicy.policyConfigurationList.Add(policyConf); } }
/// <summary> /// Carga los valores de configuración de la política /// </summary> private static void LoadConfiguration() { policyConfigurationList = new List <PolicyConfiguration>(); ExceptionHandlingSection section = null; try { section = ConfigurationManager.GetSection(exceptionHandlingSectionName) as ExceptionHandlingSection; } catch (ConfigurationErrorsException ceex) { throw new ExceptionHandlingException(Messages.ExceptionHandlingLoadError, ceex); } if (section == null) { LoadConfigurationFromDefaultValues(); } else { LoadConfigurationFromConfigurationSection(section); } traceSource = new TraceSource(Defaults.DefaultTraceSource, SourceLevels.All); }
protected override void Act() { var resolvedCategoryReference = ExceptionHandlingSection .GetDescendentsOfType <LoggingExceptionHandlerData>() .Single(x => x.Name == "General"); unresolvedCategoryReference = ExceptionHandlingSection.GetDescendentsOfType <LoggingExceptionHandlerData>() .Single(x => x.Name == "InvalidCategoryName"); resolvedCategoryProperty = resolvedCategoryReference.Property("LogCategory"); }
protected override void Arrange() { base.Arrange(); var categoryReference = ExceptionHandlingSection .GetDescendentsOfType <LoggingExceptionHandlerData>().First(); property = categoryReference.Property("LogCategory"); propertiesChanged = new Stack <string>(); property.PropertyChanged += (o, e) => propertiesChanged.Push(e.PropertyName); }