コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: ConstructorTest.cs プロジェクト: fengweijp/higlabo
        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));
        }
コード例 #3
0
ファイル: ConstructorTest.cs プロジェクト: fengweijp/higlabo
        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));
        }
コード例 #4
0
        public Constructor CreateDefaultConstructor()
        {
            var t = this.Table;
            Constructor ct = new Constructor(AccessModifier.Public, "Record");

            ct.Body.Add(SourceCodeLanguage.CSharp, "ConstructorExecuted();");
            return ct;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
 public override void Write(Constructor constructor)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public abstract void Write(Constructor constructor);
コード例 #8
0
        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;
        }
コード例 #9
0
 public override void Write(Constructor constructor)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 public abstract void Write(Constructor constructor);
コード例 #11
0
 public static String Write(SourceCodeLanguage language, Constructor constructor)
 {
     var sc = Create(language);
     sc.Write(constructor);
     return sc.TextWriter.ToString();
 }