protected override void Configure(
     IEnumTypeDescriptor <Foo> descriptor)
 {
     descriptor.BindValues(BindingBehavior.Explicit);
     descriptor.Value(Foo.Bar);
     descriptor.Value(Foo.Baz);
 }
Exemplo n.º 2
0
        protected override void Configure(IEnumTypeDescriptor <Episode> descriptor)
        {
            descriptor
            .Name("Episode")
            .Description("One of the films in the Star Wars Trilogy.");

            descriptor.Value(Episode.NEWHOPE).Description("Released in 1977.");
            descriptor.Value(Episode.EMPIRE).Description("Released in 1980.");
            descriptor.Value(Episode.JEDI).Description("Released in 1983.");
        }
 protected override void Configure(IEnumTypeDescriptor <EmulatorCompatibility> descriptor)
 {
     descriptor.Name("EmulatorCompatibility")
     .Description("Describes the levels of compatibility an emulator has with a given game.");
     descriptor.Value(EmulatorCompatibility.Unsupported)
     .Description("This game is not supported by this emulator.");
     descriptor.Value(EmulatorCompatibility.MissingSystemFiles)
     .Description("The system files required to run this game are not available.");
     descriptor.Value(EmulatorCompatibility.RequiresValidation)
     .Description("The game has the files required to be run, but they are not in the correct format. " +
                  "Validation should be run before launching this game.");
     descriptor.Value(EmulatorCompatibility.Ready)
     .Description("This game is supported and ready to be run, requiring no validation. ");
 }
Exemplo n.º 4
0
        protected override void Configure(
            IEnumTypeDescriptor <ExecuteResolver> descriptor)
        {
            descriptor
            .Name("ExecuteResolver")
            .BindValuesExplicitly();

            descriptor
            .Value(ExecuteResolver.AfterPolicy)
            .Name("AFTER_POLICY");

            descriptor
            .Value(ExecuteResolver.BeforePolicy)
            .Name("BEFORE_POLICY");
        }
Exemplo n.º 5
0
    protected override void Configure(
        IEnumTypeDescriptor <ApplyPolicy> descriptor)
    {
        descriptor
        .Name("ApplyPolicy")
        .BindValuesExplicitly();

        descriptor
        .Value(ApplyPolicy.BeforeResolver)
        .Name("BEFORE_RESOLVER");

        descriptor
        .Value(ApplyPolicy.AfterResolver)
        .Name("AFTER_RESOLVER");
    }
        private static void DeclareValues(
            IEnumTypeDescriptor typeDescriptor,
            IReadOnlyCollection <EnumValueDefinitionNode> values)
        {
            foreach (EnumValueDefinitionNode value in values)
            {
                IEnumValueDescriptor valueDescriptor =
                    typeDescriptor.Value(value.Name.Value)
                    .Description(value.Description?.Value);

                string deprecactionReason = value.DeprecationReason();
                if (!string.IsNullOrEmpty(deprecactionReason))
                {
                    valueDescriptor.Deprecated(deprecactionReason);
                }

                foreach (DirectiveNode directive in value.Directives)
                {
                    if (!directive.IsDeprecationReason())
                    {
                        valueDescriptor.Directive(directive);
                    }
                }
            }
        }
        public void SpecifyOneValueInferTheOthers()
        {
            // arrange
            var descriptor = EnumTypeDescriptor.New(Context, typeof(FooEnum));

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Value(FooEnum.Bar1).Name("FOOBAR");

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Values,
                              t =>
            {
                Assert.Equal("FOOBAR", t.Name);
                Assert.Equal(FooEnum.Bar1, t.RuntimeValue);
            },
                              t =>
            {
                Assert.Equal("BAR2", t.Name);
                Assert.Equal(FooEnum.Bar2, t.RuntimeValue);
            });
        }
