Example #1
0
        public override K GetSource(string dataUrl, T settings)
        {
            string url      = settings.ParameterizedString(dataUrl);
            string response = DataRetrieval.DataFromUrl(url, settings.AcceptHeader, logger).Result;

            if (string.IsNullOrWhiteSpace(response))
            {
                return(null);
            }

            K source = null;

            try
            {
                using (StringReader reader = new StringReader(response))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(K));
                    source = (K)serializer.Deserialize(reader);
                }
            }
            catch (Exception e)
            {
                logger.Exception(e);
                return(null);
            }
            return(source);
        }
Example #2
0
        public override K GetSource(string dataUrl, T settings)
        {
            string url      = settings.ParameterizedString(dataUrl);
            string response = DataRetrieval.DataFromUrl(url, settings.AcceptHeader, logger).Result;

            if (string.IsNullOrWhiteSpace(response))
            {
                return(null);
            }
            XDocument doc = null;

            try
            {
                doc = XDocument.Parse(response);
            }
            catch (Exception e)
            {
                logger.Exception(e);
                return(null);
            }
            return(doc as K);
        }
        public override K GetSource(string dataUrl, T settings)
        {
            string url      = settings.ParameterizedString(dataUrl);
            string response = DataRetrieval.DataFromUrl(url, settings.AcceptHeader, logger).Result;

            if (string.IsNullOrWhiteSpace(response))
            {
                return(null);
            }
            JObject json = null;

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(response);
            }
            catch (Exception e)
            {
                logger.Exception(e);
                return(null);
            }
            return(json as K);
        }