Пример #1
0
        internal static MergeOption CheckEnumerationValue(MergeOption value, string parameterName)
        {
            switch (value)
            {
            case MergeOption.AppendOnly:
            case MergeOption.OverwriteChanges:
            case MergeOption.PreserveChanges:
            case MergeOption.NoTracking:
                return(value);

            default:
                throw Error.ArgumentOutOfRange(parameterName);
            }
        }
Пример #2
0
        /// <summary>
        /// Validate HttpStack
        /// </summary>
        /// <param name="value">option to validate</param>
        /// <param name="parameterName">name of the parameter being validated</param>
        /// <exception cref="System.ArgumentOutOfRangeException">if option is not valid</exception>
        /// <returns>option</returns>
        internal static HttpStack CheckEnumerationValue(HttpStack value, string parameterName)
        {
            switch (value)
            {
            case HttpStack.Auto:
#if ASTORIA_LIGHT
            case HttpStack.ClientHttp:
            case HttpStack.XmlHttp:
#endif
                return(value);

            default:
                throw Error.ArgumentOutOfRange(parameterName);
            }
        }
        public override long Seek(long offset, SeekOrigin origin)
        {
            this.AssertOpen();

            if (offset < 0)
            {
                throw Error.ArgumentOutOfRange("offset");
            }

            if (SeekOrigin.Current != origin)
            {
                throw Error.ArgumentOutOfRange("origin");
            }

            if (Int32.MaxValue == offset)
            {
                byte[] buffer = new byte[256];
                while (0 < this.ReadDelimiter(buffer, 0, buffer.Length))
                {
                }
            }
            else if (0 < offset)
            {
                do
                {
                    int count = Math.Min(checked ((int)offset), Math.Min(this.byteLength, this.batchLength));
                    this.totalCount   += count;
                    this.bytePosition += count;
                    this.byteLength   -= count;
                    this.batchLength  -= count;
                    offset            -= count;
                }while ((0 < offset) && (this.batchLength != 0) && this.ReadBuffer());
            }

            Debug.Assert(0 <= this.byteLength, "negative byteLength");
            Debug.Assert(0 <= this.batchLength, "negative batchLength");
            return(0);
        }