Esempio n. 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:Stumps.Server.RuleContract"/> class.
        /// </summary>
        /// <param name="rule">The <see cref="T:Stumps.IStumpRule"/> used to create the instance.</param>
        public RuleContract(IStumpRule rule)
            : this()
        {
            if (rule == null)
            {
                return;
            }

            this.RuleName = rule.GetType().Name;
            var settings = rule.GetRuleSettings();

            foreach (var setting in settings)
            {
                _ruleSettings.Add(setting);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Requires the incoming HTTP request to match the specified <see cref="T:Stumps.IStumpRule"/>.
        /// </summary>
        /// <param name="stump">The <see cref="T:Stumps.Stump"/> intercepting incomming HTTP requests.</param>
        /// <param name="rule">The <see cref="T:Stumps.IStumpRule"/> required to match.</param>
        /// <returns>The calling <see cref="T:Stumps.Stump"/>.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="stump"/> is <c>null</c>.</exception>
        public static Stump MatchingRule(this Stump stump, IStumpRule rule)
        {
            if (stump == null)
            {
                throw new ArgumentNullException("stump");
            }

            stump.AddRule(rule);
            return stump;
        }
Esempio n. 3
0
        /// <summary>
        ///     Adds the rule to the Stump.
        /// </summary>
        /// <param name="rule">The rule to add to the Stump.</param>
        public void AddRule(IStumpRule rule)
        {
            if (rule == null)
            {
                throw new ArgumentNullException("rule");
            }

            _ruleList.Add(rule);
        }