/// <summary>
 /// Adds a rule to the configuration
 /// </summary>
 /// <param name="rule">The rule to add</param>
 /// <returns>This LoggingConfigBuilder</returns>
 public LoggingConfigBuilder AddRule(RuleConfig rule)
 {
     Rules.Add(rule);
     return this;
 }
Exemple #2
0
		/// <summary>
		/// Loads the rules from the configuration JSON tokens provided
		/// </summary>
		/// <param name="rulesJson">The JSON tokens from which to load the rules</param>
		/// <returns></returns>
		private static IList<RuleConfig> LoadRuleConfigs(ICollection<JToken> rulesJson)
		{
			var rules = new List<RuleConfig>();

			RuleConfig newRule;
			JToken include;
			JToken strictInclude;
			JToken exclude;
			JToken writeTo;
			JToken final;
			foreach (var ruleJson in rulesJson)
			{
				newRule = new RuleConfig();

				include = ruleJson[RuleIncludeTokenName];
				if (include != null)
					newRule.Include = include.Values<string>().ToList();

				strictInclude = ruleJson[RuleStrictIncludeTokenName];
				newRule.StrictInclude = strictInclude != null && strictInclude.Value<bool>();

				exclude = ruleJson[RuleExcludeTokenName];
				if (exclude != null)
					newRule.Exclude = exclude.Values<string>().ToList();

				writeTo = ruleJson[RuleWriteToTokenName];
				if (writeTo != null)
					newRule.WriteTo = writeTo.Values<string>().ToList();

				final = ruleJson[RuleFinalTokenName];
				newRule.Final = final != null && final.Value<bool>();

				rules.Add(newRule);
			}

			return rules;
		}