/// <inheritdoc />
        public object Deserialize(Type expectedType, IDeserializationContext context)
        {
            var startOffset = context.CurrentObjectOffset;
            var token       = (SerializerTypeToken)context.StreamReader.ReadByte();

            if (token == SerializerTypeToken.Exception)
            {
                var typeName = SerializationManager.DeserializeInner <string>(context);
                if (!_typeResolver.TryResolveType(typeName, out var type))
                {
                    // Deserialize into a fallback type for unknown exceptions
                    // This means that missing fields will not be represented.
                    var result = (UnavailableExceptionFallbackException)_objectSerializer.Deserialize(typeof(UnavailableExceptionFallbackException), startOffset, context);
                    result.ExceptionType = typeName;
                    return(result);
                }

                return(_objectSerializer.Deserialize(type, startOffset, context));
            }
            else
            {
                var type = SerializationManager.DeserializeInner <Type>(context);
                if (type.IsValueType)
                {
                    var serializer = _valueTypeSerializerFactory.GetSerializer(type);
                    return(serializer.Deserialize(type, startOffset, context));
                }

                return(_objectSerializer.Deserialize(type, startOffset, context));
            }
        }
        internal static object Deserialize(Type t, BinaryTokenStreamReader stream)
        {
            var target  = (ActorPath)SerializationManager.DeserializeInner(typeof(ActorPath), stream);
            var message = MessageEnvelope.Deserializer((byte[])SerializationManager.DeserializeInner(typeof(byte[]), stream));

            return(new RequestEnvelope(target, message));
        }
            /// <inheritdoc />
            public object Deserialize(Type type, int startOffset, IDeserializationContext context)
            {
                var callbacks = _serializationCallbacks.GetReferenceTypeCallbacks(type);
                var result    = FormatterServices.GetUninitializedObject(type);

                context.RecordObject(result, startOffset);

                var memberCount = SerializationManager.DeserializeInner <int>(context);

                var info             = new SerializationInfo(type, _formatterConverter);
                var streamingContext = new StreamingContext(StreamingContextStates.All, context);

                callbacks.OnDeserializing?.Invoke(result, streamingContext);

                for (var i = 0; i < memberCount; i++)
                {
                    var name      = SerializationManager.DeserializeInner <string>(context);
                    var fieldType = SerializationManager.DeserializeInner <Type>(context);
                    var value     = SerializationManager.DeserializeInner(fieldType, context);
                    info.AddValue(name, value);
                }

                var constructor = _constructorFactory.GetSerializationConstructorDelegate(type);

                constructor(result, info, streamingContext);
                callbacks.OnDeserialized?.Invoke(result, streamingContext);
                if (result is IDeserializationCallback callback)
                {
                    callback.OnDeserialization(context);
                }

                return(result);
            }
Exemple #4
0
        object IMessageSerializer.Deserialize(BinaryTokenStreamReader stream)
        {
            var bytes = (byte[])SerializationManager.DeserializeInner(typeof(byte[]), stream);
            var json  = Encoding.Default.GetString(bytes);

            return(JsonConvert.DeserializeObject(json, settings));
        }
Exemple #5
0
        internal static object Deserialize(Type t, BinaryTokenStreamReader stream)
        {
            var sender  = (ActorPath)SerializationManager.DeserializeInner(typeof(ActorPath), stream);
            var message = MessageEnvelope.Deserializer((byte[])SerializationManager.DeserializeInner(typeof(byte[]), stream));

            return(new NotificationEnvelope(sender, message));
        }
            public static object Deserializer(Type expected, IDeserializationContext context)
            {
                TestTypeA result = new TestTypeA();

                context.RecordObject(result);
                result.Collection = (ICollection <TestTypeA>)SerializationManager.DeserializeInner(typeof(ICollection <TestTypeA>), context);
                return(result);
            }
