Ejemplo n.º 1
0
            private void ApplyRule()
            {
                var path = PropertyPathString;

                Log.Debug("Applying rules for path: {0}", path);

                var rule = _propertyFormattingRulesCollection.GetEffectiveFormattingRules(path);

                Log.Debug(rule.ToString());

                CurrentFormattingRules = rule;
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Applies all specified (non null) property values to the other
 /// FormattingRules instance
 /// </summary>
 /// <param name="other"></param>
 public void ApplySpecifiedRulesTo(FormattingRules other)
 {
     NewLineBeforeArrayStart.WhenHasValue(v => other.NewLineBeforeArrayStart   = v);
     NewLineBeforeArrayEnd.WhenHasValue(v => other.NewLineBeforeArrayEnd       = v);
     NewLineBeforeObjectStart.WhenHasValue(v => other.NewLineBeforeObjectStart = v);
     NewLineBeforeObjectEnd.WhenHasValue(v => other.NewLineBeforeObjectEnd     = v);
     NewLineBeforeProperty.WhenHasValue(v => other.NewLineBeforeProperty       = v);
     NewLineBeforeArrayItem.WhenHasValue(v => other.NewLineBeforeArrayItem     = v);
     IndentSize.WhenHasValue(v => other.IndentSize = v);
     WhitespaceAfterProperty.WhenHasValue(v => other.WhitespaceAfterProperty = v);
     WhitespaceBeforeNonFirstArrayItem.WhenHasValue(v => other.WhitespaceBeforeNonFirstArrayItem = v);
     IncludePropertiesWithNullValues.WhenHasValue(v => other.IncludePropertiesWithNullValues     = v);
     WhiteSpaceBeforeFirstArrayItem.WhenHasValue(v => other.WhiteSpaceBeforeFirstArrayItem       = v);
     WhiteSpaceBeforeFirstProperty.WhenHasValue(v => other.WhiteSpaceBeforeFirstProperty         = v);
     WhitespaceBeforeArrayEnd.WhenHasValue(v => other.WhitespaceBeforeArrayEnd   = v);
     WhitespaceBeforeObjectEnd.WhenHasValue(v => other.WhitespaceBeforeObjectEnd = v);
 }
Ejemplo n.º 3
0
 static FormattingRules()
 {
     Default = new FormattingRules
     {
         NewLineBeforeArrayStart = false,
         NewLineBeforeArrayEnd = true,
         NewLineBeforeArrayItem = true,
         NewLineBeforeObjectStart = false,
         NewLineBeforeProperty = true,
         NewLineBeforeObjectEnd = true,
         IndentSize = 2,
         WhitespaceAfterProperty = 1,
         WhitespaceBeforeNonFirstArrayItem = 1,
         IncludePropertiesWithNullValues = true,
         WhiteSpaceBeforeFirstProperty = 1,
         WhiteSpaceBeforeFirstArrayItem = 1,
         WhitespaceBeforeArrayEnd = 1,
         WhitespaceBeforeObjectEnd = 1
     };
 }
Ejemplo n.º 4
0
 static FormattingRules()
 {
     Default = new FormattingRules
     {
         NewLineBeforeArrayStart  = false,
         NewLineBeforeArrayEnd    = true,
         NewLineBeforeArrayItem   = true,
         NewLineBeforeObjectStart = false,
         NewLineBeforeProperty    = true,
         NewLineBeforeObjectEnd   = true,
         IndentSize = 2,
         WhitespaceAfterProperty           = 1,
         WhitespaceBeforeNonFirstArrayItem = 1,
         IncludePropertiesWithNullValues   = true,
         WhiteSpaceBeforeFirstProperty     = 1,
         WhiteSpaceBeforeFirstArrayItem    = 1,
         WhitespaceBeforeArrayEnd          = 1,
         WhitespaceBeforeObjectEnd         = 1
     };
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes an instance if the <see cref="PropertyFormattingRules"/> Type.
 /// </summary>
 /// <param name="propertyPattern">Specifies a regular expression to determine which properties the formatting rules should be applied to</param>
 /// <param name="formattingRules">The formatting rules to apply when writting the JSON data</param>
 public PropertyFormattingRules(string propertyPattern, FormattingRules formattingRules)
 {
     this.PropertyPatternRegex = new Regex(propertyPattern);
     this.FormattingRules      = formattingRules;
     this.Priority             = propertyPattern.Length;
 }
 /// <summary>
 /// Adds a set of formatting rules for the given property pattern
 /// </summary>
 /// <param name="propertyPattern">The property pattern</param>
 /// <param name="formattingRules">The formatting rules</param>
 public void AddPatternRule(string propertyPattern, FormattingRules formattingRules)
 {
     this.Add(new PropertyFormattingRules(propertyPattern, formattingRules));
 }
 /// <summary>
 /// Initializes an instance of the <see cref="PropertyFormattingRulesCollection"/> Type
 /// </summary>
 /// <param name="defaultFormattingRules">Specifies the default formatting rules</param>
 public PropertyFormattingRulesCollection(FormattingRules defaultFormattingRules)
 {
     _defaultFormattingRules = defaultFormattingRules;
 }
 /// <summary>
 /// Initializes an instance if the <see cref="PropertyFormattingRules"/> Type.
 /// </summary>
 /// <param name="propertyPattern">Specifies a regular expression to determine which properties the formatting rules should be applied to</param>
 /// <param name="formattingRules">The formatting rules to apply when writting the JSON data</param>
 public PropertyFormattingRules(string propertyPattern, FormattingRules formattingRules)
 {
     this.PropertyPatternRegex = new Regex(propertyPattern);
     this.FormattingRules = formattingRules;
     this.Priority = propertyPattern.Length;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Applies all specified (non null) property values to the other
 /// FormattingRules instance
 /// </summary>
 /// <param name="other"></param>
 public void ApplySpecifiedRulesTo(FormattingRules other)
 {
     NewLineBeforeArrayStart.WhenHasValue(v => other.NewLineBeforeArrayStart = v);
     NewLineBeforeArrayEnd.WhenHasValue(v => other.NewLineBeforeArrayEnd = v);
     NewLineBeforeObjectStart.WhenHasValue(v => other.NewLineBeforeObjectStart = v);
     NewLineBeforeObjectEnd.WhenHasValue(v => other.NewLineBeforeObjectEnd = v);
     NewLineBeforeProperty.WhenHasValue(v => other.NewLineBeforeProperty = v);
     NewLineBeforeArrayItem.WhenHasValue(v => other.NewLineBeforeArrayItem = v);
     IndentSize.WhenHasValue(v => other.IndentSize = v);
     WhitespaceAfterProperty.WhenHasValue(v => other.WhitespaceAfterProperty = v);
     WhitespaceBeforeNonFirstArrayItem.WhenHasValue(v => other.WhitespaceBeforeNonFirstArrayItem = v);
     IncludePropertiesWithNullValues.WhenHasValue(v => other.IncludePropertiesWithNullValues = v);
     WhiteSpaceBeforeFirstArrayItem.WhenHasValue(v => other.WhiteSpaceBeforeFirstArrayItem = v);
     WhiteSpaceBeforeFirstProperty.WhenHasValue(v => other.WhiteSpaceBeforeFirstProperty = v);
     WhitespaceBeforeArrayEnd.WhenHasValue(v => other.WhitespaceBeforeArrayEnd = v);
     WhitespaceBeforeObjectEnd.WhenHasValue(v => other.WhitespaceBeforeObjectEnd = v);
 }