Exemplo n.º 1
0
            internal static bool TryCreateItemValue <ItemT>(
                PType <ItemT> itemType,
                string json,
                GreenJsonListSyntax jsonListSyntax,
                int itemIndex,
                int listSyntaxStartPosition,
                List <JsonErrorInfo> errors,
                out ItemT convertedTargetValue,
                out PValue value)
            {
                GreenJsonValueSyntax itemNode = jsonListSyntax.ListItemNodes[itemIndex].ValueNode.ContentNode;

                int itemNodeStart = listSyntaxStartPosition
                                    + jsonListSyntax.GetElementNodeStart(itemIndex)
                                    + jsonListSyntax.ListItemNodes[itemIndex].ValueNode.BackgroundBefore.Length;

                var itemValueOrError = itemType.TryCreateValue(
                    json,
                    itemNode,
                    out convertedTargetValue,
                    itemNodeStart,
                    errors);

                if (itemValueOrError.IsOption2(out value))
                {
                    return(true);
                }

                // Report type error at this index.
                itemValueOrError.IsOption1(out ITypeErrorBuilder itemTypeError);
                errors.Add(ValueTypeErrorAtItemIndex.Create(itemTypeError, itemIndex, itemNode, json, itemNodeStart));
                return(false);
            }
Exemplo n.º 2
0
            internal static bool TryCreateTupleValue <ItemT>(
                PType <ItemT> itemType,
                string json,
                GreenJsonListSyntax jsonListSyntax,
                int itemIndex,
                int errorReportingOffset,
                List <JsonErrorInfo> errors,
                out ItemT convertedTargetValue,
                out PValue value)
            {
                if (itemIndex < jsonListSyntax.FilteredListItemNodeCount)
                {
                    return(TryCreateItemValue(
                               itemType,
                               json,
                               jsonListSyntax,
                               itemIndex,
                               errorReportingOffset,
                               errors,
                               out convertedTargetValue,
                               out value));
                }

                convertedTargetValue = default;
                value = default;
                return(false);
            }
Exemplo n.º 3
0
 internal abstract Union <ITypeErrorBuilder, PList> TryCreateFromList(
     string json,
     GreenJsonListSyntax jsonListSyntax,
     out T convertedValue,
     int listSyntaxStartPosition,
     List <JsonErrorInfo> errors);