Exemple #7
0
        private static MemberDeclarationSyntax GenerateDeserializerMethod(Type type, List <FieldInfoMember> fields)
        {
            Expression <Action> deserializeInner =
                () => SerializationManager.DeserializeInner(default(Type), default(BinaryTokenStreamReader));
            var streamParameter = SF.IdentifierName("stream");

            var resultDeclaration =
                SF.LocalDeclarationStatement(
                    SF.VariableDeclaration(type.GetTypeSyntax())
                    .AddVariables(
                        SF.VariableDeclarator("result")
                        .WithInitializer(SF.EqualsValueClause(GetObjectCreationExpressionSyntax(type)))));
            var resultVariable      = SF.IdentifierName("result");
            var boxedResultVariable = resultVariable;

            var body = new List <StatementSyntax> {
                resultDeclaration
            };

            if (type.IsValueType)
            {
                // For value types, we need to box the result for reflection-based setters to work.
                body.Add(SF.LocalDeclarationStatement(
                             SF.VariableDeclaration(typeof(object).GetTypeSyntax())
                             .AddVariables(
                                 SF.VariableDeclarator("boxedResult").WithInitializer(SF.EqualsValueClause(resultVariable)))));
                boxedResultVariable = SF.IdentifierName("boxedResult");
            }

            // Deserialize all fields.
            foreach (var field in fields)
            {
                var deserialized =
                    deserializeInner.Invoke()
                    .AddArgumentListArguments(
                        SF.Argument(SF.TypeOfExpression(field.Type)),
                        SF.Argument(streamParameter));
                body.Add(
                    SF.ExpressionStatement(
                        field.GetSetter(
                            resultVariable,
                            SF.CastExpression(field.Type, deserialized),
                            boxedResultVariable)));
            }

            body.Add(SF.ReturnStatement(SF.CastExpression(type.GetTypeSyntax(), boxedResultVariable)));
            return
                (SF.MethodDeclaration(typeof(object).GetTypeSyntax(), "Deserializer")
                 .AddModifiers(SF.Token(SyntaxKind.PublicKeyword), SF.Token(SyntaxKind.StaticKeyword))
                 .AddParameterListParameters(
                     SF.Parameter(SF.Identifier("expected")).WithType(typeof(Type).GetTypeSyntax()),
                     SF.Parameter(SF.Identifier("stream")).WithType(typeof(BinaryTokenStreamReader).GetTypeSyntax()))
                 .AddBodyStatements(body.ToArray())
                 .AddAttributeLists(
                     SF.AttributeList()
                     .AddAttributes(SF.Attribute(typeof(DeserializerMethodAttribute).GetNameSyntax()))));
        }
Exemple #8
0
            internal static object Deserialize(Type expected, IDeserializationContext context)
            {
                int a = (int)SerializationManager.DeserializeInner <int>(context);
                int b = (int)SerializationManager.DeserializeInner <int>(context);

                return(new AdvancedPOCO {
                    A = a, B = b
                });
            }
        internal static object Deserialize(Type expected, IDeserializationContext context)
        {
            string etag          = SerializationManager.DeserializeInner <string>(context);
            TView  state         = SerializationManager.DeserializeInner <TView>(context);
            int    globalVersion = SerializationManager.DeserializeInner <int>(context);
            string writeVector   = SerializationManager.DeserializeInner <string>(context);

            return(new GrainStateWithMetaDataAndETag <TView>(etag, state, globalVersion, writeVector));
        }
