public DiffSpreadPin AddInput(params InputAttribute[] attrs) { if (GroupType == null) { throw new TypeIsNullException(); } return(attrs.Select(attr => Pd.AddInput(GroupType, attr)).ToArray()[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); }
protected void AddPinAndSetDefaultValue(PropertyInfo member, InputAttribute iattr, object defaultValue) { var defVals = TransformDefaultToValues(defaultValue); iattr.Name = member.Name; iattr.DefaultValue = defVals[0]; iattr.DefaultValues = defVals; iattr.DefaultString = defaultValue?.ToString() ?? ""; iattr.DefaultNodeValue = defaultValue; if (defaultValue is bool b) { iattr.DefaultBoolean = b; } if (defaultValue is RGBAColor vcol) { iattr.DefaultColor = new[] { vcol.R, vcol.G, vcol.B, vcol.A } } ; if (defaultValue is Color4 s4Col) { iattr.DefaultColor = new double[] { s4Col.Red, s4Col.Green, s4Col.Blue, s4Col.Alpha } } ; if (defaultValue is Color3 s3Col) { iattr.DefaultColor = new double[] { s3Col.Red, s3Col.Green, s3Col.Blue, 1 } } ; Pd.AddInput(TransformType(member.PropertyType, member), iattr); var spread = Pd.InputPins[member.Name].Spread; spread.SliceCount = 1; spread[0] = TransformDefaultValue(defaultValue, member); } }