当前位置: 首页>>代码示例>>C#>>正文


C# XmlNode.GetRequiredAttribute方法代码示例

本文整理汇总了C#中System.Xml.XmlNode.GetRequiredAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.GetRequiredAttribute方法的具体用法?C# XmlNode.GetRequiredAttribute怎么用?C# XmlNode.GetRequiredAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlNode的用法示例。


在下文中一共展示了XmlNode.GetRequiredAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string propertyName = node.GetRequiredAttribute(Constants.AttrProperty);
            string appSettingKey = node.GetRequiredAttribute(Constants.AttrKey);

            return new SetAppSettingPropertyAction(propertyName, appSettingKey);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:22,代码来源:SetAppSettingPropertyActionParser.cs

示例2: Parse

        /// <summary>
        ///     Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, RewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string cookieName = node.GetRequiredAttribute(Constants.AttrCookie);
            string cookieValue = node.GetRequiredAttribute(Constants.AttrValue, true);

            return new SetCookieAction(cookieName, cookieValue);
        }
开发者ID:hnq90,项目名称:hblog-asp.net-3tiers,代码行数:22,代码来源:SetCookieActionParser.cs

示例3: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            string to = node.GetRequiredAttribute(Constants.AttrTo, true);
            bool permanent = node.GetBooleanAttribute(Constants.AttrPermanent) ?? true;

            RedirectAction action = new RedirectAction(to, permanent);
            ParseConditions(node, action.Conditions, false, config);
            return action;
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:20,代码来源:RedirectActionParser.cs

示例4: Parse

        /// <summary>
        ///     Parses the condition.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <returns>The condition parsed, or null if nothing parsed.</returns>
        public IRewriteCondition Parse(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            XmlNode headerAttr = node.Attributes.GetNamedItem(Constants.AttrHeader);
            if (headerAttr == null)
            {
                return null;
            }

            string match = node.GetRequiredAttribute(Constants.AttrMatch, true);
            return new PropertyMatchCondition(headerAttr.Value, match);
        }
开发者ID:hnq90,项目名称:hblog-asp.net-3tiers,代码行数:21,代码来源:HeaderMatchConditionParser.cs

示例5: Parse

        /// <summary>
        /// Parses the condition.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <returns>The condition parsed, or null if nothing parsed.</returns>
        public IRewriteCondition Parse(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            string property = node.GetOptionalAttribute(Constants.AttrProperty);
            if (property == null)
            {
                return null;
            }

            string match = node.GetRequiredAttribute(Constants.AttrMatch, true);

            return new PropertyMatchCondition(property, match);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:22,代码来源:PropertyMatchConditionParser.cs

示例6: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string to = node.GetRequiredAttribute(Constants.AttrTo, true);

            RewriteProcessing processing = ParseProcessing(node);

            RewriteAction action = new RewriteAction(to, processing);
            ParseConditions(node, action.Conditions, false, config);

            return action;
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:26,代码来源:RewriteActionParser.cs

示例7: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string headerName = node.GetOptionalAttribute(Constants.AttrHeader);
            if (headerName == null)
            {
                return null;
            }

            string headerValue = node.GetRequiredAttribute(Constants.AttrValue, true);

            return new AddHeaderAction(headerName, headerValue);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:27,代码来源:AddHeaderActionParser.cs

示例8: ReadRegisterTransform

        private static void ReadRegisterTransform(XmlNode node, RewriterConfiguration config)
        {
            if (node.ChildNodes.Count > 0)
            {
                throw new ConfigurationErrorsException(
                    MessageProvider.FormatString(Message.ElementNoElements, Constants.ElementRegister), node);
            }

            string type = node.GetRequiredAttribute(Constants.AttrTransform);

            // Transform type specified.
            // Create an instance and add it as the mapper handler for this map.
            var transform = TypeHelper.Activate(type, null) as IRewriteTransform;
            if (transform == null)
            {
                throw new ConfigurationErrorsException(
                    MessageProvider.FormatString(Message.InvalidTypeSpecified, type, typeof (IRewriteTransform)), node);
            }

            config.TransformFactory.AddTransform(transform);
        }
开发者ID:hnq90,项目名称:hblog-asp.net-3tiers,代码行数:21,代码来源:RewriterConfigurationReader.cs

示例9: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string propertyName = node.GetOptionalAttribute(Constants.AttrProperty);
            if (String.IsNullOrEmpty(propertyName))
            {
                return null;
            }

            string propertyValue = node.GetRequiredAttribute(Constants.AttrValue, true);

            return new SetPropertyAction(propertyName, propertyValue);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:27,代码来源:SetPropertyActionParser.cs

示例10: Parse

        /// <summary>
        ///     Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, RewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string to = node.GetRequiredAttribute(Constants.AttrTo, true);

            XmlNode processingNode = node.Attributes[Constants.AttrProcessing];

            var processing = RewriteProcessing.ContinueProcessing;
            if (processingNode != null)
            {
                if (processingNode.Value == Constants.AttrValueRestart)
                {
                    processing = RewriteProcessing.RestartProcessing;
                }
                else if (processingNode.Value == Constants.AttrValueStop)
                {
                    processing = RewriteProcessing.StopProcessing;
                }
                else if (processingNode.Value != Constants.AttrValueContinue)
                {
                    throw new ConfigurationErrorsException(
                        MessageProvider.FormatString(Message.ValueOfProcessingAttribute, processingNode.Value,
                                                     Constants.AttrValueContinue, Constants.AttrValueRestart,
                                                     Constants.AttrValueStop), node);
                }
            }

            var action = new RewriteAction(to, processing);
            ParseConditions(node, action.Conditions, false, config);
            return action;
        }
