Esempio n. 1
0
        public bool TryResolve(ParsingEventBuffer buffer, out Type suggestedType)
        {
            if (buffer.TryFindMappingEntry(
                    scalar => typeLookup.ContainsKey(scalar.Value),
                    out Scalar key,
                    out ParsingEvent _))
            {
                suggestedType = typeLookup[key.Value];
                return(true);
            }

            buffer.Reset();
            if (buffer.TryFindMappingEntry(
                    scalar => fallback.Key == scalar.Value,
                    out Scalar _,
                    out ParsingEvent _))
            {
                suggestedType = fallback.Value;
                return(true);
            }

            suggestedType = null;
            return(false);
        }
Esempio n. 2
0
        public bool TryResolve(ParsingEventBuffer buffer, out Type suggestedType)
        {
            if (buffer.TryFindMappingEntry(
                    scalar => targetKey == scalar.Value,
                    out Scalar key,
                    out ParsingEvent value))
            {
                // read the value of the kind key
                if (value is Scalar valueScalar)
                {
                    suggestedType = CheckName(valueScalar.Value);

                    return(true);
                }
                else
                {
                    FailEmpty();
                }
            }

            // we could not find our key, thus we could not determine correct child type
            suggestedType = null;
            return(false);
        }