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); }
public void OnImportsSatisfied() { Pd = new PinDictionary(FIOFactory); foreach (var pin in FPluginHost.GetPins()) { if (pin.Name != "Descriptive Name") { continue; } pin.SetSlice(0, ""); break; } _pg = new ConfigurableTypePinGroup(FPluginHost, FIOFactory, Hde.MainLoop, "Input", 100); _pg.OnTypeChangeEnd += (sender, args) => { _typeChanged = true; foreach (var pin in FPluginHost.GetPins()) { if (pin.Name != "Descriptive Name") { continue; } pin.SetSlice(0, ""); break; } Pd.RemoveAllInput(); IsMemberEnumerable.Clear(); foreach (var pin in FPluginHost.GetPins()) { if (pin.Name != "Descriptive Name") { continue; } pin.SetSlice(0, _pg.GroupType.GetCSharpName()); break; } foreach (var field in _pg.GroupType.GetFields()) { AddMemberPin(field); } foreach (var prop in _pg.GroupType.GetProperties()) { AddMemberPin(prop); } if (_pgready) { return; } _pgready = true; _input = _pg.AddInput(new InputAttribute("Input")); }; }
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); }