Exemplo n.º 8
0
        protected override void Configure(IEnumTypeDescriptor <PathType> descriptor)
        {
            descriptor.Name("PathType")
            .Description("If the option is a PATH option, the type of path the option accepts as values.");

            descriptor.Value(PathType.Either)
            .Description("A contextual path that points to either a directory or a file.");
            descriptor.Value(PathType.File)
            .Description("A contextual path that points to a file.");
            descriptor.Value(PathType.Directory)
            .Description("A contextual path that points to a directory.");
            descriptor.Value(PathType.NotPath)
            .Description("Not a path.");
            descriptor.Value(PathType.Raw)
            .Description("A raw, operating-system dependent path on the realized filesystem.");
        }
Exemplo n.º 9
0
        private static void DeclareValues(
            IEnumTypeDescriptor typeDescriptor,
            IReadOnlyCollection <EnumValueDefinitionNode> values)
        {
            foreach (EnumValueDefinitionNode value in values)
            {
                IEnumValueDescriptor valueDescriptor =
                    typeDescriptor
                    .Value(value.Name.Value)
                    .Description(value.Description?.Value)
                    .Name(value.Name.Value);

                if (value.DeprecationReason() is { Length: > 0 } s)
                {
                    valueDescriptor.Deprecated(s);
                }

                foreach (DirectiveNode directive in value.Directives)
                {
                    if (!directive.IsDeprecationReason())
                    {
                        valueDescriptor.Directive(directive);
                    }
                }
            }
        }
Exemplo n.º 10
0
        protected override void Configure(IEnumTypeDescriptor <GeoJsonGeometryType> descriptor)
        {
            descriptor
            .Name(EnumTypeTypeName)
            .BindValuesExplicitly();

            descriptor
            .Value(Point)
            .Name(nameof(Point));

            descriptor
            .Value(MultiPoint)
            .Name(nameof(MultiPoint));

            descriptor
            .Value(LineString)
            .Name(nameof(LineString));

            descriptor
            .Value(MultiLineString)
            .Name(nameof(MultiLineString));

            descriptor
            .Value(Polygon)
            .Name(nameof(Polygon));

            descriptor
            .Value(MultiPolygon)
            .Name(nameof(MultiPolygon));

            descriptor
            .Value(GeometryCollection)
            .Name(nameof(GeometryCollection));
        }
