示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="relativeURL"></param>
        /// <param name="pComplexity"></param>
        /// <param name="count">Max items to load from CSV</param>
        /// <param name="PropNames">Mapping between CSV columns and T members (optional)</param>
        /// <returns></returns>
        private IEnumerable <T> CallCsvWS <T>(string relativeURL, RequestComplexity pComplexity, int count, params string[] PropNames) where T : new()
        {
            var requestUrl = _CurrentConnection.EndsWith("/") ? _CurrentConnection.Substring(0, _CurrentConnection.Length - 1) : _CurrentConnection;

            requestUrl += "/";
            requestUrl += relativeURL.StartsWith("/") ? relativeURL.Substring(1) : relativeURL;

            var csvString = _Client.DownloadCsvString(requestUrl, pComplexity);

            var serializer = new CsvSerializer <T>();

            return(serializer.ReadObjects(csvString, count, PropNames));
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="relativeURL"></param>
        /// <param name="pComplexity"></param>
        /// <param name="count">Max items to load from CSV</param>
        /// <param name="PropNames">Mapping between CSV columns and T members (optional)</param>
        /// <returns></returns>
        private IEnumerable <T> CallCsvWS <T>(string relativeURL, RequestComplexity pComplexity, int count, params string[] PropNames) where T : new()
        {
            var requestUrl = _CurrentConnection.EndsWith("/") ? _CurrentConnection.Substring(0, _CurrentConnection.Length - 1) : _CurrentConnection;

            requestUrl += "/";
            requestUrl += relativeURL.StartsWith("/") ? relativeURL.Substring(1) : relativeURL;

            try
            {
                if (_Client.GetCookieContainer().Count > 0)
                {
                    _Client.RemoveAuthenticationHeaders(CurrentApiKey);
                }
                var csvString  = _Client.DownloadCsvString(requestUrl, pComplexity);
                var serializer = new CsvSerializer <T>();
                return(serializer.ReadObjects(csvString, count, PropNames));
            }
            catch (WebException e)
            {
                LogHelper.Instance.LogError(e.Message);
                return(null);
            }
        }