public override void ProcessList(IOrderedCompositeSpec spec, JArray inputList, WalkedPath walkedPath, JObject output, JObject context)
        {
            int?originalSize = walkedPath.LastElement().OrigSize;

            foreach (var kv in spec.GetLiteralChildren())
            {
                JToken subInputOptional = null;
                // If the data is an Array, but the spec keys are Non-Integer Strings,
                //  we are annoyed, but we don't stop the whole transform.
                // Just this part of the Transform won't work.
                if (Int32.TryParse(kv.Key, out int keyInt) &&
                    keyInt >= 0 && keyInt < inputList.Count)
                {
                    // if the input in not available in the list use null or else get value,
                    // then lookup and place a default value as defined in spec there
                    JToken subInput = inputList[keyInt];
                    if ((subInput != null && subInput.Type != JTokenType.Null) |
                        !originalSize.HasValue || keyInt < originalSize.Value)
                    {
                        subInputOptional = subInput;
                    }
                }
                kv.Value.Apply(kv.Key, subInputOptional, walkedPath, output, context);
            }
        }
        public override void ProcessList(IOrderedCompositeSpec spec, JArray inputList, WalkedPath walkedPath, JObject output, JObject context)
        {
            int?originalSize = walkedPath.LastElement().OrigSize;

            foreach (var kv in spec.GetLiteralChildren())
            {
                // If the data is an Array, but the spec keys are Non-Integer Strings,
                //  we are annoyed, but we don't stop the whole transform.
                // Just this part of the Transform won't work.
                if (Int32.TryParse(kv.Key, out int keyInt) &&
                    // Do not work if the index is outside of the input list
                    keyInt < inputList.Count)
                {
                    // XXX: does this make sense? can you have a literal null in JArray?
                    JToken subInput = inputList[keyInt];
                    JToken subInputOptional;
                    if (subInput == null && originalSize.HasValue && keyInt >= originalSize.Value)
                    {
                        subInputOptional = null;
                    }
                    else
                    {
                        subInputOptional = subInput;
                    }

                    kv.Value.Apply(kv.Key, subInputOptional, walkedPath, output, context);
                }
            }
        }
 public override void ProcessScalar(IOrderedCompositeSpec spec, string scalarInput, WalkedPath walkedPath, JObject output, JObject context)
 {
     if (spec.GetLiteralChildren().TryGetValue(scalarInput, out var literalChild))
     {
         literalChild.Apply(scalarInput, null, walkedPath, output, context);
     }
 }
 public override void ProcessMap(IOrderedCompositeSpec spec, JObject inputMap, WalkedPath walkedPath, JObject output, JObject context)
 {
     foreach (var kv in spec.GetLiteralChildren())
     {
         // if the input in not available in the map us null or else get value,
         // then lookup and place a defined value from spec there
         inputMap.TryGetValue(kv.Key, out var input);
         kv.Value.Apply(kv.Key, input, walkedPath, output, context);
     }
 }
 /**
  * The performance assumption built into this code is that the literal values in the spec, are generally smaller
  *  than the number of potential keys to check in the input.
  *
  *  More specifically, the assumption here is that the set of literalChildren is smaller than the input "keyset".
  */
 public override void ProcessMap(IOrderedCompositeSpec spec, JObject inputMap, WalkedPath walkedPath, JObject output, JObject context)
 {
     foreach (var kv in spec.GetLiteralChildren())
     {
         // Do not work if the value is missing in the input map
         if (inputMap.TryGetValue(kv.Key, out var inputValue))
         {
             kv.Value.Apply(kv.Key, inputValue, walkedPath, output, context);
         }
     }
 }