Exemple #10
0
        /// <summary>
        /// Returns syntax for the deserializer method.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="fields">The fields.</param>
        /// <returns>Syntax for the deserializer method.</returns>
        private static MemberDeclarationSyntax GenerateDeserializerMethod(Type type, List <FieldInfoMember> fields)
        {
            Expression <Action> deserializeInner =
                () => SerializationManager.DeserializeInner(default(Type), default(IDeserializationContext));
            var contextParameter = SF.IdentifierName("context");

            var resultDeclaration =
                SF.LocalDeclarationStatement(
                    SF.VariableDeclaration(type.GetTypeSyntax())
                    .AddVariables(
                        SF.VariableDeclarator("result")
                        .WithInitializer(SF.EqualsValueClause(GetObjectCreationExpressionSyntax(type)))));
            var resultVariable = SF.IdentifierName("result");

            var body = new List <StatementSyntax> {
                resultDeclaration
            };

            // Value types cannot be referenced, only copied, so there is no need to box & record instances of value types.
            if (!type.GetTypeInfo().IsValueType)
            {
                // Record the result for cyclic deserialization.
                Expression <Action <IDeserializationContext> > recordObject = ctx => ctx.RecordObject(default(object));
                var currentSerializationContext = contextParameter;
                body.Add(
                    SF.ExpressionStatement(
                        recordObject.Invoke(currentSerializationContext)
                        .AddArgumentListArguments(SF.Argument(resultVariable))));
            }

            // Deserialize all fields.
            foreach (var field in fields)
            {
                var deserialized =
                    deserializeInner.Invoke()
                    .AddArgumentListArguments(
                        SF.Argument(SF.TypeOfExpression(field.Type)),
                        SF.Argument(contextParameter));
                body.Add(
                    SF.ExpressionStatement(
                        field.GetSetter(
                            resultVariable,
                            SF.CastExpression(field.Type, deserialized))));
            }

            body.Add(SF.ReturnStatement(SF.CastExpression(type.GetTypeSyntax(), resultVariable)));
            return
                (SF.MethodDeclaration(typeof(object).GetTypeSyntax(), "Deserializer")
                 .AddModifiers(SF.Token(SyntaxKind.PublicKeyword), SF.Token(SyntaxKind.StaticKeyword))
                 .AddParameterListParameters(
                     SF.Parameter(SF.Identifier("expected")).WithType(typeof(Type).GetTypeSyntax()),
                     SF.Parameter(SF.Identifier("context")).WithType(typeof(IDeserializationContext).GetTypeSyntax()))
                 .AddBodyStatements(body.ToArray())
                 .AddAttributeLists(
                     SF.AttributeList()
                     .AddAttributes(SF.Attribute(typeof(DeserializerMethodAttribute).GetNameSyntax()))));
        }
        public override object Deserialize(BinaryTokenStreamReader stream)
        {
            var bytes = (byte[])SerializationManager.DeserializeInner(typeof(byte[]), stream);

            using (var ms = new MemoryStream(bytes))
            {
                var formatter = new BinaryFormatter();
                return(formatter.Deserialize(ms));
            }
        }
Exemple #12
0
            internal static object Deserialize(Type expected, IDeserializationContext context)
            {
                int a                = SerializationManager.DeserializeInner <int>(context);
                int b                = SerializationManager.DeserializeInner <int>(context);
                int copyCount        = SerializationManager.DeserializeInner <int>(context);
                int serializeCount   = SerializationManager.DeserializeInner <int>(context);
                int deserializeCount = SerializationManager.DeserializeInner <int>(context);

                return(new ReportingPOCO {
                    A = a, B = b, CopyCount = copyCount, SerializeCount = serializeCount, DeserializeCount = deserializeCount + 1
                });
            }
Exemple #13
0
 public void Deserialize(ReadOnlySequence <byte> input, out T value)
 {
     reader.PartialReset(input);
     try
     {
         value = (T)SerializationManager.DeserializeInner(this.serializationManager, typeof(T), this.deserializationContext, this.reader);
     }
     finally
     {
         this.deserializationContext.Reset();
     }
 }
Exemple #14
0
        public static object Deserializer(Type expected, IDeserializationContext context)
        {
            var source    = SerializationManager.DeserializeInner <WorkflowActivity>(context);
            var target    = SerializationManager.DeserializeInner <WorkflowActivity>(context);
            var predicate = (Expression <Func <ActivityContext, bool> >)ExpressionSerializer.DeserializeBinary(SerializationManager.DeserializeInner <byte[]>(context));

            return(new EdgeWithPredicate
            {
                Source = source,
                Target = target,
                Predicate = predicate
            });
        }
Exemple #15
0
        public virtual object Deserialize(Type expectedType, IDeserializationContext context)
        {
            var bytes = SerializationManager.DeserializeInner <byte[]>(context);

            using (var stream = new MemoryStream())
            {
                stream.Write(bytes, 0, bytes.Length);
                var formatter = new BinaryFormatter();
                stream.Position = 0;
                object obTarget = formatter.Deserialize(stream);
                stream.Close();
                return(obTarget);
            }
        }
Exemple #16
0
        public static object Deserializer(Type expected, IDeserializationContext context)
        {
            var typeSourceCode = SerializationManager.DeserializeInner <string>(context);

            var workflowType = ActivityTypeCache.GetOrAdd(typeSourceCode, src => src.CompileFromSourceCode());

            var objectBytes = SerializationManager.DeserializeInner <byte[]>(context);

            var workflowActivity = JsonSerializer.NonGeneric.Deserialize(workflowType, objectBytes);

            context.RecordObject(workflowActivity);

            return(workflowActivity);
        }
