Esempio n. 1
0
    protected InterfaceTypeDescriptor(
        IDescriptorContext context,
        InterfaceTypeDefinition definition)
        : base(context)
    {
        Definition = definition ?? throw new ArgumentNullException(nameof(definition));

        foreach (InterfaceFieldDefinition field in definition.Fields)
        {
            Fields.Add(InterfaceFieldDescriptor.From(Context, field));
        }
    }
    public IInterfaceFieldDescriptor Field(
        Expression <Func <T, object> > propertyOrMethod)
    {
        if (propertyOrMethod is null)
        {
            throw new ArgumentNullException(nameof(propertyOrMethod));
        }

        MemberInfo member = propertyOrMethod.ExtractMember();

        if (member is PropertyInfo || member is MethodInfo)
        {
            InterfaceFieldDescriptor fieldDescriptor =
                Fields.FirstOrDefault(t => t.Definition.Member == member);
            if (fieldDescriptor is { })
    protected override void OnCompleteFields(
        IDictionary <NameString, InterfaceFieldDefinition> fields,
        ISet <MemberInfo> handledMembers)
    {
        if (Definition.Fields.IsImplicitBinding())
        {
            FieldDescriptorUtilities.AddImplicitFields(
                this,
                p => InterfaceFieldDescriptor
                .New(Context, p)
                .CreateDefinition(),
                fields,
                handledMembers);
        }

        base.OnCompleteFields(fields, handledMembers);
    }