public void ResolvePeers() { BindingFlags binding = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; // base type foreach (Peer peer in Peers) { if (peer.IsOpaque || peer.IsValueType || peer.CLRType.BaseType == null) { continue; } peer.NearestBase = GetPeer(peer.CLRType.BaseType); if (peer.NearestBase == null) { Console.Error.WriteLine("Error: cannot find an internal base type for {0}.", peer.Name); Environment.Exit(-1); } } // fields foreach (Peer peer in Peers) { if (peer.IsOpaque || peer.IsEnum) { continue; } Type clr_base = null; if (peer.NearestBase != null) { clr_base = peer.NearestBase.CLRType; } Stack declared = new Stack(); Type type = peer.CLRType; while (type != clr_base) { declared.Push(type); type = type.BaseType; } // build declared field list while (declared.Count > 0) { type = (Type)declared.Pop(); foreach (FieldInfo info in type.GetFields(binding)) { PeerField field = new PeerField( GetPeer(info.FieldType), info.Name ); peer.Fields.Add(field); } } } // enums foreach (Peer peer in Peers) { if (peer.IsOpaque || !peer.IsEnum) { continue; } Type clr_type = peer.CLRType; // constants Hashtable constants = new Hashtable(); foreach (string name in Enum.GetNames(clr_type)) { constants.Add(name, (int)Enum.Parse(clr_type, name)); } peer.UnderlyingPeer = GetPeer(Enum.GetUnderlyingType(clr_type)); peer.EnumConstants = constants; } }
public void ResolvePeers () { BindingFlags binding = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; // base type foreach (Peer peer in Peers) { if (peer.IsOpaque || peer.IsValueType || peer.CLRType.BaseType == null) continue; peer.NearestBase = GetPeer (peer.CLRType.BaseType); if (peer.NearestBase == null) { Console.Error.WriteLine ("Error: cannot find an internal base type for {0}.", peer.Name); Environment.Exit (-1); } } // fields foreach (Peer peer in Peers) { if (peer.IsOpaque || peer.IsEnum) continue; Type clr_base = null; if (peer.NearestBase != null) clr_base = peer.NearestBase.CLRType; Stack declared = new Stack (); Type type = peer.CLRType; while (type != clr_base) { declared.Push (type); type = type.BaseType; } // build declared field list while (declared.Count > 0) { type = (Type)declared.Pop (); foreach (FieldInfo info in type.GetFields (binding)) { PeerField field = new PeerField ( GetPeer (info.FieldType), info.Name ); peer.Fields.Add (field); } } } // enums foreach (Peer peer in Peers) { if (peer.IsOpaque || !peer.IsEnum) continue; Type clr_type = peer.CLRType; // constants Hashtable constants = new Hashtable (); foreach (string name in Enum.GetNames (clr_type)) constants.Add (name, (int)Enum.Parse (clr_type, name)); peer.UnderlyingPeer = GetPeer (Enum.GetUnderlyingType (clr_type)); peer.EnumConstants = constants; } }
public void Add(PeerField f) { List.Add(f); }
public void Add (PeerField f) { List.Add (f); }