public string GetDeserializationString(string fieldInstance, string schemaObject, uint fieldNumber) { return(new CustomScopeBlock(scope => { scope.Line(new[] { $"{fieldInstance} = new {Type}();", $"var list = {fieldInstance};", $"var listLength = {ContainedType.GetCountExpression(schemaObject, fieldNumber)};" }); scope.Loop("for (var i = 0; i < listLength; i++)", body => { body.Line($"list.Add({ContainedType.GetFieldIndexExpression(schemaObject, fieldNumber, "i")});"); }); }).Format()); }
public string GetDeserializationString(string fieldInstance, string schemaObject, uint fieldNumber, int indents) { var codeWriter = new CodeWriter(); using (codeWriter.Scope()) { codeWriter.WriteLine($"{fieldInstance} = new {Type}();"); codeWriter.WriteLine($"var list = {fieldInstance};"); codeWriter.WriteLine( $"var listLength = {containedType.GetCountExpression(schemaObject, fieldNumber)};"); using (codeWriter.Scope("for (var i = 0; i < listLength; i++)")) { codeWriter.WriteLine( $"list.Add({containedType.GetFieldIndexExpression(schemaObject, fieldNumber, "i")});"); } } return(CommonGeneratorUtils.IndentEveryNewline(codeWriter.Build(), indents)); }