Example #1
0
 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
 }
Example #2
0
        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");
        }
Example #3
0
 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
 }