コード例 #1
0
 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));
             }
         }
     }
 }
コード例 #2
0
 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));
             }
         }
     }
 }