Esempio n. 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);
        }
Esempio n. 2
0
        public void ConstructorGenericParameters()
        {
            var md = new Constructor(AccessModifier.Public, "Person");

            md.AddParameter("String", "name");
            md.AddParameter("Int32", "age");
            md.GenericParameters.Add("T1");
            md.GenericParameters.Add("T2");
            md.Body.Add(SourceCodeLanguage.CSharp, "this.Value = name + \":\" + age.ToString();");

            Assert.AreEqual("public Person<T1, T2>(String name, Int32 age)" + SourceCodeGenerator.NewLine
                            + "{" + SourceCodeGenerator.NewLine
                            + SourceCodeGenerator.Default.Indent + "this.Value = name + \":\" + age.ToString();" + SourceCodeGenerator.NewLine
                            + "}" + SourceCodeGenerator.NewLine, SourceCodeGenerator.Write(SourceCodeLanguage.CSharp, md));
        }
Esempio n. 3
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);
        }