JavaScriptTemplate.cs 31.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
// ------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行时版本: 17.0.0.0
//  
//     对此文件的更改可能导致不正确的行为,如果
//     重新生成代码,这些更改将会丢失。
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Hh.Mes.T4
{
    using System.Linq;
    using System;
    
    /// <summary>
    /// Class to produce the template output
    /// </summary>
    
    #line 1 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
    public partial class JavaScriptTemplate : JavaScriptTemplateBase
    {
#line hidden
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write(@"let action = null;
layui.config({
    base: ""/js/"",
    version: 1
}).use(['system'], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendDataWhere = null,
        sendDataDescWhere = null,
        areaName = """);
            
            #line 15 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(AreaName));
            
            #line default
            #line hidden
            this.Write("\",\r\n        controllerName = \"");
            
            #line 16 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ControllerName));
            
            #line default
            #line hidden
            this.Write("\",\r\n        app = null;\r\n\r\n    action = {\r\n        addOptions");
            
            #line 20 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function () {\r\n            var options = {\r\n                fromId: \"#modifyFor" +
                    "m");
            
            #line 22 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(" form\",\r\n                url: `/${areaName}/${controllerName}/Ins");
            
            #line 23 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("`,\r\n                //sendDataWhere: null,\r\n                //isAddWhereExtend: \"" +
                    "arbitrarily\",\r\n                //mainTable: app.data.tableIns,\r\n                " +
                    "submit: \"submit(fromAdd");
            
            #line 27 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(")\"\r\n            }\r\n            return options;\r\n        },\r\n\r\n        editOptions" +
                    "");
            
            #line 32 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function () {\r\n            var options = {\r\n                fromId: \"#modifyFor" +
                    "m");
            
            #line 34 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(" form\",\r\n                url: `/${areaName}/${controllerName}/Upd");
            
            #line 35 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("`,\r\n                submit: \"submit(fromUpdate");
            
            #line 36 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(")\"\r\n            }\r\n            return options;\r\n        },\r\n\r\n        deleteOptio" +
                    "ns");
            
            #line 41 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function () {\r\n            var options = {\r\n                url: `/${areaName}/" +
                    "${controllerName}/DelByIds");
            
            #line 43 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("`,\r\n                keyId: \"id\"\r\n            }\r\n            return options;\r\n    " +
                    "    },\r\n\r\n        exportOptions: function () {\r\n            var options = {\r\n   " +
                    "             fromId: \"listForm");
            
            #line 51 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(@""",
                url: `/${areaName}/${controllerName}/Export`,
                isDefault: false,
                sendDataWhere:{},
                excelCols: {
                    head: app.data.cols,
                    body: app.data.colsDesc
                }
            }
            return options;
        },

        queryOptions");
            
            #line 63 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function () {\r\n            var options = {\r\n                resetFrom: \"form[la" +
                    "y-filter=listForm");
            
            #line 65 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("]\",\r\n                fromId: \"listForm");
            
            #line 66 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("\",\r\n                urlExport: `/${areaName}/${controllerName}/Export`,\r\n        " +
                    "        urlQuery: `/${areaName}/${controllerName}/Load");
            
            #line 68 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("`,\r\n                sendDataWhere:{},\r\n                mainTable: app.data.tableI" +
                    "ns");
            
            #line 70 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(@"
            }
            return options;
        },
        /*rowClickOptions: function () {
            var options = {
                //是否主子表
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: ""tableTabBody"",
                tabId: 2,
                customFn: app.methods.initTableDesc
            }
            return options;
        },*/

        uploadOptions: function () {
            var options = {
                url: `/${areaName}/${controllerName}/Import`,
                fromFile: ""#excelfile"",
                content: $(""#ImportData"")
            }
            return options;
        },
        addBefore");
            
            #line 94 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function (callBack) {\r\n            //callBack是回调函数,如果editBefore有ajax 放在成功之后\r\n  " +
                    "          if (callBack != null) callBack();\r\n        },\r\n\r\n        addSaveBefore" +
                    "");
            
            #line 99 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function (data, callBack) {\r\n            if (callBack != null) callBack();\r\n   " +
                    "     },\r\n        editBefore");
            
            #line 102 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function (data, callBack) {\r\n            //data.enable = data.enable.toString()" +
                    ";\r\n            form.val(\"modifyForm\", data);\r\n            if (callBack != null) " +
                    "callBack();\r\n        },\r\n        editSaveBefore");
            
            #line 107 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(@": function (data, callBack) {
            if (callBack != null) callBack();
        },

        checkboxMethod: function (obj) {
            var page = """".GetUrlParam(""page""),
                xxx = """".GetUrlParam(""xxx"");
            if (page == ""xxx"") {
                var sendData = {
                    
                };
                var ajaxConfig = {
                    data: sendData,
                    url: `${areaName}/${controllerName}/xxx`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        layer.msg(result.Message);
                    }
                };
                sysU.ajax(ajaxConfig);
            }
        },
        //所有动作成功之后
        actionSuccess: (flag) => {
           var data  = null;
           if (flag.includes(""Desc"")) {
               data = sendDataDescWhere;
           }
           sysU.refreshTable(app, sysU, data, flag);
        },
        closeAfter: function (callBack) {
            if (callBack != null) callBack();
        }
    }

    app = {
        data: {
            cols");
            
            #line 144 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": [[\r\n                { checkbox: true, fixed: true },\r\n");
            
            #line 146 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 if(Data.Any(x => x.Key.Equals("id", StringComparison.OrdinalIgnoreCase))) 
            
            #line default
            #line hidden
            
            #line 147 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 { 
            
            #line default
            #line hidden
            this.Write("                { field: \"id\", width: 80, hide: true, title: \"Id\" },\r\n");
            
            #line 149 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 } 
            
            #line default
            #line hidden
            
            #line 150 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 if(Data.Any(x => x.Key.Equals("keys", StringComparison.OrdinalIgnoreCase))) 
            
            #line default
            #line hidden
            
            #line 151 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 { 
            
            #line default
            #line hidden
            this.Write("                { field: \"keys\", width: 80, hide: true, title: \"Keys\" },\r\n");
            
            #line 153 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 } 
            
            #line default
            #line hidden
            
            #line 154 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 foreach(var item in Data) 
            
            #line default
            #line hidden
            
            #line 155 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 { 
            
            #line default
            #line hidden
            
            #line 156 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 if (item.Key.Equals("Id", StringComparison.OrdinalIgnoreCase) || item.Key.Equals("Keys", StringComparison.OrdinalIgnoreCase)) 
            
            #line default
            #line hidden
            
            #line 157 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 { continue; } 
            
            #line default
            #line hidden
            
            #line 158 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 if(!string.IsNullOrWhiteSpace(item.Value)) 
            
            #line default
            #line hidden
            
            #line 159 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 { 
            
            #line default
            #line hidden
            this.Write("                { field: \"");
            
            #line 160 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(item.Key));
            
            #line default
            #line hidden
            this.Write("\", width: 150, title: \"");
            
            #line 160 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(item.Value));
            
            #line default
            #line hidden
            this.Write("\" },\r\n");
            
            #line 161 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 }else{ 
            
            #line default
            #line hidden
            this.Write("                { field: \"");
            
            #line 162 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(item.Key));
            
            #line default
            #line hidden
            this.Write("\", width: 150, title: \"");
            
            #line 162 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(item.Key));
            
            #line default
            #line hidden
            this.Write("\" },\r\n");
            
            #line 163 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 } 
            
            #line default
            #line hidden
            
            #line 164 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
 } 
            
            #line default
            #line hidden
            this.Write(@"            ]],
            colsDesc:null,
            tableIns: null,
            tableElem: ""mainList"",
            tableInsDesc: null,
            tableElemDesc: ""mainListDesc"",

            //下拉框配置
            selectOption: {
                //station: {
                //    SelType: ""FromUrl"",
                //    SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
                //    SelLabel: ""workStationName"",
                //    SelValue: ""workStationCode"",
                //    OptGroup: true,
                //    Dom: [$(""[name='stationCode']"")]
                //},
                //返回的数据 用于后续操作
                selectData: {

                }
            },
            //下拉框配置枚举
            selectOptionEnum: {
                 type: {
                    SelValue: ""value"",     //key or value
                    SelFrom: ""dataSource"", //固定
                    Dom: [$(""select[name='xxx']"")],
                    dataSource: window.top.Enumxxx,
                },
                //返回的数据 用于后续操作
                selectData: {

                }
            },
        },
        methods: {
            initTable");
            
            #line 202 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(": function (opt) {\r\n                var config = {};\r\n                if (opt != " +
                    "undefined) $.extend(config, opt);\r\n                let options = {\r\n            " +
                    "        elem: \"#\" + app.data.tableElem");
            
            #line 206 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(",\r\n                    url: `/${areaName}/${controllerName}/Load");
            
            #line 207 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("`,\r\n                    cols: sysU.columnRecord(app.data.tableElem");
            
            #line 208 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(", app.data.cols");
            
            #line 208 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write(@"),
                    toolbar: '#toolbarTable',
                    where: config, 
                    //height: ""full-50"",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
                    doneExtend: function (res, obj) {
                    
                    }
                }
                app.data.tableIns = sysU.initTable(options);
            },

            initSelectTable: function () {
              var opt1 = {
                    elem: "".productCode"",
                    checkedKey: ""productCode"",
                    doneKey: {
                        key: ""productCode"",
                        lableValue: ""productName""
                    },
                    searchKey: ""productCode"",
                    searchName: ""产品编码""
                };
               sysU.initSelectProduct(opt1);
            },

            initFrom() {
                //sysU.initSelect(app.data.selectOption);

                //sysU.tabClick(""tableTabBody"");
                //sysU.initSelecteByEnum(app.data.selectOptionEnum);
            }
        },
        registerEvent: function () {

        },
        init: function () {
            //var sendDataWhere = form.val(""listForm");
            
            #line 244 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("\")\r\n            app.methods.initTable");
            
            #line 245 "E:\project\mes\IOT\Hh.Mes.T4\JavaScriptTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(IsDetail ? "Desc" : ""));
            
            #line default
            #line hidden
            this.Write("();\r\n            app.methods.initFrom();\r\n            app.registerEvent();\r\n     " +
                    "   }\r\n    };\r\n    app.init();\r\n});");
            return this.GenerationEnvironment.ToString();
        }
    }
    
    #line default
    #line hidden
    #region Base class
    /// <summary>
    /// Base class for this transformation
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
    public class JavaScriptTemplateBase
    {
        #region Fields
        private global::System.Text.StringBuilder generationEnvironmentField;
        private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
        private global::System.Collections.Generic.List<int> indentLengthsField;
        private string currentIndentField = "";
        private bool endsWithNewline;
        private global::System.Collections.Generic.IDictionary<string, object> sessionField;
        #endregion
        #region Properties
        /// <summary>
        /// The string builder that generation-time code is using to assemble generated output
        /// </summary>
        protected System.Text.StringBuilder GenerationEnvironment
        {
            get
            {
                if ((this.generationEnvironmentField == null))
                {
                    this.generationEnvironmentField = new global::System.Text.StringBuilder();
                }
                return this.generationEnvironmentField;
            }
            set
            {
                this.generationEnvironmentField = value;
            }
        }
        /// <summary>
        /// The error collection for the generation process
        /// </summary>
        public System.CodeDom.Compiler.CompilerErrorCollection Errors
        {
            get
            {
                if ((this.errorsField == null))
                {
                    this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
                }
                return this.errorsField;
            }
        }
        /// <summary>
        /// A list of the lengths of each indent that was added with PushIndent
        /// </summary>
        private System.Collections.Generic.List<int> indentLengths
        {
            get
            {
                if ((this.indentLengthsField == null))
                {
                    this.indentLengthsField = new global::System.Collections.Generic.List<int>();
                }
                return this.indentLengthsField;
            }
        }
        /// <summary>
        /// Gets the current indent we use when adding lines to the output
        /// </summary>
        public string CurrentIndent
        {
            get
            {
                return this.currentIndentField;
            }
        }
        /// <summary>
        /// Current transformation session
        /// </summary>
        public virtual global::System.Collections.Generic.IDictionary<string, object> Session
        {
            get
            {
                return this.sessionField;
            }
            set
            {
                this.sessionField = value;
            }
        }
        #endregion
        #region Transform-time helpers
        /// <summary>
        /// Write text directly into the generated output
        /// </summary>
        public void Write(string textToAppend)
        {
            if (string.IsNullOrEmpty(textToAppend))
            {
                return;
            }
            // If we're starting off, or if the previous text ended with a newline,
            // we have to append the current indent first.
            if (((this.GenerationEnvironment.Length == 0) 
                        || this.endsWithNewline))
            {
                this.GenerationEnvironment.Append(this.currentIndentField);
                this.endsWithNewline = false;
            }
            // Check if the current text ends with a newline
            if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
            {
                this.endsWithNewline = true;
            }
            // This is an optimization. If the current indent is "", then we don't have to do any
            // of the more complex stuff further down.
            if ((this.currentIndentField.Length == 0))
            {
                this.GenerationEnvironment.Append(textToAppend);
                return;
            }
            // Everywhere there is a newline in the text, add an indent after it
            textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
            // If the text ends with a newline, then we should strip off the indent added at the very end
            // because the appropriate indent will be added when the next time Write() is called
            if (this.endsWithNewline)
            {
                this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
            }
            else
            {
                this.GenerationEnvironment.Append(textToAppend);
            }
        }
        /// <summary>
        /// Write text directly into the generated output
        /// </summary>
        public void WriteLine(string textToAppend)
        {
            this.Write(textToAppend);
            this.GenerationEnvironment.AppendLine();
            this.endsWithNewline = true;
        }
        /// <summary>
        /// Write formatted text directly into the generated output
        /// </summary>
        public void Write(string format, params object[] args)
        {
            this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
        }
        /// <summary>
        /// Write formatted text directly into the generated output
        /// </summary>
        public void WriteLine(string format, params object[] args)
        {
            this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
        }
        /// <summary>
        /// Raise an error
        /// </summary>
        public void Error(string message)
        {
            System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
            error.ErrorText = message;
            this.Errors.Add(error);
        }
        /// <summary>
        /// Raise a warning
        /// </summary>
        public void Warning(string message)
        {
            System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
            error.ErrorText = message;
            error.IsWarning = true;
            this.Errors.Add(error);
        }
        /// <summary>
        /// Increase the indent
        /// </summary>
        public void PushIndent(string indent)
        {
            if ((indent == null))
            {
                throw new global::System.ArgumentNullException("indent");
            }
            this.currentIndentField = (this.currentIndentField + indent);
            this.indentLengths.Add(indent.Length);
        }
        /// <summary>
        /// Remove the last indent that was added with PushIndent
        /// </summary>
        public string PopIndent()
        {
            string returnValue = "";
            if ((this.indentLengths.Count > 0))
            {
                int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
                this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
                if ((indentLength > 0))
                {
                    returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
                    this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
                }
            }
            return returnValue;
        }
        /// <summary>
        /// Remove any indentation
        /// </summary>
        public void ClearIndent()
        {
            this.indentLengths.Clear();
            this.currentIndentField = "";
        }
        #endregion
        #region ToString Helpers
        /// <summary>
        /// Utility class to produce culture-oriented representation of an object as a string.
        /// </summary>
        public class ToStringInstanceHelper
        {
            private System.IFormatProvider formatProviderField  = global::System.Globalization.CultureInfo.InvariantCulture;
            /// <summary>
            /// Gets or sets format provider to be used by ToStringWithCulture method.
            /// </summary>
            public System.IFormatProvider FormatProvider
            {
                get
                {
                    return this.formatProviderField ;
                }
                set
                {
                    if ((value != null))
                    {
                        this.formatProviderField  = value;
                    }
                }
            }
            /// <summary>
            /// This is called from the compile/run appdomain to convert objects within an expression block to a string
            /// </summary>
            public string ToStringWithCulture(object objectToConvert)
            {
                if ((objectToConvert == null))
                {
                    throw new global::System.ArgumentNullException("objectToConvert");
                }
                System.Type t = objectToConvert.GetType();
                System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
                            typeof(System.IFormatProvider)});
                if ((method == null))
                {
                    return objectToConvert.ToString();
                }
                else
                {
                    return ((string)(method.Invoke(objectToConvert, new object[] {
                                this.formatProviderField })));
                }
            }
        }
        private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
        /// <summary>
        /// Helper to produce culture-oriented representation of an object as a string
        /// </summary>
        public ToStringInstanceHelper ToStringHelper
        {
            get
            {
                return this.toStringHelperField;
            }
        }
        #endregion
    }
    #endregion
}