private bool TryDeserializeInternal(IDeserializerContext context, ICompositeStorage storage) { string typeName = storage.Get <string>(Name.TypeName); if (!typeNameMapper.TryGet(typeName, out Type outputType)) { return(false); } if (!storage.TryGet(Name.Payload, out ICompositeStorage childStorage)) { return(false); } ICompositeModel model = modelFactory.Create(outputType) as ICompositeModel; if (model == null) { return(false); } model.Load(childStorage); context.Output = model; return(true); }
public async Task <bool> TryDeserializeAsync(Stream input, IDeserializerContext context) { Ensure.NotNull(input, "input"); Ensure.NotNull(context, "context"); ICompositeModel model = modelFactory.Invoke(context.OutputType) as ICompositeModel; if (model == null) { return(false); } ICompositeStorage storage = storageFactory.Create(); await storage.LoadAsync(input).ConfigureAwait(false); model.Load(storage); context.Output = model; return(true); }
public bool TryDeserialize(Stream input, IDeserializerContext context) { Ensure.NotNull(input, "input"); Ensure.NotNull(context, "context"); ICompositeModel model = modelFactory.Invoke(context.OutputType) as ICompositeModel; if (model == null) { return(false); } ICompositeStorage storage = storageFactory.Create(); storage.Load(input); model.Load(storage); context.Output = model; return(true); }