Exemplo n.º 1
0
 public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber)
 {
     return(new IfElseBlock($"{fieldInstance}.HasValue", then =>
     {
         then.Line(containedType.GetSerializationStatement($"{fieldInstance}.Value", schemaObject, fieldNumber));
     }).Format());
 }
Exemplo n.º 2
0
 public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber)
 {
     return(new LoopBlock($"foreach (var value in {fieldInstance})", body =>
     {
         body.Line(ContainedType.GetSerializationStatement("value", schemaObject, fieldNumber));
     }).Format());
 }
Exemplo n.º 3
0
        public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber, int indents)
        {
            var codeWriter = new CodeWriter();

            using (codeWriter.Scope($"foreach (var value in {fieldInstance})"))
            {
                codeWriter.WriteLine(containedType.GetSerializationStatement("value", schemaObject, fieldNumber));
            }

            return(CommonGeneratorUtils.IndentEveryNewline(codeWriter.Build(), indents));
        }
Exemplo n.º 4
0
 public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber)
 {
     return(new LoopBlock($"foreach (var keyValuePair in {fieldInstance})", body =>
     {
         body.Line(new[]
         {
             $"var mapObj = {schemaObject}.AddObject({fieldNumber});",
             keyType.GetSerializationStatement("keyValuePair.Key", "mapObj", 1),
             valueType.GetSerializationStatement("keyValuePair.Value", "mapObj", 2)
         });
     }).Format());
 }
Exemplo n.º 5
0
        public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber, int indents)
        {
            var codeWriter = new CodeWriter();

            using (codeWriter.Scope($"foreach (var keyValuePair in {fieldInstance})"))
            {
                codeWriter.WriteLine($"var mapObj = {schemaObject}.AddObject({fieldNumber});");
                codeWriter.WriteLine(keyType.GetSerializationStatement("keyValuePair.Key", "mapObj", 1));
                codeWriter.WriteLine(valueType.GetSerializationStatement("keyValuePair.Value", "mapObj", 2));
            }

            return(CommonGeneratorUtils.IndentEveryNewline(codeWriter.Build(), indents));
        }
Exemplo n.º 6
0
 public string GetSerializationString(string fieldInstance, string schemaObject, uint fieldNumber)
 {
     return(containedType.GetSerializationStatement(fieldInstance, schemaObject, fieldNumber));
 }