private static IObjectFieldDescriptor UseFiltering( IObjectFieldDescriptor descriptor, Type filterType) { FieldMiddleware placeholder = next => context => Task.CompletedTask; descriptor .Use(placeholder) .Extend() .OnBeforeCreate(definition => { Type argumentType = filterType; if (filterType == null) { if (!TypeInspector.Default.TryCreate( definition.ResultType, out TypeInfo typeInfo)) { // TODO : resources throw new ArgumentException( "Cannot handle the specified type.", nameof(descriptor)); } argumentType = typeof(FilterInputType <>).MakeGenericType( typeInfo.ClrType); } var argumentTypeReference = new ClrTypeReference( argumentType, TypeContext.Input); if (argumentType == typeof(object)) { // TODO : resources throw new SchemaException( SchemaErrorBuilder.New() .SetMessage( "The filter type cannot be " + "infered from `System.Object`.") .SetCode("FILTER_OBJECT_TYPE") .Build()); } var argumentDefinition = new ArgumentDefinition(); argumentDefinition.Name = _whereArgumentName; argumentDefinition.Type = new ClrTypeReference( argumentType, TypeContext.Input); definition.Arguments.Add(argumentDefinition); ILazyTypeConfiguration lazyConfiguration = LazyTypeConfigurationBuilder .New <ObjectFieldDefinition>() .Definition(definition) .Configure((context, defintion) => CompileMiddleware( context, definition, argumentTypeReference, placeholder)) .On(ApplyConfigurationOn.Completion) .DependsOn(argumentTypeReference, true) .Build(); definition.Configurations.Add(lazyConfiguration); }); return(descriptor); }
public Variable(ClrVariableName Name, ClrTypeReference typeref = null, CodeDocumentationSpec Documentation = null) : base(Name, Documentation, ClrAccessKind.Default, array <AttributionSpec>()) { this.VariableType = typeref; }
public ClrMemberReference(ClrTypeReference DeclaringType, ClrItemIdentifier MemberName) { this.DeclaringType = DeclaringType; this.MemberName = MemberName; }
public EnumSpec(ClrEnumName Name, ClrTypeReference UnderlyingType, params (string literalName, object literalValue)[] literals)
/// <summary> /// Defines a consructor invocation /// </summary> /// <param name="type">The type that defines the constructor</param> /// <param name="arguments">The arguments to supply upon invocation</param> /// <returns></returns> public static ConstructorInvocationSpec CreateObject(this ClrTypeReference type, params MethodArgumentValueSpec[] arguments) => new ConstructorInvocationSpec(type, arguments);
public ConstructorInvocationSpec(ClrTypeReference TypeReference, params MethodArgumentValueSpec[] Arguments) { this.TypeReference = TypeReference; this.Arguments = rolist(Arguments); }