Exemplo n.º 11
0
        protected override void Configure(IEnumTypeDescriptor <TypeKind> descriptor)
        {
            descriptor
            .Name(Names.__TypeKind)
            .Description(TypeResources.TypeKind_Description)
            // Introspection types must always be bound explicitly so that we
            // do not get any interference with conventions.
            .BindValues(BindingBehavior.Explicit);

            descriptor
            .Value(TypeKind.Scalar)
            .Name(Names.Scalar)
            .Description(TypeResources.TypeKind_Scalar);

            descriptor
            .Value(TypeKind.Object)
            .Name(Names.Object)
            .Description(TypeResources.TypeKind_Object);

            descriptor
            .Value(TypeKind.Interface)
            .Name(Names.Interface)
            .Description(TypeResources.TypeKind_Interface);

            descriptor
            .Value(TypeKind.Union)
            .Name(Names.Union)
            .Description(TypeResources.TypeKind_Union);

            descriptor
            .Value(TypeKind.Enum)
            .Name(Names.Enum)
            .Description(TypeResources.TypeKind_Enum);

            descriptor
            .Value(TypeKind.InputObject)
            .Name(Names.InputObject)
            .Description(TypeResources.TypeKind_InputObject);

            descriptor
            .Value(TypeKind.List)
            .Name(Names.List)
            .Description(TypeResources.TypeKind_List);

            descriptor
            .Value(TypeKind.NonNull)
            .Name(Names.NonNull)
            .Description(TypeResources.TypeKind_NonNull);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Ignores the given enum value for the schema creation.
        /// This enum will not be included into the GraphQL schema.
        /// </summary>
        /// <param name="descriptor">
        /// The enum type descriptor.
        /// </param>
        /// <param name="value">
        /// The enum value that shall be ignored.
        /// </param>
        /// <typeparam name="T">
        /// The enum value type.
        /// </typeparam>
        /// <returns>
        /// Returns the enum type descriptor for configuration chaining.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="descriptor"/> is <c>null</c> or
        /// <paramref name="value"/> is <c>null</c>.
        /// </exception>
        public static IEnumTypeDescriptor Ignore <T>(
            this IEnumTypeDescriptor descriptor,
            T value)
        {
            if (descriptor is null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            descriptor.Value(value).Ignore();
            return(descriptor);
        }
Exemplo n.º 13
0
        protected override void Configure(IEnumTypeDescriptor <GameEmulationState> descriptor)
        {
            descriptor.Name("GameEmulationState")
            .Description("Describes the state of a game emulation.");
            descriptor.Value(GameEmulationState.RequiresSetupEnvironment)
            .Description(
                @"This game emulation requires environment setup. The following mutations may occur.

* `setupEmulationEnvironment`
* `cleanupEmulation`
");
            descriptor.Value(GameEmulationState.RequiresCompileConfiguration)
            .Description(
                @"The game emulation requires configuration to be compiled. The following mutations may occur.

* `compileEmulationConfiguration`
* `cleanupEmulation`
");
            descriptor.Value(GameEmulationState.RequiresRestoreSaveGame)
            .Description(
                @"The game emulation requires the save game to be restored. The following mutations may occur.

* `restoreEmulationSave`
* `cleanupEmulation`
");
            descriptor.Value(GameEmulationState.CanStartEmulation)
            .Description(
                @"The game emulation can be started. The following mutations may occur.

* `persistEmulationSave`
* `startEmulation`
* `cleanupEmulation`
");
            descriptor.Value(GameEmulationState.CanStopEmulation)
            .Description(
                @"The game emulation is running, and can be stopped. The following mutations may occur.

* `persistEmulationSave`
* `stopEmulation`
* `cleanupEmulation` will immediately stop the emulation and cleanup.
");
            descriptor.Value(GameEmulationState.RequiresDispose)
            .Description(
                @"The game emulation has been stopped, and needs cleanup. The following mutations may occur.

* `persistEmulationSave`
* `cleanupEmulation`
");
        }
Exemplo n.º 14
0
        public void ExplicitValueBinding()
        {
            // arrange
            var descriptor = EnumTypeDescriptor.New(Context, typeof(FooEnum));

            // act
            IEnumTypeDescriptor desc = descriptor;

            desc.Value(FooEnum.Bar1).Name("FOOBAR");
            desc.BindValues(BindingBehavior.Explicit);

            // assert
            EnumTypeDefinition description = descriptor.CreateDefinition();

            Assert.Collection(description.Values,
                              t =>
            {
                Assert.Equal("FOOBAR", t.Name);
                Assert.Equal(FooEnum.Bar1, t.RuntimeValue);
            });
        }
Exemplo n.º 15
0
 protected override void Configure(IEnumTypeDescriptor <string> descriptor)
 {
     descriptor.Name("Some");
     descriptor.Value("ABC").Name("DEF");
 }
Exemplo n.º 16
0
 protected override void Configure(IEnumTypeDescriptor descriptor)
 {
     descriptor.Name("Foo");
     descriptor.Value(Foo.Bar).Ignore();
 }
Exemplo n.º 17
0
 protected override void Configure(IEnumTypeDescriptor descriptor)
 {
     descriptor.Name("Foo");
     descriptor.Value(Foo.Quox).Name("_QUOX");
 }
Exemplo n.º 18
0
 protected override void Configure(IEnumTypeDescriptor <Foo> descriptor)
 {
     descriptor.Value(Foo.Bar2).Ignore();
 }
Exemplo n.º 19
0
 protected override void Configure(IEnumTypeDescriptor <Episode> descriptor)
 {
     descriptor.Value(Episode.NewHope).Name("NEW_HOPE");
 }
Exemplo n.º 20
0
        protected override void Configure(IEnumTypeDescriptor <DirectiveLocation> descriptor)
        {
            descriptor
            .Name(Names.__DirectiveLocation)
            .Description(TypeResources.DirectiveLocation_Description)
            // Introspection types must always be bound explicitly so that we
            // do not get any interference with conventions.
            .BindValues(BindingBehavior.Explicit);

            descriptor
            .Value(DirectiveLocation.Query)
            .Name(Lang.Query.Value)
            .Description(TypeResources.DirectiveLocation_Query);

            descriptor
            .Value(DirectiveLocation.Mutation)
            .Name(Lang.Mutation.Value)
            .Description(TypeResources.DirectiveLocation_Mutation);

            descriptor
            .Value(DirectiveLocation.Subscription)
            .Name(Lang.Subscription.Value)
            .Description(TypeResources.DirectiveLocation_Subscription);

            descriptor
            .Value(DirectiveLocation.Field)
            .Name(Lang.Field.Value)
            .Description(TypeResources.DirectiveLocation_Field);

            descriptor
            .Value(DirectiveLocation.FragmentDefinition)
            .Name(Lang.FragmentDefinition.Value)
            .Description(TypeResources.DirectiveLocation_FragmentDefinition);

            descriptor
            .Value(DirectiveLocation.FragmentSpread)
            .Name(Lang.FragmentSpread.Value)
            .Description(TypeResources.DirectiveLocation_FragmentSpread);

            descriptor
            .Value(DirectiveLocation.InlineFragment)
            .Name(Lang.InlineFragment.Value)
            .Description(TypeResources.DirectiveLocation_InlineFragment);

            descriptor
            .Value(DirectiveLocation.VariableDefinition)
            .Name(Lang.VariableDefinition.Value)
            .Description("Location adjacent to a variable definition.");

            descriptor
            .Value(DirectiveLocation.Schema)
            .Name(Lang.Schema.Value)
            .Description(TypeResources.DirectiveLocation_Schema);

            descriptor
            .Value(DirectiveLocation.Scalar)
            .Name(Lang.Scalar.Value)
            .Description(TypeResources.DirectiveLocation_Scalar);

            descriptor
            .Value(DirectiveLocation.Object)
            .Name(Lang.Object.Value)
            .Description(TypeResources.DirectiveLocation_Object);

            descriptor
            .Value(DirectiveLocation.FieldDefinition)
            .Name(Lang.FieldDefinition.Value)
            .Description(TypeResources.DirectiveLocation_FieldDefinition);

            descriptor
            .Value(DirectiveLocation.ArgumentDefinition)
            .Name(Lang.ArgumentDefinition.Value)
            .Description(TypeResources.DirectiveLocation_ArgumentDefinition);

            descriptor
            .Value(DirectiveLocation.Interface)
            .Name(Lang.Interface.Value)
            .Description(TypeResources.DirectiveLocation_Interface);

            descriptor
            .Value(DirectiveLocation.Union)
            .Name(Lang.Union.Value)
            .Description(TypeResources.DirectiveLocation_Union);

            descriptor
            .Value(DirectiveLocation.Enum)
            .Name(Lang.Enum.Value)
            .Description(TypeResources.DirectiveLocation_Enum);

            descriptor
            .Value(DirectiveLocation.EnumValue)
            .Name(Lang.EnumValue.Value)
            .Description(TypeResources.DirectiveLocation_EnumValue);

            descriptor
            .Value(DirectiveLocation.InputObject)
            .Name(Lang.InputObject.Value)
            .Description(TypeResources.DirectiveLocation_InputObject);

            descriptor
            .Value(DirectiveLocation.InputFieldDefinition)
            .Name(Lang.InputFieldDefinition.Value)
            .Description(TypeResources.DirectiveLocation_InputFieldDefinition);
        }
Exemplo n.º 21
0
 protected override void Configure(IEnumTypeDescriptor <CodingSkillLevel> descriptor)
 {
     descriptor.Value(CodingSkillLevel.GettingThingsDone)
     .Name("GETTING_THINGS_DONE");
 }
Exemplo n.º 22
0
 protected override void Configure(IEnumTypeDescriptor descriptor)
 {
     descriptor.Value("RED");
     descriptor.Value("BLUE");
     descriptor.Value("GREEN");
 }
Exemplo n.º 23
0
 protected override void Configure(IEnumTypeDescriptor <SortOperationKind> descriptor)
 {
     base.Configure(descriptor);
     descriptor.Value(SortOperationKind.Asc);
     descriptor.Value(SortOperationKind.Desc);
 }