Exemple #1
0
        public TypeSchema Initialize(KnownSerializers serializers, TypeSchema targetSchema)
        {
            var schema = TypeSchema.FromType(typeof(T), serializers.RuntimeVersion, this.GetType(), Version);

            this.serializeImpl   = Generator.GenerateSerializeMethod <T>(il => Generator.EmitPrimitiveSerialize(typeof(T), il));
            this.deserializeImpl = Generator.GenerateDeserializeMethod <T>(il => Generator.EmitPrimitiveDeserialize(typeof(T), il));
            return(targetSchema ?? schema);
        }
Exemple #2
0
        public TypeSchema Initialize(KnownSerializers serializers, TypeSchema targetSchema)
        {
            var runtimeSchema = TypeSchema.FromType(typeof(T), serializers.RuntimeVersion, this.GetType(), Version);
            var members       = runtimeSchema.GetCompatibleMemberSet(targetSchema);

            this.serializeImpl   = Generator.GenerateSerializeMethod <T>(il => Generator.EmitSerializeFields(typeof(T), serializers, il, members));
            this.deserializeImpl = Generator.GenerateDeserializeMethod <T>(il => Generator.EmitDeserializeFields(typeof(T), serializers, il, members));

            return(targetSchema ?? runtimeSchema);
        }