public Constructor CreateResultSetConstructor() { Constructor ct = new Constructor(AccessModifier.Public, this.ResultSet.Name); if (String.IsNullOrEmpty(this.ResultSet.TableName) == false) { if (this.StoredProcedureType == StoredProcedureType.SelectAll || this.StoredProcedureType == StoredProcedureType.SelectByPrimaryKey) { ct.AddParameter(this.ResultSet.TableName + ".IRecord", "resultSet"); } else { ct.AddParameter(this.ResultSet.Name, "resultSet"); } } else { ct.AddParameter(this.ResultSet.Name, "resultSet"); } ct.Body.Add(SourceCodeLanguage.CSharp, "var r = resultSet;"); foreach (var parameter in this.ResultSet.Columns) { ct.Body.Add(SourceCodeLanguage.CSharp, String.Format("{0} = r.{0};", parameter.Name)); } return ct; }
public void ConstructorBasicFeature() { var md = new Constructor(AccessModifier.Public, "BigNumber"); md.Body.Add(SourceCodeLanguage.CSharp, "this.Value = 123;"); Assert.AreEqual("public BigNumber()" + SourceCodeGenerator.NewLine + "{" + SourceCodeGenerator.NewLine + SourceCodeGenerator.Default.Indent + "this.Value = 123;" + SourceCodeGenerator.NewLine + "}" + SourceCodeGenerator.NewLine, SourceCodeGenerator.Write(SourceCodeLanguage.CSharp, md)); }
public void ConstructorParameters() { var md = new Constructor(AccessModifier.Public, "Person"); md.Parameters.Add(new MethodParameter("String", "name")); md.Parameters.Add(new MethodParameter("Int32", "age")); md.Body.Add(SourceCodeLanguage.CSharp, "this.DisplayName = name + \":\" + age.ToString();"); Assert.AreEqual("public Person(String name, Int32 age)" + SourceCodeGenerator.NewLine + "{" + SourceCodeGenerator.NewLine + SourceCodeGenerator.Default.Indent + "this.DisplayName = name + \":\" + age.ToString();" + SourceCodeGenerator.NewLine + "}" + SourceCodeGenerator.NewLine, SourceCodeGenerator.Write(SourceCodeLanguage.CSharp, md)); }
public Constructor CreateDefaultConstructor() { var t = this.Table; Constructor ct = new Constructor(AccessModifier.Public, "Record"); ct.Body.Add(SourceCodeLanguage.CSharp, "ConstructorExecuted();"); return ct; }
public Constructor CreateConstructor() { var t = this.Table; Constructor ct = new Constructor(AccessModifier.Public, "Record"); ct.Parameters.Add(new MethodParameter("IRecord", "record")); ct.Body.Add(SourceCodeLanguage.CSharp, "this.SetProperty(record);"); ct.Body.Add(SourceCodeLanguage.CSharp, "ConstructorExecuted();"); return ct; }
public override void Write(Constructor constructor) { throw new NotImplementedException(); }
public abstract void Write(Constructor constructor);
public Constructor CreateResultSetConstructorWithStoredProcedure() { Constructor ct = new Constructor(AccessModifier.Internal, this.ResultSet.Name); ct.AddParameter(this.StoredProcedureName, "storedProcedure"); ct.Body.Add(SourceCodeLanguage.CSharp, "this._StoredProcedureResultSet_StoredProcedure = storedProcedure;"); return ct; }
public static String Write(SourceCodeLanguage language, Constructor constructor) { var sc = Create(language); sc.Write(constructor); return sc.TextWriter.ToString(); }