Example #1
0
        public void Deserialize(ISymbol member, ITypeSymbol type, CodeWriter code,
                                string name, string typeIdentifier, Location location)
        {
            var named  = GenerationEngine.GetNamedTypeSymbol(type);
            var types  = named.TypeArguments;
            var prefix = GenerationEngine.GetVariableName(name);

            code.AppendLine($"{GenerationEngine.GetQualifiedName(types[0])} {prefix}Key = default;");
            code.AppendLine($"{GenerationEngine.GetQualifiedName(types[1])} {prefix}Value = default;");

            ReadGenerator.Make(member, types[0], code, $"{prefix}Key", location);
            ReadGenerator.Make(member, types[1], code, $"{prefix}Value", location);

            code.AppendLine($"{name} = new {typeIdentifier}({prefix}Key, {prefix}Value);");
        }
        public void Deserialize(ISymbol member, ITypeSymbol type, CodeWriter code,
                                string name,
                                string typeIdentifier, Location location)
        {
            var named  = GenerationEngine.GetNamedTypeSymbol(type);
            var types  = named.TypeArguments;
            var prefix = GenerationEngine.GetVariableName(name);

            for (var idx = 0; idx < Items; idx++)
            {
                var item       = idx + 1;
                var identifier = $"{prefix}Item{item}";

                code.AppendLine($"{GenerationEngine.GetQualifiedName(types[idx])} {identifier} = default;");
                ReadGenerator.Make(member, types[idx], code, identifier, location);
            }

            code.AppendLine(
                $"{name} = new {typeIdentifier}({string.Join(", ", Enumerable.Range(1, Items).Select(self => $"{prefix}Item{self}"))});");
        }