Exemple #1
0
        private bool CollectionWrapper(PropertyModel prop, bool head)
        {
            if (!prop.IsCollection)
            {
                return(false);
            }

            if (head)
            {
        #line default
        #line hidden

        #line 93 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(" \r\n                if (");


        #line default
        #line hidden

        #line 94 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 94 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(" != null)\r\n                {\r\n                    var temp");


        #line default
        #line hidden

        #line 96 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 96 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(" = ");


        #line default
        #line hidden

        #line 96 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(GeneratorTools.CollectionConstructor(prop, $"{prop.Name}.{GeneratorTools.CollectionSize(prop)}")));


        #line default
        #line hidden

        #line 96 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(";\r\n");


        #line default
        #line hidden

        #line 97 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"

                if (GeneratorTools.SupportsForLoop(prop))
                {
        #line default
        #line hidden

        #line 100 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("                    for (var i = 0; i < ");


        #line default
        #line hidden

        #line 101 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 101 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(".");


        #line default
        #line hidden

        #line 101 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(GeneratorTools.CollectionSize(prop)));


        #line default
        #line hidden

        #line 101 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("; i++)\r\n                    {\r\n                        var value = ");


        #line default
        #line hidden

        #line 103 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 103 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("[i];\r\n");


        #line default
        #line hidden

        #line 104 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                }
                else
                {
        #line default
        #line hidden

        #line 108 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("                    foreach (var value in ");


        #line default
        #line hidden

        #line 109 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 109 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(")\r\n                    {\r\n");


        #line default
        #line hidden

        #line 111 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                }
            }
            else
            {
                if (prop.CollectionType == "Array")
                {
        #line default
        #line hidden

        #line 118 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("                        temp");


        #line default
        #line hidden

        #line 119 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 119 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("[i] = value;\r\n");


        #line default
        #line hidden

        #line 120 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                }
                else
                {
        #line default
        #line hidden

        #line 124 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write("                        temp");


        #line default
        #line hidden

        #line 125 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 125 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                    this.Write(".Add(value);\r\n");


        #line default
        #line hidden

        #line 126 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                }


        #line default
        #line hidden

        #line 128 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write("                    }\r\n                    copy.");


        #line default
        #line hidden

        #line 130 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 130 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(" = temp");


        #line default
        #line hidden

        #line 130 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));


        #line default
        #line hidden

        #line 130 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
                this.Write(";\r\n                }\r\n");


        #line default
        #line hidden

        #line 132 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Clone\CloneGenerator.tt"
            }

            return(true);
        }
Exemple #2
0
        //--------------------------------------
        // Code fragments wrapping a collection
        //--------------------------------------
        private void CollectionWrapper(PropertyModel property, bool start)
        {
            if (!property.IsCollection || property.ValueType == ModelValueType.Byte)
            {
                return;
            }

            if (start)
            {
        #line default
        #line hidden

        #line 244 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                this.Write("            if (");


        #line default
        #line hidden

        #line 245 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));


        #line default
        #line hidden

        #line 245 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                this.Write(" != null)\r\n            {\r\n");


        #line default
        #line hidden

        #line 247 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"

                if (GeneratorTools.SupportsForLoop(property))
                {
                    var dimensions = new[] { "i", "j", "k" };
                    for (var dimension = 0; dimension < property.Dimensions; dimension++)
                    {
                        var targetDimension = property.Dimensions > 1 ? dimension : -1;



        #line default
        #line hidden

        #line 255 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write("                for(var ");


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension]));


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(" = 0; ");


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension]));


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(" < ");


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(".");


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(GeneratorTools.CollectionSize(property, targetDimension)));


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write("; ");


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension]));


        #line default
        #line hidden

        #line 256 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                        this.Write("++)\r\n");


        #line default
        #line hidden

        #line 257 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    }


        #line default
        #line hidden

        #line 259 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write("                {\r\n                    var value = ");


        #line default
        #line hidden

        #line 261 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));


        #line default
        #line hidden

        #line 261 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write("[");


        #line default
        #line hidden

        #line 261 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(",", Enumerable.Range(0, property.Dimensions).Select(i => dimensions[i]))));


        #line default
        #line hidden

        #line 261 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write("];\r\n");


        #line default
        #line hidden

        #line 262 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                }
                else
                {
        #line default
        #line hidden

        #line 266 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write("                foreach(var value in ");


        #line default
        #line hidden

        #line 267 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));


        #line default
        #line hidden

        #line 267 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                    this.Write(")\r\n                {\r\n");


        #line default
        #line hidden

        #line 269 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                }
            }
            else
            {
        #line default
        #line hidden

        #line 275 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
                this.Write("                }\r\n            }\r\n");


        #line default
        #line hidden

        #line 278 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt"
            }
        }