private IEnumerable <Pin> GetAttrPinsByDirection(PinDirection direction) { foreach (FieldInfo fi in GetType().GetFields(pinBinding)) { if (fi.FieldType == (typeof(Pin))) { PinAttribs pa = GetPinAttribs(fi); if (pa != null && pa.direction == direction) { yield return((Pin)fi.GetValue(this)); } } } }
protected void InitPins() { Debug.WriteLine("Initing pins for " + this.ToString()); foreach (FieldInfo fi in GetType().GetFields(pinBinding)) { if (fi.FieldType == typeof(Pin)) { PinAttribs attr = GetPinAttribs(fi); //Debug.WriteLine(" " + fi.Name + ": " + attr.ToString()); if (attr != null) { string name = attr.name; string desc = "???"; Pin p = Activator.CreateInstance(fi.FieldType, new object[] { name, desc, attr.dataType, attr.direction, this }) as Pin; fi.SetValue(this, p); p.SetConstantValue(GetPinDefaultConstantValue(p)); } } } }