Exemplo n.º 1
0
        private static void RegisterInputObjectType(
            IDocumentAnalyzerContext context,
            InputObjectType inputObjectType)
        {
            RenameDirective?rename;
            var             fields = new List <InputFieldModel>();

            foreach (IInputField inputField in inputObjectType.Fields)
            {
                rename = inputField.Directives.SingleOrDefault <RenameDirective>();

                fields.Add(new InputFieldModel(
                               GetClassName(rename?.Name ?? inputField.Name),
                               inputField.Description,
                               inputField,
                               inputField.Type));

                context.RegisterType(inputField.Type.NamedType());
            }

            rename = inputObjectType.Directives.SingleOrDefault <RenameDirective>();

            NameString typeName = context.ResolveTypeName(
                GetClassName(rename?.Name ?? inputObjectType.Name));

            context.RegisterModel(
                typeName,
                new InputObjectTypeModel(
                    GetClassName(rename?.Name ?? inputObjectType.Name),
                    inputObjectType.Description,
                    inputObjectType,
                    fields));
        }
Exemplo n.º 2
0
        private static void CollectEnumTypes(
            IDocumentAnalyzerContext context)
        {
            var analyzer = new EnumTypeUsageAnalyzer(context.Schema);

            analyzer.Analyze(context.Document);

            foreach (EnumType enumType in analyzer.EnumTypes)
            {
                RenameDirective?rename;
                var             values = new List <EnumValueModel>();

                foreach (IEnumValue enumValue in enumType.Values)
                {
                    rename = enumValue.Directives.SingleOrDefault <RenameDirective>();

                    EnumValueDirective?value =
                        enumValue.Directives.SingleOrDefault <EnumValueDirective>();

                    values.Add(new EnumValueModel(
                                   rename?.Name ?? GetEnumValue(enumValue.Name),
                                   enumValue.Description,
                                   enumValue,
                                   value?.Value));
                }

                rename = enumType.Directives.SingleOrDefault <RenameDirective>();

                SerializationTypeDirective?serializationType =
                    enumType.Directives.SingleOrDefault <SerializationTypeDirective>();

                NameString typeName = context.ResolveTypeName(
                    rename?.Name ?? GetClassName(enumType.Name));

                context.RegisterModel(
                    typeName,
                    new EnumTypeModel(
                        typeName,
                        enumType.Description,
                        enumType,
                        serializationType?.Name,
                        values));
            }
        }
Exemplo n.º 3
0
        private static void CollectInputObjectTypes(
            IDocumentAnalyzerContext context)
        {
            var analyzer = new InputObjectTypeUsageAnalyzer(context.Schema);

            analyzer.Analyze(context.Document);

            foreach (InputObjectType inputObjectType in analyzer.InputObjectTypes)
            {
                RenameDirective?rename;
                var             fields = new List <InputFieldModel>();

                foreach (IInputField inputField in inputObjectType.Fields)
                {
                    rename = inputField.Directives.SingleOrDefault <RenameDirective>();

                    fields.Add(new InputFieldModel(
                                   GetClassName(rename?.Name ?? inputField.Name),
                                   inputField.Description,
                                   inputField,
                                   inputField.Type));
                }

                rename = inputObjectType.Directives.SingleOrDefault <RenameDirective>();

                NameString typeName = context.ResolveTypeName(
                    GetClassName(rename?.Name ?? inputObjectType.Name));

                context.RegisterModel(
                    typeName,
                    new InputObjectTypeModel(
                        GetClassName(rename?.Name ?? inputObjectType.Name),
                        inputObjectType.Description,
                        inputObjectType,
                        fields));
            }
        }