Ejemplo n.º 1
0
        public override void OnBeforeRegisterDependencies(
            ITypeDiscoveryContext discoveryContext,
            DefinitionBase?definition,
            IDictionary <string, object?> contextData)
        {
            if (definition is FilterInputTypeDefinition def)
            {
                IFilterConvention convention = GetConvention(
                    discoveryContext.DescriptorContext,
                    def.Scope);

                SchemaTypeReference typeReference = TypeReference.Create(
                    discoveryContext.Type,
                    def.Scope);

                var descriptor = FilterInputTypeDescriptor.New(
                    discoveryContext.DescriptorContext,
                    def.EntityType,
                    def.Scope);

                convention.ApplyConfigurations(typeReference, descriptor);

                FilterInputTypeDefinition extensionDefinition = descriptor.CreateDefinition();

                discoveryContext.RegisterDependencies(extensionDefinition);
            }
        }
 public QueryableSpatialWithinOperationHandlerBase(
     IFilterConvention convention,
     ITypeInspector inspector,
     InputParser inputParser)
     : base(convention, inspector, inputParser, _within)
 {
 }
Ejemplo n.º 3
0
 public ArrayFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConventions)
     : base(context, property, typeof(TArray), filterConventions)
 {
 }
 private SelectionMiddlewareContext(
     IFilterConvention fiterConvention,
     string sortingArgumentName)
 {
     FilterConvention    = fiterConvention;
     SortingArgumentName = sortingArgumentName;
 }
 public QueryableSpatialDistanceOperationHandler(
     IFilterConvention convention,
     ITypeInspector inspector,
     InputParser inputParser)
     : base(convention, inspector, inputParser, _distance)
 {
 }
 public ObjectFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConvention)
     : base(context, property, typeof(TObject), filterConvention)
 {
 }
Ejemplo n.º 7
0
        public override void OnBeforeCompleteName(
            ITypeCompletionContext completionContext,
            DefinitionBase?definition,
            IDictionary <string, object?> contextData)
        {
            if (definition is FilterInputTypeDefinition def)
            {
                IFilterConvention convention = GetConvention(
                    completionContext.DescriptorContext,
                    def.Scope);

                var descriptor = FilterInputTypeDescriptor.New(
                    completionContext.DescriptorContext,
                    def.EntityType,
                    def.Scope);

                SchemaTypeReference typeReference = TypeReference.Create(
                    completionContext.Type,
                    def.Scope);

                convention.ApplyConfigurations(typeReference, descriptor);

                DataTypeExtensionHelper.MergeFilterInputTypeDefinitions(
                    completionContext,
                    descriptor.CreateDefinition(),
                    def);

                if (def.Scope is not null)
                {
                    definition.Name = completionContext.Scope +
                                      "_" +
                                      definition.Name;
                }
            }
        }
 public ComparableFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConventions)
     : base(FilterKind.Comparable, context, property, filterConventions)
 {
 }
Ejemplo n.º 9
0
 public QueryableSpatialContainsOperationHandler(
     IFilterConvention convention,
     ITypeInspector inspector,
     InputParser inputParser)
     : base(convention, inspector, inputParser)
 {
 }
Ejemplo n.º 10
0
 void IFilterProviderConvention.Initialize(
     IConventionContext context,
     IFilterConvention convention)
 {
     _filterConvention = convention;
     base.Initialize(context);
 }
 public QueryableSpatialTouchesOperationHandlerBase(
     IFilterConvention convention,
     ITypeInspector inspector,
     InputParser inputParser)
     : base(convention, inspector, inputParser, _touches)
 {
 }
Ejemplo n.º 12
0
 public FilterFieldCollectionExtensionTest()
 {
     _property          = x => x.Bar;
     _propertyInfo      = (PropertyInfo)_property.ExtractMember();
     _descriptorContext = DescriptorContext.Create();
     _filterConvention  = new FilterConvention();
 }
 public QueryableSpatialOverlapsOperationHandlerBase(
     IFilterConvention convention,
     ITypeInspector inspector,
     InputParser inputParser)
     : base(convention, inspector, inputParser, _overlap)
 {
 }
Ejemplo n.º 14
0
 public BooleanFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConventions)
     : base(FilterKind.Boolean, context, property, filterConventions)
 {
 }
 public StringFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConventions)
     : base(FilterKind.String, context, property, filterConventions)
 {
 }
