예제 #1
0
        /// <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;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
		/// <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, object config)
		{
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            
            XmlNode toNode = node.Attributes.GetNamedItem(Constants.AttrTo);
			if (toNode == null)
			{
				throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.AttributeRequired, Constants.AttrTo), node);
			}

			bool permanent = true;
			XmlNode permanentNode = node.Attributes.GetNamedItem(Constants.AttrPermanent);
			if (permanentNode != null)
			{
				permanent = Convert.ToBoolean(permanentNode.Value);
			}

			RedirectAction action = new RedirectAction(toNode.Value, permanent);
			ParseConditions(node, action.Conditions, false, config);
			return action;
		}