Beispiel #1
0
        private static void Validate(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("httpModule");
            }

            HttpModuleAction elem = (HttpModuleAction)value;

            if (HttpModuleAction.IsSpecialModule(elem.Type))
            {
                throw new ConfigurationErrorsException(
                          SR.GetString(SR.Special_module_cannot_be_added_manually, elem.Type),
                          elem.ElementInformation.Properties["type"].Source,
                          elem.ElementInformation.Properties["type"].LineNumber);
            }

            if (HttpModuleAction.IsSpecialModuleName(elem.Name))
            {
                throw new ConfigurationErrorsException(
                          SR.GetString(SR.Special_module_cannot_be_added_manually, elem.Name),
                          elem.ElementInformation.Properties["name"].Source,
                          elem.ElementInformation.Properties["name"].LineNumber);
            }
        }
        protected override bool IsElementRemovable(ConfigurationElement element)
        {
            HttpModuleAction action = (HttpModuleAction)element;

            if (base.BaseIndexOf(action) != -1)
            {
                return(true);
            }
            if (HttpModuleAction.IsSpecialModuleName(action.Name))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Special_module_cannot_be_removed_manually", new object[] { action.Name }), action.FileName, action.LineNumber);
            }
            throw new ConfigurationErrorsException(System.Web.SR.GetString("Module_not_in_app", new object[] { action.Name }), action.FileName, action.LineNumber);
        }
        protected override bool IsElementRemovable(ConfigurationElement element)
        {
            HttpModuleAction module = (HttpModuleAction)element;

            if (BaseIndexOf(module) == -1) // does it exist?
            {
                if (HttpModuleAction.IsSpecialModuleName(module.Name))
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Special_module_cannot_be_removed_manually, module.Name),
                                                           module.FileName, module.LineNumber);
                }
                else
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Module_not_in_app, module.Name),
                                                           module.FileName, module.LineNumber);
                }
            }
            return(true);
        }