开发者ID:hnq90,项目名称:hblog-asp.net-3tiers,代码行数:45,代码来源:RewriteActionParser.cs

示例11: Parse

        /// <summary>
        /// Parses the node.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <param name="config">The rewriter configuration.</param>
        /// <returns>The parsed action, or null if no action parsed.</returns>
        public override IRewriteAction Parse(XmlNode node, RewriterConfiguration config)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            string to = node.GetRequiredAttribute(Constants.AttrTo, true);

            bool permanent = true;
            XmlNode permanentNode = node.Attributes.GetNamedItem(Constants.AttrPermanent);
            if (permanentNode != null)
            {
                if (!bool.TryParse(permanentNode.Value, out permanent))
                {
                    throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.InvalidBooleanAttribute, Constants.AttrPermanent), node);
                }
            }

            RedirectAction action = new RedirectAction(to, permanent);
            ParseConditions(node, action.Conditions, false, config);
            return action;
        }
开发者ID:rachziger,项目名称:urlrewriter,代码行数:29,代码来源:RedirectActionParser.cs

示例12: ReadErrorHandler

        private static void ReadErrorHandler(XmlNode node, IRewriterConfiguration config)
        {
            string code = node.GetRequiredAttribute(Constants.AttrCode);

            XmlNode typeNode = node.Attributes[Constants.AttrType];
            XmlNode urlNode = node.Attributes[Constants.AttrUrl];
            if (typeNode == null && urlNode == null)
            {
                throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.AttributeRequired, Constants.AttrUrl), node);
            }

            IRewriteErrorHandler handler = null;
            if (typeNode != null)
            {
                // <error-handler code="500" url="/oops.aspx" />
                handler = TypeHelper.Activate(typeNode.Value, null) as IRewriteErrorHandler;
                if (handler == null)
                {
                    throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.InvalidTypeSpecified, typeNode.Value, typeof(IRewriteErrorHandler)), node);
                }
            }
            else
            {
                handler = new DefaultErrorHandler(urlNode.Value);
            }

            int statusCode;
            if (!Int32.TryParse(code, out statusCode))
            {
                throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.InvalidHttpStatusCode, code), node);
            }

            config.ErrorHandlers.Add(statusCode, handler);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:34,代码来源:RewriterConfigurationReader.cs

示例13: ReadRegisterParser

        private static void ReadRegisterParser(XmlNode node, IRewriterConfiguration config)
        {
            if (node.ChildNodes.Count > 0)
            {
                throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.ElementNoElements, Constants.ElementRegister), node);
            }

            string type = node.GetRequiredAttribute(Constants.AttrParser);

            object parser = TypeHelper.Activate(type, null);
            IRewriteActionParser actionParser = parser as IRewriteActionParser;
            if (actionParser != null)
            {
                config.ActionParserFactory.Add(actionParser);
            }

            IRewriteConditionParser conditionParser = parser as IRewriteConditionParser;
            if (conditionParser != null)
            {
                config.ConditionParserPipeline.Add(conditionParser);
            }
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:22,代码来源:RewriterConfigurationReader.cs

示例14: ReadRegisterLogger

        private static void ReadRegisterLogger(XmlNode node, IRewriterConfiguration config)
        {
            if (node.ChildNodes.Count > 0)
            {
                throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.ElementNoElements, Constants.ElementRegister), node);
            }

            string type = node.GetRequiredAttribute(Constants.AttrLogger);

            // Logger type specified.  Create an instance and add it
            // as the mapper handler for this map.
            IRewriteLogger logger = TypeHelper.Activate(type, null) as IRewriteLogger;
            if (logger != null)
            {
                config.Logger = logger;
            }
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:17,代码来源:RewriterConfigurationReader.cs

示例15: ReadMapping

        private static void ReadMapping(XmlNode node, IRewriterConfiguration config)
        {
            // Name attribute.
            string mappingName = node.GetRequiredAttribute(Constants.AttrName);

            // Mapper type not specified.  Load in the hash map.
            StringDictionary map = new StringDictionary();
            foreach (XmlNode mapNode in node.ChildNodes)
            {
                if (mapNode.NodeType == XmlNodeType.Element)
                {
                    if (mapNode.LocalName == Constants.ElementMap)
                    {
                        string fromValue = mapNode.GetRequiredAttribute(Constants.AttrFrom, true);
                        string toValue = mapNode.GetRequiredAttribute(Constants.AttrTo, true);

                        map.Add(fromValue, toValue);
                    }
                    else
                    {
                        throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.ElementNotAllowed, mapNode.LocalName), node);
                    }
                }
            }

            IRewriteTransform mapping = new StaticMappingTransform(mappingName, map);

            config.TransformFactory.Add(mapping);
        }
开发者ID:Thesykan,项目名称:urlrewriter,代码行数:29,代码来源:RewriterConfigurationReader.cs


注:本文中的System.Xml.XmlNode.GetRequiredAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。