コード例 #1
0
ファイル: DpoClass.cs プロジェクト: fjiang2/sqlcon
        private string FillAndCollect()
        {
            Method fill = new Method("FillObject")
            {
                Modifier = Modifier.Public | Modifier.Override,
                Params   = new Parameters().Add <DataRow>("row")
            };

            Method collect = new Method("UpdateRow")
            {
                Modifier = Modifier.Public | Modifier.Override,
                Params   = new Parameters().Add <DataRow>("row")
            };

            foreach (IColumn column in metaTable.Columns)
            {
                var    fieldDef  = dict_column_field[column.ColumnName];
                string fieldName = fieldDef.PropertyName;
                fill.Statement.AppendFormat("this.{0} = GetField<{1}>(row, _{0});", fieldName, fieldDef.Type);
                collect.Statement.AppendFormat("SetField(row, _{0}, this.{0});", fieldName);
            }

            clss.Add(fill);
            clss.Add(collect);

            CodeBlock block = new CodeBlock();

            block.Add(fill);
            block.AppendLine();
            block.Add(collect);
            return(block.ToString(2));
        }
コード例 #2
0
        public void TestCodeBlockCanBeBuiltByLine()
        {
            var code = new CodeBlock();

            code.AppendLine(@"m-config.      symbol         operations     final m-config.");
            code.AppendLine();
            code.AppendLine(@"             /  None              P0                b");
            code.AppendLine(@"   b        <    0             R, R, P1             b");
            code.AppendLine(@"             \   1             R, R, P0             b");

            code.AssertOutputEquals(
                "    m-config.      symbol         operations     final m-config." + Environment.NewLine +
                "    " + Environment.NewLine +
                "                 /  None              P0                b" + Environment.NewLine +
                "       b        <    0             R, R, P1             b" + Environment.NewLine +
                "                 \\   1             R, R, P0             b" + Environment.NewLine
                ,
                "<pre><code>m-config.      symbol         operations     final m-config.\n" +
                "\n" +
                "             /  None              P0                b\n" +
                "   b        &lt;    0             R, R, P1             b\n" +
                "             \\   1             R, R, P0             b\n" +
                "</code></pre>\n\n");
        }