Ejemplo n.º 16
0
 public IgnoredFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     IFilterConvention filterConvention)
     : base(FilterKind.Ignored, context, property, filterConvention)
 {
     Definition.Ignore = true;
 }
 protected QueryableSpatialMethodHandler(
     IFilterConvention convention,
     ITypeInspector inspector,
     MethodInfo method)
 {
     _runtimeType      = inspector.GetReturnType(method);
     GeometryFieldName = convention.GetOperationName(SpatialFilterOperations.Geometry);
     BufferFieldName   = convention.GetOperationName(SpatialFilterOperations.Buffer);
 }
 /// <summary>
 /// Create a new string filter operation descriptor.
 /// </summary>
 /// <param name="context">
 /// The descriptor context.
 /// </param>
 /// <param name="descriptor">
 /// The field descriptor on which this
 /// filter operation shall be applied.
 /// </param>
 /// <param name="name">
 /// The default name of the filter operation field.
 /// </param>
 /// <param name="type">
 /// The field type of this filter operation field.
 /// </param>
 /// <param name="operation">
 /// The filter operation info.
 /// </param>
 /// <param name="filterConventions">
 /// The filter conventions
 /// </param>
 public static ObjectFilterOperationDescriptor <TObject> New(
     IDescriptorContext context,
     ObjectFilterFieldDescriptor <TObject> descriptor,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConventions) =>
 new ObjectFilterOperationDescriptor <TObject>(
     context, descriptor, name, type, operation, filterConventions);
 /// <summary>
 /// Create a new string filter operation descriptor.
 /// </summary>
 /// <param name="context">
 /// The descriptor context.
 /// </param>
 /// <param name="descriptor">
 /// The field descriptor on which this
 /// filter operation shall be applied.
 /// </param>
 /// <param name="name">
 /// The default name of the filter operation field.
 /// </param>
 /// <param name="type">
 /// The field type of this filter operation field.
 /// </param>
 /// <param name="operation">
 /// The filter operation info.
 /// </param>
 /// <param name="filterConventions">
 /// The filter conventions
 /// </param>
 public static ArrayFilterOperationDescriptor New(
     IDescriptorContext context,
     ArrayFilterFieldDescriptor descriptor,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConvention) =>
 new ArrayFilterOperationDescriptor(
     context, descriptor, name, type, operation, filterConvention);
 /// <summary>
 /// Create a new comparable filter operation descriptor.
 /// </summary>
 /// <param name="context">
 /// The descriptor context.
 /// </param>
 /// <param name="descriptor">
 /// The field descriptor on which this
 /// filter operation shall be applied.
 /// </param>
 /// <param name="name">
 /// The default name of the filter operation field.
 /// </param>
 /// <param name="type">
 /// The field type of this filter operation field.
 /// </param>
 /// <param name="operation">
 /// The filter operation info.
 /// </param>
 /// <param name="filterConventions">
 /// The filter conventions
 /// </param>
 public static ComparableFilterOperationDescriptor New(
     IDescriptorContext context,
     ComparableFilterFieldDescriptor descriptor,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConventions) =>
 new ComparableFilterOperationDescriptor(
     context, descriptor, name, type, operation, filterConventions);
Ejemplo n.º 21
0
 protected BooleanFilterOperationDescriptorBase(
     IDescriptorContext context,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConventions)
     : base(context, name, type, operation, filterConventions)
 {
 }
 public ArrayFilterFieldDescriptor(
     IDescriptorContext context,
     PropertyInfo property,
     Type type,
     IFilterConvention filtersConventions)
     : base(FilterKind.Array, context, property, filtersConventions)
 {
     _type = type;
 }
Ejemplo n.º 23
0
        public override void OnBeforeRegisterDependencies(
            ITypeDiscoveryContext discoveryContext,
            DefinitionBase?definition,
            IDictionary <string, object?> contextData)
        {
            if (definition is FilterInputTypeDefinition def)
            {
                IFilterConvention convention = GetConvention(
                    discoveryContext.DescriptorContext,
                    def.Scope);

                var descriptor = FilterInputTypeDescriptor.From(
                    discoveryContext.DescriptorContext,
                    def,
                    def.Scope);

                var typeReference = TypeReference.Create(
                    discoveryContext.Type,
                    def.Scope);

                convention.ApplyConfigurations(typeReference, descriptor);

                foreach (InputFieldDefinition field in def.Fields)
                {
                    if (field is FilterFieldDefinition filterFieldDefinition)
                    {
                        if (discoveryContext.TryPredictTypeKind(
                                filterFieldDefinition.Type,
                                out TypeKind kind) &&
                            kind != TypeKind.Scalar && kind != TypeKind.Enum)
                        {
                            field.Type = field.Type.With(scope: discoveryContext.Scope);
                        }

                        if (filterFieldDefinition.Handler is null)
                        {
                            if (convention.TryGetHandler(
                                    discoveryContext,
                                    def,
                                    filterFieldDefinition,
                                    out IFilterFieldHandler? handler))
                            {
                                filterFieldDefinition.Handler = handler;
                            }
                            else
                            {
                                throw ThrowHelper.FilterInterceptor_NoHandlerFoundForField(
                                          def,
                                          filterFieldDefinition);
                            }
                        }
                    }
                }
            }
        }
 protected ObjectFilterOperationDescriptor(
     IDescriptorContext context,
     ObjectFilterFieldDescriptor <TObject> descriptor,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConventions)
     : base(context, descriptor, name, type, operation, filterConventions)
 {
     _descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
 }
