/// <summary>
 /// 
 /// </summary>
 /// <param name="inputSimplTypesScope"></param>
 /// <param name="inputContext"></param>
 /// <param name="hookStrategy"></param>
 protected PullDeserializer(SimplTypesScope inputSimplTypesScope, TranslationContext inputContext,
     IDeserializationHookStrategy hookStrategy)
 {
     simplTypesScope = inputSimplTypesScope;
     translationContext = inputContext;
     deserializationHookStrategy = hookStrategy;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="inputSimplTypesScope"></param>
 /// <param name="inputContext"></param>
 /// <param name="hookStrategy"></param>
 protected PullDeserializer(SimplTypesScope inputSimplTypesScope, TranslationContext inputContext,
                            IDeserializationHookStrategy hookStrategy)
 {
     simplTypesScope             = inputSimplTypesScope;
     translationContext          = inputContext;
     deserializationHookStrategy = hookStrategy;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pSimplTypesScope"></param>
 /// <param name="pTranslationContext"></param>
 /// <param name="pDeserializationHookStrategy"></param>
 /// <param name="format"></param>
 /// <returns></returns>
 public static PullDeserializer GetPullDeserializer(SimplTypesScope pSimplTypesScope, TranslationContext pTranslationContext, IDeserializationHookStrategy pDeserializationHookStrategy, Format format)
 {
     switch (format)
     {
         case Format.Xml:
             return new XmlPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy);
         case Format.Json:
             return new JsonPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy);
         case Format.Bibtex:
             throw new SimplTranslationException("bibtex serialization is not supported");
         case Format.Tlv:
             return new TlvPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy);
         default:
             throw new SimplTranslationException(format + "format not supported");
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="inputSimplTypesScope"></param>
 /// <param name="inputContext"></param>
 /// <param name="deserializationHookStrategy"></param>
 protected StringPullDeserializer(SimplTypesScope inputSimplTypesScope, TranslationContext inputContext, IDeserializationHookStrategy deserializationHookStrategy)
     : base(inputSimplTypesScope, inputContext, deserializationHookStrategy)
 {
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputSimplTypesScope"></param>
 /// <param name="inputContext"></param>
 /// <param name="deserializationHookStrategy"></param>
 protected BinaryPullDeserializer(SimplTypesScope inputSimplTypesScope, TranslationContext inputContext,
     IDeserializationHookStrategy deserializationHookStrategy)
     : base(inputSimplTypesScope, inputContext, deserializationHookStrategy)
 {
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="inputString"></param>
        /// <param name="translationContext"></param>
        /// <param name="deserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public Object Deserialize(String inputString, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, StringFormat format)
        {
            StringPullDeserializer pullDeserializer = PullDeserializer.GetStringDeserializer(this, translationContext,
                                                                                             deserializationHookStrategy,
                                                                                             format);

            return pullDeserializer.Parse(inputString);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputStream"></param>
 /// <param name="translationContext"></param>
 /// <param name="deserializationHookStrategy"></param>
 /// <param name="format"></param>
 /// <returns></returns>
 public object Deserialize(Stream inputStream, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, Format format)
 {
     PullDeserializer pullDeserializer = PullDeserializer.GetPullDeserializer(this, translationContext,
                                                                              deserializationHookStrategy, format);
     return pullDeserializer.Parse(inputStream);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="file"></param>
        /// <param name="translationContext"></param>
        /// <param name="deserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public async Task<object> Deserialize(object file, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, Format format, Encoding encoding = null)
        {
            if (encoding == null)
                encoding = Encoding.UTF8;

            Stream readStream = await FundamentalPlatformSpecifics.Get().OpenFileReadStream(file, encoding);
            return Deserialize(readStream, translationContext, deserializationHookStrategy, format);
        }
        public async Task<object> DeserializeUri(ParsedUri uri, Format format = Format.Xml, TranslationContext context = null, IDeserializationHookStrategy deserializationHookStrategy = null)
        {
            object result = null;
            
            var request = WebRequest.Create(uri);
            if (request != null)
            {
                WebResponse response = await request.GetResponseAsync();
                result = Deserialize(response.GetResponseStream(), context, deserializationHookStrategy, format);
            }

            return result;
        }
 //        private String test;
 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputSimplTypesScope"></param>
 /// <param name="inputContext"></param>
 /// <param name="deserializationHookStrategy"></param>
 public JsonPullDeserializer(SimplTypesScope inputSimplTypesScope, TranslationContext inputContext,
     IDeserializationHookStrategy deserializationHookStrategy)
     : base(inputSimplTypesScope, inputContext, deserializationHookStrategy)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSimplTypesScope"></param>
        /// <param name="pTranslationContext"></param>
        /// <param name="pDeserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static PullDeserializer GetPullDeserializer(SimplTypesScope pSimplTypesScope, TranslationContext pTranslationContext, IDeserializationHookStrategy pDeserializationHookStrategy, Format format)
        {
            switch (format)
            {
            case Format.Xml:
                return(new XmlPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy));

            case Format.Json:
                return(new JsonPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy));

            case Format.Bibtex:
                throw new SimplTranslationException("bibtex serialization is not supported");

            case Format.Tlv:
                return(new TlvPullDeserializer(pSimplTypesScope, pTranslationContext, pDeserializationHookStrategy));

            default:
                throw new SimplTranslationException(format + "format not supported");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputString"></param>
        /// <param name="translationContext"></param>
        /// <param name="deserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public Object Deserialize(String inputString, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, StringFormat format)
        {
            StringPullDeserializer pullDeserializer = PullDeserializer.GetStringDeserializer(this, translationContext,
                                                                                             deserializationHookStrategy,
                                                                                             format);

            return(pullDeserializer.Parse(inputString));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputStream"></param>
        /// <param name="translationContext"></param>
        /// <param name="deserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public object Deserialize(Stream inputStream, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, Format format)
        {
            PullDeserializer pullDeserializer = PullDeserializer.GetPullDeserializer(this, translationContext,
                                                                                     deserializationHookStrategy, format);

            return(pullDeserializer.Parse(inputStream));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <param name="translationContext"></param>
        /// <param name="deserializationHookStrategy"></param>
        /// <param name="format"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public async Task <object> Deserialize(object file, TranslationContext translationContext, IDeserializationHookStrategy deserializationHookStrategy, Format format, Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }

            Stream readStream = await FundamentalPlatformSpecifics.Get().OpenFileReadStream(file, encoding);

            return(Deserialize(readStream, translationContext, deserializationHookStrategy, format));
        }
        public async Task <object> DeserializeUri(ParsedUri uri, Format format = Format.Xml, TranslationContext context = null, IDeserializationHookStrategy deserializationHookStrategy = null)
        {
            object result = null;

            var request = WebRequest.Create(uri);

            if (request != null)
            {
                WebResponse response = await request.GetResponseAsync();

                result = Deserialize(response.GetResponseStream(), context, deserializationHookStrategy, format);
            }

            return(result);
        }