Example #1
0
            public TestTokenizer(System.IO.TextReader reader)
                : base(reader)
            {
                //Caution: "Reader" is actually of type "ReusableStringReader" and some
                //methods (for ex. "ReadToEnd", "Peek",  "ReadLine") is not implemented.

                Assert.AreEqual("ReusableStringReader", reader.GetType().Name);
                Assert.AreEqual("First Line", reader.ReadLine(), "\"ReadLine\" method is not implemented");
                Assert.AreEqual("Second Line", reader.ReadToEnd(), "\"ReadToEnd\" method is not implemented");
            }
Example #2
0
        /// <inheritdoc />
        public override object Deserialize(Type targetType, TextReader source, bool throwOnError)
        {
            if (targetType == null) throw new ArgumentNullException("targetType");
            if (source == null) throw new ArgumentNullException("source");

            try
            {
                return defaultSerializer.Value.Deserialize(source, targetType);
            }
            catch (JsonSerializationException e)
            {
                return LogAndThrowParseExceptionIfNeeded<object>(
                    throwOnError, e, "Error deserializing object of type {0}", source.GetType().FullName);
            }
        }