Esempio n. 1
0
 /**
  * Static utility method for facilitating writes on input object
  *
  * @param parent the source object
  * @param matchedElement the current spec (leaf) element that was matched with input
  * @param value to write
  * @param opMode to determine if write is applicable
  */
 protected static void SetData(JToken parent, MatchedElement matchedElement, JToken value, OpMode opMode)
 {
     if (parent is JObject source)
     {
         string key = matchedElement.RawKey;
         if (opMode.IsApplicable(source, key))
         {
             source[key] = value;
         }
     }
     else if (parent is JArray list && matchedElement is ArrayMatchedElement ame)
     {
         int origSize = ame.GetOrigSize();
         int reqIndex = ame.GetRawIndex();
         if (opMode.IsApplicable(list, reqIndex, origSize))
         {
             list[reqIndex] = value;
         }
     }
 public TemplatrSpecBuilder(OpMode opMode, IReadOnlyDictionary <string, IFunction> functionsMap)
 {
     _opMode       = opMode;
     _functionsMap = functionsMap;
 }