/// <summary> /// Initializes a rule from an enumerable list of <see cref="T:Stumps.RuleSetting" /> objects. /// </summary> /// <param name="settings">The enumerable list of <see cref="T:Stumps.RuleSetting" /> objects.</param> public void InitializeFromSettings(IEnumerable<RuleSetting> settings) { if (this.IsInitialized) { throw new InvalidOperationException(BaseResources.BodyRuleAlreadyInitializedError); } if (settings == null) { throw new ArgumentNullException("settings"); } var helper = new RuleSettingsHelper(settings); var name = helper.FindString(HeaderRule.HeaderNameSetting, string.Empty); var value = helper.FindString(HeaderRule.HeaderValueSetting, string.Empty); InitializeRule(name, value); }
/// <summary> /// Initializes a rule from an enumerable list of <see cref="T:Stumps.RuleSetting" /> objects. /// </summary> /// <param name="settings">The enumerable list of <see cref="T:Stumps.RuleSetting" /> objects.</param> public void InitializeFromSettings(IEnumerable<RuleSetting> settings) { if (this.IsInitialized) { throw new InvalidOperationException(BaseResources.BodyRuleAlreadyInitializedError); } if (settings == null) { throw new ArgumentNullException("settings"); } var helper = new RuleSettingsHelper(settings); _maximumLength = helper.FindInteger(BodyLengthRule.MaximumLengthSettingName, BodyLengthRule.DefaultMaximumLength); _minimumLength = helper.FindInteger(BodyLengthRule.MinimumLengthSettingName, BodyLengthRule.DefaultMinimumLength); this.IsInitialized = true; }
/// <summary> /// Gets an enumerable list of <see cref="T:Stumps.RuleSetting" /> objects used to represent the current instance. /// </summary> /// <returns> /// An enumerable list of <see cref="T:Stumps.RuleSetting" /> objects used to represent the current instance. /// </returns> public IEnumerable<RuleSetting> GetRuleSettings() { var helper = new RuleSettingsHelper(); helper.Add(BodyLengthRule.MaximumLengthSettingName, _maximumLength); helper.Add(BodyLengthRule.MinimumLengthSettingName, _minimumLength); return helper.ToEnumerableList(); }
/// <summary> /// Initializes a rule from an enumerable list of <see cref="T:Stumps.RuleSetting" /> objects. /// </summary> /// <param name="settings">The enumerable list of <see cref="T:Stumps.RuleSetting" /> objects.</param> public void InitializeFromSettings(IEnumerable<RuleSetting> settings) { if (this.IsInitialized) { throw new InvalidOperationException(BaseResources.BodyRuleAlreadyInitializedError); } if (settings == null) { throw new ArgumentNullException("settings"); } var helper = new RuleSettingsHelper(settings); var length = helper.FindInteger(BodyMatchRule.BodyLengthSetting, 0); var md5Hash = helper.FindString(BodyMatchRule.BodyMd5HashSetting, "000000"); InitializeRule(length, md5Hash); }