Ejemplo n.º 1
0
        public IDataReader Find(string contentTypeHeader)
        {
            var type = DataProviderUtility.ParseMediaType(contentTypeHeader);

            var readers = _readersByMime.Where(reader => Regex.Match(type, reader.Key, RegexOptions.Singleline).Success);

            var keyValuePairs = readers as IList <KeyValuePair <string, IDataReader> > ?? readers.ToList();

            return(keyValuePairs.Any() ? keyValuePairs.First().Value : null);
        }
        public IDataReader Find(string contentTypeHeader)
        {
            var type = DataProviderUtility.ParseMediaType(contentTypeHeader);

            var readers = from reader in _readersByMime
                          where Regex.Match(type, reader.Key, RegexOptions.Singleline).Success
                          select reader;

            if (readers.Count() > 0)
            {
                return(readers.First().Value);
            }
            return(null);
        }
        public static IEnumerable <string> ParseHeaders(string accept, string contentType)
        {
            string mime;

            // check for a matching accept type
            foreach (string type in SplitTrim(accept, ','))
            {
                mime = DataProviderUtility.ParseMediaType(type);
                if (!String.IsNullOrEmpty(mime))
                {
                    yield return(mime);
                }
            }

            // fallback on content-type
            mime = DataProviderUtility.ParseMediaType(contentType);
            if (!String.IsNullOrEmpty(mime))
            {
                yield return(mime);
            }
        }