Exemple #1
0
        public object Deserialize(TReader reader, Type objType, ReadFormatContext <TReader>?context = null)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            if (objType == null)
            {
                throw new ArgumentNullException(nameof(objType));
            }

            var format = Formats.GetFor(objType, Options);

            context = context ?? new ReadFormatContext <TReader>(this, reader);

            var obj = format.Read(objType, context.Value);

            if (obj is IDeserializationCallback callback)
            {
                callback.OnDeserialization(this);
            }

            return(obj);
        }
Exemple #2
0
 public T Deserialize <T>(TReader reader, ReadFormatContext <TReader>?context = null)
 => (T)Deserialize(reader, typeof(T), context);