Exemplo n.º 1
0
        private static void CompleteCompositeType(
            ICompleteValueContext context,
            IType type,
            object result)
        {
            ObjectType objectType =
                context.LocalContextData.Count != 0 &&
                context.LocalContextData.TryGetValue(
                    WellKnownContextData.Type,
                    out object o) &&
                o is NameString typeName
                ? context.ResolveObjectType(typeName)
                : context.ResolveObjectType(type, result);

            if (objectType == null)
            {
                context.AddError(b =>
                                 b.SetMessage(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  CoreResources.CompleteCompositeType_UnknownSchemaType,
                                                  result.GetType().GetTypeName(),
                                                  type.NamedType().Name.Value)));
                context.Value = null;
            }
            else
            {
                context.Value = context.EnqueueForProcessing(objectType, result);
            }
        }
Exemplo n.º 2
0
        private static void CompleteCompositeType(
            ICompleteValueContext context,
            IType type,
            object result)
        {
            ObjectType objectType = context.ResolveObjectType(type, result);

            if (objectType == null)
            {
                context.AddError(b =>
                                 b.SetMessage(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  CoreResources.CompleteCompositeType_UnknownSchemaType,
                                                  context.Value.GetType().GetTypeName())));
                context.Value = null;
            }
            else
            {
                var objectResult = new OrderedDictionary();
                context.Value = objectResult;
                context.EnqueueForProcessing(objectType, objectResult, result);
            }
        }