Example #1
0
        /// <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);
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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");
        }
Example #4
0
        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);
        }