Exemple #17
0
        /// <summary>
        /// Deserializes the container from the data stream.
        /// </summary>
        /// <param name="expected">The expected type</param>
        /// <param name="reader">The stream reader</param>
        /// <returns>The deserialized value</returns>
        public static object Deserialize(Type expected, BinaryTokenStreamReader reader)
        {
            var deserialized = new AzureQueueBatchContainerV2();

            DeserializationContext.Current.RecordObject(deserialized);
            var guid       = reader.ReadGuid();
            var ns         = reader.ReadString();
            var eventToken = SerializationManager.DeserializeInner <EventSequenceTokenV2>(reader);
            var events     = SerializationManager.DeserializeInner <List <object> >(reader);
            var context    = SerializationManager.DeserializeInner <Dictionary <string, object> >(reader);

            deserialized.SetValues(guid, ns, events, context, eventToken);
            return(deserialized);
        }
Exemple #18
0
        public static object Deserializer(Type expected, IDeserializationContext context)
        {
            var result = new User();

            // Record 'result' immediately after constructing it. As with with the deep copier, this
            // allows for cyclic references and de-duplication.
            context.RecordObject(result);

            // Deserialize each field in the order that they were serialized.
            result.BestFriend     = SerializationManager.DeserializeInner <User>(context);
            result.NickName       = SerializationManager.DeserializeInner <string>(context);
            result.FavoriteNumber = SerializationManager.DeserializeInner <int>(context);
            result.BirthDate      = SerializationManager.DeserializeInner <DateTimeOffset>(context);

            return(result);
        }
Exemple #19
0
        public static object Deserializer(Type expected, IDeserializationContext context)
        {
            var result = new ActivityContext();

            // Record 'result' immediately after constructing it. As with with the deep copier, this
            // allows for cyclic references and de-duplication.
            context.RecordObject(result);

            var deserialized = SerializationManager.DeserializeInner <IDictionary <string, object> >(context);

            foreach (var kvp in deserialized)
            {
                result.Data.Add(kvp.Key, kvp.Value);
            }

            return(result);
        }
        public ReflectedSerializationMethodInfo()
        {
            this.GetUninitializedObject = TypeUtils.Method(() => FormatterServices.GetUninitializedObject(typeof(int)));
            this.GetTypeFromHandle      = TypeUtils.Method(() => Type.GetTypeFromHandle(typeof(Type).TypeHandle));
            this.DeepCopyInner          = TypeUtils.Method(() => SerializationManager.DeepCopyInner(default(Type), default(ICopyContext)));
            this.SerializeInner         = TypeUtils.Method(() => SerializationManager.SerializeInner(default(object), default(ISerializationContext), default(Type)));
            this.DeserializeInner       = TypeUtils.Method(() => SerializationManager.DeserializeInner(default(Type), default(IDeserializationContext)));

            this.RecordObjectWhileCopying = TypeUtils.Method((ICopyContext ctx) => ctx.RecordCopy(default(object), default(object)));

            this.GetStreamFromDeserializationContext = TypeUtils.Property((IDeserializationContext ctx) => ctx.StreamReader).GetMethod;
            this.GetStreamFromSerializationContext   = TypeUtils.Property((ISerializationContext ctx) => ctx.StreamWriter).GetMethod;

            this.RecordObjectWhileDeserializing = TypeUtils.Method((IDeserializationContext ctx) => ctx.RecordObject(default(object)));
            this.SerializerDelegate             =
                TypeUtils.Method((Serializer del) => del.Invoke(default(object), default(ISerializationContext), default(Type)));
            this.DeserializerDelegate = TypeUtils.Method((Deserializer del) => del.Invoke(default(Type), default(IDeserializationContext)));
            this.DeepCopierDelegate   = TypeUtils.Method((DeepCopier del) => del.Invoke(default(object), default(ICopyContext)));
        }
