Exemplo n.º 1
0
        protected virtual async Task ObjectDeserializeOverrideAsync(BoundedStream stream, EventShuttle eventShuttle,
                                                                    CancellationToken cancellationToken)
        {
            // check to see if we are actually supposed to be a custom deserialization.  This is a side-effect of
            // treating all object members as object nodes.  In the case of sub-types we could later discover we
            // are actually a custom node because the specified subtype implements IBinarySerializable.
            if (IsCustomNode(out ValueNode customValueNode))
            {
                await customValueNode.DeserializeOverrideAsync(stream, eventShuttle, cancellationToken)
                .ConfigureAwait(false);

                // this is a cheat, but another side-effect of this weird corner case
                _cachedValue = customValueNode.Value;

                return;
            }

            var lazyContext = CreateLazySerializationContext();

            foreach (var child in GetSerializableChildren())
            {
                EmitBeginDeserialization(stream, child, lazyContext, eventShuttle);

                await child.DeserializeAsync(stream, eventShuttle, cancellationToken).ConfigureAwait(false);

                EmitEndDeserialization(stream, child, lazyContext, eventShuttle);
            }
        }
 public override void DeserializeOverride(StreamLimiter stream, EventShuttle eventShuttle)
 {
     throw new InvalidOperationException("Deserializing object fields not supported.");
 }
Exemplo n.º 3
0
 internal override Task SerializeOverrideAsync(BoundedStream stream, EventShuttle eventShuttle, CancellationToken cancellationToken)
 {
     ThrowIfUnordered();
     return(ObjectSerializeOverrideAsync(stream, eventShuttle, cancellationToken));
 }
Exemplo n.º 4
0
 internal override void SerializeOverride(BoundedStream stream, EventShuttle eventShuttle)
 {
     ThrowIfUnordered();
     ObjectSerializeOverride(stream, eventShuttle);
 }
 internal override void SerializeOverride(BoundedStream stream, EventShuttle eventShuttle)
 {
     Serialize(stream, BoundValue, TypeNode.GetSerializedType());
 }
Exemplo n.º 6
0
 internal override Task DeserializeOverrideAsync(BoundedStream stream, EventShuttle eventShuttle,
                                                 CancellationToken cancellationToken)
 {
     DeserializeOverride(stream, eventShuttle);
     return(Task.CompletedTask);
 }