コード例 #1
0
 private void InnerClone(T instance, ref T target, SerializationContext context)
 {
     // create and register the target, then clone the fields
     this.innerSerializer.PrepareCloningTarget(instance, ref target, context);
     context.AddDeserializedObject(target);
     this.innerSerializer.Clone(instance, ref target, context);
 }
コード例 #2
0
 private void InnerDeserialize(BufferReader reader, ref T target, SerializationContext context)
 {
     // create and register the target, then deserialize the fields
     this.innerSerializer.PrepareDeserializationTarget(reader, ref target, context);
     context.AddDeserializedObject(target);
     this.innerSerializer.Deserialize(reader, ref target, context);
 }
コード例 #3
0
        internal override void UntypedClear(ref object target, SerializationContext context)
        {
            T typedTarget = (T)target;

            context.AddDeserializedObject(target);
            this.innerSerializer.Clear(ref typedTarget, context);
            target = typedTarget;
        }
コード例 #4
0
        internal override void UntypedClone(object instance, ref object target, SerializationContext context)
        {
            T typedTarget = (target is T) ? (T)target : default(T);

            target = target ?? typedTarget;
            context.AddDeserializedObject(target);
            this.innerSerializer.Clone((T)instance, ref typedTarget, context);
            CopyToBox(typedTarget, ref target, context);
        }
コード例 #5
0
        internal override void UntypedDeserialize(BufferReader reader, ref object target, SerializationContext context)
        {
            T typedTarget = (target is T) ? (T)target : default(T);

            target = target ?? typedTarget;
            context.AddDeserializedObject(target);
            this.innerSerializer.Deserialize(reader, ref typedTarget, context);
            CopyToBox(typedTarget, ref target, context);
        }
コード例 #6
0
        internal override void UntypedClear(ref object target, SerializationContext context)
        {
            T typedTarget = default(T);

            if (target is T)
            {
                typedTarget = (T)target;
            }
            else
            {
                target = (object)default(T); // when the target is of a different type, we have to allocate a new object (via boxing)
            }

            context.AddDeserializedObject(target);
            this.innerSerializer.Clear(ref typedTarget, context);
            CopyToBox(typedTarget, ref target, context);
        }
コード例 #7
0
 private void InnerClear(ref T target, SerializationContext context)
 {
     context.AddDeserializedObject(target); // must do it first, so that circular dependencies can be detected
     this.innerSerializer.Clear(ref target, context);
 }