Exemple #21
0
        public ReflectedSerializationMethodInfo()
        {
#if NETSTANDARD
            this.GetUninitializedObject = TypeUtils.Method(() => SerializationManager.GetUninitializedObjectWithFormatterServices(typeof(int)));
#else
            this.GetUninitializedObject = TypeUtils.Method(() => FormatterServices.GetUninitializedObject(typeof(int)));
#endif
            this.GetTypeFromHandle = TypeUtils.Method(() => Type.GetTypeFromHandle(typeof(int).TypeHandle));
            this.DeepCopyInner     = TypeUtils.Method(() => SerializationManager.DeepCopyInner(typeof(int)));
            this.SerializeInner    = TypeUtils.Method(() => SerializationManager.SerializeInner(default(object), default(BinaryTokenStreamWriter), default(Type)));
            this.DeserializeInner  = TypeUtils.Method(() => SerializationManager.DeserializeInner(default(Type), default(BinaryTokenStreamReader)));

            this.GetCurrentSerializationContext = TypeUtils.Property((object _) => SerializationContext.Current).GetMethod;
            this.RecordObjectWhileCopying       = TypeUtils.Method((SerializationContext ctx) => ctx.RecordObject(default(object), default(object)));

            this.GetCurrentDeserializationContext = TypeUtils.Property((object _) => DeserializationContext.Current).GetMethod;
            this.RecordObjectWhileDeserializing   = TypeUtils.Method((DeserializationContext ctx) => ctx.RecordObject(default(object)));
            this.SerializerDelegate =
                TypeUtils.Method((SerializationManager.Serializer del) => del.Invoke(default(object), default(BinaryTokenStreamWriter), default(Type)));
            this.DeserializerDelegate = TypeUtils.Method((SerializationManager.Deserializer del) => del.Invoke(default(Type), default(BinaryTokenStreamReader)));
            this.DeepCopierDelegate   = TypeUtils.Method((SerializationManager.DeepCopier del) => del.Invoke(default(object)));
        }
Exemple #22
0
 static private object Deserialize(Type expected, IDeserializationContext context)
 {
     return(SerializationManager.DeserializeInner(expected, context));
 }
Exemple #23
0
        internal static object Deserialize(Type t, BinaryTokenStreamReader stream)
        {
            var message = MessageEnvelope.Deserializer((byte[])SerializationManager.DeserializeInner(typeof(byte[]), stream));

            return(new ResponseEnvelope(message));
        }
            public static object Deserializer(Type expected, BinaryTokenStreamReader stream)
            {
                var str = (string)(SerializationManager.DeserializeInner(typeof(string), stream));

                return(JObject.Parse(str));
            }
Exemple #25
0
        /// <summary>
        /// Called from generated code.
        /// </summary>
        /// <param name="stream">Stream to recover / repopulate this grain state object from.</param>
        public void DeserializeFrom(BinaryTokenStreamReader stream)
        {
            var values = (Dictionary <string, object>)SerializationManager.DeserializeInner(wireFormatType, stream);

            this.SetAllInternal(values);
        }
