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); }
//---------------------------------------- // Generate loop for reading collections //---------------------------------------- private void GenerateReadLoop(PropertyModel property, bool header) { if (!property.IsCollection) { return; } if (header) { // Read the length for (var dimension = 0; dimension < property.Dimensions; dimension++) { #line default #line hidden #line 337 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" var "); #line default #line hidden #line 338 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FieldLength(property, dimension))); #line default #line hidden #line 338 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" = GeneratorByteConverter.ToUInt16(bytes, ref index);\r\n"); #line default #line hidden #line 339 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" } } if (header && property.IsCollection) { // Create temp object #line default #line hidden #line 346 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" var temp"); #line default #line hidden #line 347 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Name)); #line default #line hidden #line 347 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" = "); #line default #line hidden #line 347 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(GeneratorTools.CollectionConstructor(property, FieldLength(property)))); #line default #line hidden #line 347 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(";\r\n"); #line default #line hidden #line 348 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" // Generate the loop var dimensions = new[] { "i", "j", "k" }; for (var dimension = 0; dimension < property.Dimensions; dimension++) { #line default #line hidden #line 354 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" for (var "); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension])); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" = 0; "); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension])); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" < "); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FieldLength(property, dimension))); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write("; "); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(dimensions[dimension])); #line default #line hidden #line 355 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write("++)\r\n"); #line default #line hidden #line 356 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" } #line default #line hidden #line 358 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" {\r\n"); #line default #line hidden #line 360 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" } else if (!header && property.IsCollection) { var collAssignment = property.CollectionType == "Array" ? $"temp{property.Name}[{FieldPosition(property)}] = value" : $"temp{property.Name}.Add(value)"; #line default #line hidden #line 368 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" "); #line default #line hidden #line 369 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(collAssignment)); #line default #line hidden #line 369 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(";\r\n }\r\n "); #line default #line hidden #line 371 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Name)); #line default #line hidden #line 371 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(" = temp"); #line default #line hidden #line 371 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Name)); #line default #line hidden #line 371 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" this.Write(";\r\n"); #line default #line hidden #line 372 "C:\Users\Thomas\Documents\Development\CGbR\CGbR\Generator\Serialization\BinarySerializerGenerator.tt" } }