public bool AddField(string name, CbType type) { if (Fields.ContainsKey(name)) { return(false); // error -- duplicate field name } Fields[name] = new CbField(name, type, this); return(true); // success }
public override void Print(TextWriter p) { p.Write("class {0}", Name); p.WriteLine(" {"); // output the fields foreach (CbMember cm in Members.Values) { CbField cf = cm as CbField; if (cf == null) { continue; } p.Write(" "); cf.Print(p); } // output the constructors (there should be at most one) foreach (CbMember cm in Members.Values) { CbConstructor cc = cm as CbConstructor; if (cc == null || cc is CFMethod) { continue; } p.Write(" "); cc.Print(p); } // output the methods foreach (CbMember cm in Members.Values) { CFMethod ct = cm as CFMethod; if (ct == null) { continue; } p.Write(" "); ct.Print(p); } p.WriteLine("}\n"); }
public bool AddField( string name, CbType type ) { if (Fields.ContainsKey(name)) return false; // error -- duplicate field name Fields[name] = new CbField(name, type, this); return true; // success }