Exemple #26
0
            public static object Deserializer(Type expected, IDeserializationContext context)
            {
                var result = new HeadersContainer();
                var reader = context.StreamReader;

                context.RecordObject(result);
                var headers = (Headers)reader.ReadInt();

                if ((headers & Headers.CACHE_INVALIDATION_HEADER) != Headers.NONE)
                {
                    var n = reader.ReadInt();
                    if (n > 0)
                    {
                        var list = result.CacheInvalidationHeader = new List <ActivationAddress>(n);
                        for (int i = 0; i < n; i++)
                        {
                            list.Add((ActivationAddress)ReadObj(typeof(ActivationAddress), context));
                        }
                    }
                }

                if ((headers & Headers.CATEGORY) != Headers.NONE)
                {
                    result.Category = (Categories)reader.ReadByte();
                }

                if ((headers & Headers.DEBUG_CONTEXT) != Headers.NONE)
                {
                    result.DebugContext = reader.ReadString();
                }

                if ((headers & Headers.DIRECTION) != Headers.NONE)
                {
                    result.Direction = (Message.Directions)reader.ReadByte();
                }

                if ((headers & Headers.TIME_TO_LIVE) != Headers.NONE)
                {
                    result.TimeToLive = reader.ReadTimeSpan();
                }

                if ((headers & Headers.FORWARD_COUNT) != Headers.NONE)
                {
                    result.ForwardCount = reader.ReadInt();
                }

                if ((headers & Headers.GENERIC_GRAIN_TYPE) != Headers.NONE)
                {
                    result.GenericGrainType = reader.ReadString();
                }

                if ((headers & Headers.CORRELATION_ID) != Headers.NONE)
                {
                    result.Id = (Orleans.Runtime.CorrelationId)ReadObj(typeof(Orleans.Runtime.CorrelationId), context);
                }

                if ((headers & Headers.ALWAYS_INTERLEAVE) != Headers.NONE)
                {
                    result.IsAlwaysInterleave = ReadBool(reader);
                }

                if ((headers & Headers.IS_NEW_PLACEMENT) != Headers.NONE)
                {
                    result.IsNewPlacement = ReadBool(reader);
                }

                if ((headers & Headers.IS_USING_INTERFACE_VERSION) != Headers.NONE)
                {
                    result.IsUsingIfaceVersion = true;
                }

                if ((headers & Headers.READ_ONLY) != Headers.NONE)
                {
                    result.IsReadOnly = ReadBool(reader);
                }

                if ((headers & Headers.IS_UNORDERED) != Headers.NONE)
                {
                    result.IsUnordered = ReadBool(reader);
                }

                if ((headers & Headers.NEW_GRAIN_TYPE) != Headers.NONE)
                {
                    result.NewGrainType = reader.ReadString();
                }

                if ((headers & Headers.REJECTION_INFO) != Headers.NONE)
                {
                    result.RejectionInfo = reader.ReadString();
                }

                if ((headers & Headers.REJECTION_TYPE) != Headers.NONE)
                {
                    result.RejectionType = (RejectionTypes)reader.ReadByte();
                }

                if ((headers & Headers.REQUEST_CONTEXT) != Headers.NONE)
                {
                    var c           = reader.ReadInt();
                    var requestData = new Dictionary <string, object>(c);
                    for (int i = 0; i < c; i++)
                    {
                        requestData[reader.ReadString()] = SerializationManager.DeserializeInner(null, context);
                    }
                    result.RequestContextData = requestData;
                }

                if ((headers & Headers.RESEND_COUNT) != Headers.NONE)
                {
                    result.ResendCount = reader.ReadInt();
                }

                if ((headers & Headers.RESULT) != Headers.NONE)
                {
                    result.Result = (Orleans.Runtime.Message.ResponseTypes)reader.ReadByte();
                }

                if ((headers & Headers.SENDING_ACTIVATION) != Headers.NONE)
                {
                    result.SendingActivation = reader.ReadActivationId();
                }

                if ((headers & Headers.SENDING_GRAIN) != Headers.NONE)
                {
                    result.SendingGrain = reader.ReadGrainId();
                }

                if ((headers & Headers.SENDING_SILO) != Headers.NONE)
                {
                    result.SendingSilo = reader.ReadSiloAddress();
                }

                if ((headers & Headers.TARGET_ACTIVATION) != Headers.NONE)
                {
                    result.TargetActivation = reader.ReadActivationId();
                }

                if ((headers & Headers.TARGET_GRAIN) != Headers.NONE)
                {
                    result.TargetGrain = reader.ReadGrainId();
                }

                if ((headers & Headers.TARGET_OBSERVER) != Headers.NONE)
                {
                    result.TargetObserverId = (Orleans.Runtime.GuidId)ReadObj(typeof(Orleans.Runtime.GuidId), context);
                }

                if ((headers & Headers.TARGET_SILO) != Headers.NONE)
                {
                    result.TargetSilo = reader.ReadSiloAddress();
                }

                result.IsTransactionRequired = (headers & Headers.IS_TRANSACTION_REQUIRED) != Headers.NONE;

                if ((headers & Headers.TRANSACTION_INFO) != Headers.NONE)
                {
                    result.TransactionInfo = SerializationManager.DeserializeInner <ITransactionInfo>(context);
                }

                return(result);
            }
        public virtual object Deserialize(Type expectedType, IDeserializationContext context)
        {
            var str = SerializationManager.DeserializeInner <string>(context);

            return(JsonConvert.DeserializeObject(str, expectedType, JsonSettingsFunc()));
        }
 public object DeserializeInner(Type expected)
 {
     return(SerializationManager.DeserializeInner(expected, this));
 }
 public override object Deserialize(BinaryTokenStreamReader stream)
 {
     return(SerializationManager.DeserializeInner(null, stream));
 }
 public object DeserializeInner(Type expected) => SerializationManager.DeserializeInner(expected, this);