Example #1
0
        public void Deserialize(SerializationEngine engine, IPropertySymbol property, ITypeSymbol type, CodeWriter code,
                                string name, string typeIdentifier, Location location)
        {
            var named = (INamedTypeSymbol)type;
            var types = named.TypeArguments;

            code.AppendLine($"{SerializationEngine.GetQualifiedName(types[0])} key;");
            code.AppendLine($"{SerializationEngine.GetQualifiedName(types[1])} value;");

            engine.AppendReadLogic(property, types[0], code, "key", location);
            engine.AppendReadLogic(property, types[1], code, "value", location);

            code.AppendLine($"{name} = new {typeIdentifier}(key, value);");
        }
Example #2
0
        public void Deserialize(SerializationEngine engine, IPropertySymbol property, ITypeSymbol type, CodeWriter code,
                                string name,
                                string typeIdentifier, Location location)
        {
            var named = (INamedTypeSymbol)type;
            var types = named.TypeArguments;

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

                code.AppendLine($"{SerializationEngine.GetQualifiedName(types[idx])} {identifier};");
                engine.AppendReadLogic(property, types[0], code, identifier, location);
            }

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