Пример #1
0
        public ContentRangeParser(RangeUnitRegistry units)
        {
            if (units == null)
            {
                throw new ArgumentNullException("units");
            }

            this.units = units;
        }
Пример #2
0
        public RangeUnitRegistry Merge(RangeUnitRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException("registry");
            }

            var mergedUnits = this.Concat(registry);

            if (mergedUnits.GroupBy(unit => unit.Name).Any(group => group.Count() > 1))
            {
                throw new ArgumentException("result contains duplicates");
            }

            return(new RangeUnitRegistry(mergedUnits));
        }
Пример #3
0
        public static Range GetRange(this HttpRequestBase request, RangeUnitRegistry units)
        {
            if (units == null)
            {
                throw new ArgumentNullException("units");
            }

            var value = request.Headers[RangeHeaders.RANGE];

            if (value == null)
            {
                return(null);
            }

            try
            {
                return(new HeaderReader <Range>(new RangeParser(RangeUnitRegistry.Default)).Read(value));
            }
            catch (ParsingException)
            {
                return(null);
            }
        }