public FieldDeclaration AddField(string name) { FieldDeclaration fd = new FieldDeclaration( Conformer.ToCapitalized(name), this, new TypeTypeDeclaration(typeof(int)) ); fd.Attributes = MemberAttributes.Public; this.fields.Add(fd); return(fd); }
public PropertyDeclaration AddProperty( FieldDeclaration f, bool hasGet, bool hasSet, bool checkNonNull ) { var p = AddProperty( f.Type, Conformer.ToCapitalized(f.Name)); if (hasGet) { p.Get.Return(Expr.This.Field(f)); } if (hasSet) { if (checkNonNull) { var ifnull = Stm.If(Expr.Value.Identity(Expr.Null)); p.Set.Add(ifnull); ifnull.TrueStatements.Add( Stm.Throw(typeof(ArgumentNullException)) ); p.SetExceptions.Add(new ThrowedExceptionDeclaration( typeof(ArgumentNullException), "value is a null reference" )); } p.Set.Add( Stm.Assign( Expr.This.Field(f), Expr.Value ) ); } return(p); }