Ejemplo n.º 25
0
        public override void OnBeforeCompleteType(
            ITypeCompletionContext completionContext,
            DefinitionBase?definition,
            IDictionary <string, object?> contextData)
        {
            if (definition is FilterInputTypeDefinition def)
            {
                IFilterConvention convention = GetConvention(
                    completionContext.DescriptorContext,
                    def.Scope);

                foreach (InputFieldDefinition field in def.Fields)
                {
                    if (field is FilterFieldDefinition filterFieldDefinition)
                    {
                        if (filterFieldDefinition.Type is null)
                        {
                            throw ThrowHelper.FilterInterceptor_OperationHasNoTypeSpecified(
                                      def,
                                      filterFieldDefinition);
                        }

                        if (completionContext.TryPredictTypeKind(
                                filterFieldDefinition.Type,
                                out TypeKind kind) &&
                            kind != TypeKind.Scalar && kind != TypeKind.Enum)
                        {
                            field.Type = field.Type.With(scope: completionContext.Scope);
                        }

                        if (filterFieldDefinition.Handler is null)
                        {
                            if (convention.TryGetHandler(
                                    completionContext,
                                    def,
                                    filterFieldDefinition,
                                    out IFilterFieldHandler? handler))
                            {
                                filterFieldDefinition.Handler = handler;
                            }
                            else
                            {
                                throw ThrowHelper.FilterInterceptor_NoHandlerFoundForField(
                                          def,
                                          filterFieldDefinition);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
 protected FilterInputTypeDescriptor(
     IDescriptorContext context,
     Type entityType,
     IFilterConvention convention)
     : base(context)
 {
     _convention           = convention;
     Definition.EntityType = entityType ??
                             throw new ArgumentNullException(nameof(entityType));
     Definition.ClrType                = typeof(object);
     Definition.Name                   = _convention.GetTypeName(context, entityType);
     Definition.Description            = _convention.GetTypeDescription(context, entityType);
     Definition.Fields.BindingBehavior =
         context.Options.DefaultBindingBehavior;
 }
Ejemplo n.º 27
0
    protected FilterFieldDescriptor(
        IDescriptorContext context,
        string?scope,
        MemberInfo member)
        : base(context)
    {
        IFilterConvention convention = context.GetFilterConvention(scope);

        Definition.Member = member ??
                            throw new ArgumentNullException(nameof(member));

        Definition.Name        = convention.GetFieldName(member);
        Definition.Description = convention.GetFieldDescription(member);
        Definition.Type        = convention.GetFieldType(member);
        Definition.Scope       = scope;
    }
Ejemplo n.º 28
0
 protected FilterOperationDescriptorBase(
     IDescriptorContext context,
     NameString name,
     ITypeReference type,
     FilterOperation operation,
     IFilterConvention filterConventions)
     : base(context)
 {
     Definition.Name = name.EnsureNotEmpty(nameof(name));
     Definition.Type = type
                       ?? throw new ArgumentNullException(nameof(type));
     Definition.Operation = operation
                            ?? throw new ArgumentNullException(nameof(operation));
     Definition.Description =
         filterConventions.GetOperationDescription(operation);
 }
Ejemplo n.º 29
0
        private static void CompileMiddleware(
            ITypeCompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder,
            string?scope)
        {
            IFilterInputType  type       = context.GetType <IFilterInputType>(argumentTypeReference);
            IFilterConvention convention = context.DescriptorContext.GetFilterConvention(scope);

            MethodInfo factory    = _factoryTemplate.MakeGenericMethod(type.EntityType.Source);
            var        middleware = (FieldMiddleware)factory.Invoke(null, new object[] { convention }) !;
            var        index      = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }
Ejemplo n.º 30
0
        private static void CompileMiddleware(
            ICompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder)
        {
            IFilterConvention convention =
                context.DescriptorContext.GetFilterConvention();
            IFilterInputType type           = context.GetType <IFilterInputType>(argumentTypeReference);
            Type             middlewareType = _middlewareDefinition.MakeGenericType(type.EntityType);
            FieldMiddleware  middleware     =
                FieldClassMiddlewareFactory.Create(middlewareType,
                                                   FilterMiddlewareContext.Create(convention));
            var index = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }