示例#1
0
        protected void AddMemberPin(MemberInfo member)
        {
            if (!AllowMember(member))
            {
                return;
            }
            var oattr = MemberAttributeHandler <OutputAttribute>(member);

            Type memberType = typeof(object);

            switch (member)
            {
            case FieldInfo field:
                memberType = field.FieldType;
                break;

            case PropertyInfo prop:
                memberType = prop.PropertyType;
                break;
            }
            var enumerable    = false;
            var dictionary    = false;
            var allowEnumconv = AllowEnumBinsizing(member, memberType);

            GetEnumerableGenerics(member, memberType, out var potentialGenDictT, out var potentialGenEnumT);

            if (allowEnumconv && potentialGenDictT != null)
            {
                var stype = potentialGenDictT.GenericTypeArguments;
                oattr.Name          = member.Name + " Values";
                oattr.BinVisibility = oattr.Visibility == PinVisibility.OnlyInspector
                    ? PinVisibility.OnlyInspector
                    : PinVisibility.Hidden;

                var kattr = (OutputAttribute)oattr.Clone();
                kattr.Name          = member.Name + " Keys";
                kattr.BinVisibility = PinVisibility.OnlyInspector;
                Pd.AddOutput(TransformType(stype[0], member), kattr, binSized: true);
                Pd.AddOutput(TransformType(stype[1], member), oattr, binSized: true);
                dictionary = true;
            }
            else if (allowEnumconv && potentialGenEnumT != null)
            {
                var stype = potentialGenEnumT.GenericTypeArguments[0];
                oattr.BinVisibility = oattr.Visibility == PinVisibility.OnlyInspector
                    ? PinVisibility.OnlyInspector
                    : PinVisibility.Hidden;
                Pd.AddOutput(TransformType(stype, member), oattr, binSized: true);
                enumerable = true;
            }
            else
            {
                Pd.AddOutput(TransformType(memberType, member), oattr);
                enumerable = false;
            }
            AddMemberAttributePin(member);
            IsMemberEnumerable.Add(member, enumerable);
            IsMemberDictionary.Add(member, dictionary);
        }
示例#2
0
        private void AddMemberPin(PropertyInfo member)
        {
            if (!AllowMember(member))
            {
                return;
            }
            if (!member.CanWrite)
            {
                return;
            }

            var memberType = member.PropertyType;

            Properties.Add(member);

            var iattr = MemberAttributeHandler <InputAttribute>(member);

            var enumerable   = false;
            var dictionary   = false;
            var defaultValue = typeof(T).GetProperty(member.Name)?.GetValue(Default);

            var allowEnumconv = AllowEnumBinsizing(member, memberType);

            GetEnumerableGenerics(member, memberType, out var potentialGenDictT, out var potentialGenEnumT);

            if (allowEnumconv && potentialGenDictT != null)
            {
                var stype = potentialGenDictT.GenericTypeArguments;
                iattr.Name = member.Name + " Values";
                var kattr = (InputAttribute)iattr.Clone();
                kattr.Name = member.Name + " Keys";
                Pd.AddInput(TransformType(stype[0], member), kattr, binSized: true, obj: member);
                Pd.AddInput(TransformType(stype[1], member), iattr, binSized: true, obj: member);
                dictionary = true;
            }
            else if (allowEnumconv && potentialGenEnumT != null)
            {
                var stype = potentialGenEnumT.GenericTypeArguments[0];
                Pd.AddInput(TransformType(stype, member), iattr, binSized: true, obj: member);
                enumerable = true;
            }
            else
            {
                AddPinAndSetDefaultValue(member, iattr, defaultValue);
                enumerable = false;
            }
            IsMemberEnumerable.Add(member, enumerable);
            IsMemberDictionary.Add(member, dictionary);
        }