コード例 #1
0
    /// <inheritdoc />
    public IFilterFieldDescriptor Field <TField>(Expression <Func <T, TField> > property)
    {
        if (property.ExtractMember() is PropertyInfo m)
        {
            FilterFieldDescriptor?fieldDescriptor =
                Fields.FirstOrDefault(t => t.Definition.Member == m);

            if (fieldDescriptor is null)
            {
                fieldDescriptor = FilterFieldDescriptor.New(Context, Definition.Scope, m);
                Fields.Add(fieldDescriptor);
            }

            return(fieldDescriptor);
        }

        throw new ArgumentException(
                  FilterInputTypeDescriptor_Field_OnlyProperties,
                  nameof(property));
    }
コード例 #2
0
    protected override void OnCompleteFields(
        IDictionary <NameString, FilterFieldDefinition> fields,
        ISet <MemberInfo> handledProperties)
    {
        if (Definition.Fields.IsImplicitBinding())
        {
            FieldDescriptorUtilities.AddImplicitFields(
                this,
                Definition.EntityType,
                p => FilterFieldDescriptor
                .New(Context, Definition.Scope, p)
                .CreateDefinition(),
                fields,
                handledProperties,
                include: (members, member) =>
                member is PropertyInfo && !handledProperties.Contains(member));
        }

        base.OnCompleteFields(fields, handledProperties);
    }