当前位置: 首页>>代码示例>>C#>>正文


C# SeekOrigin.ToString方法代码示例

本文整理汇总了C#中SeekOrigin.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SeekOrigin.ToString方法的具体用法?C# SeekOrigin.ToString怎么用?C# SeekOrigin.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SeekOrigin的用法示例。


在下文中一共展示了SeekOrigin.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Seek

 public override long Seek(long offset, SeekOrigin origin)
 {
     switch(origin)
     {
         case SeekOrigin.Begin:
             Position = offset;
             break;
         case SeekOrigin.End:
             Position = _bufferPool.Length + offset;
             break;
         case SeekOrigin.Current:
             Position = _position + offset;
             break;
         default:
             throw new Exception("Unknown SeekOrigin: " + origin.ToString());
     }
     return Position;
 }
开发者ID:jpierson,项目名称:EventStore,代码行数:18,代码来源:BufferPoolStream.cs

示例2: SeekInternal

        /// <summary>
        /// Perform the actual seek on the stream. Report errors.
        /// </summary>
        /// <param name="offset">New position in the stream.</param>
        /// <param name="current">Current position in the stream.</param>
        /// <param name="whence">Where to count from.</param>
        /// <returns><c>true</c> if successful</returns>
        /// <exception cref="PhpException">In case that Seek is not supported by this stream type.</exception>
        internal bool SeekInternal(int offset, int current, SeekOrigin whence)
        {
            try
            {
                if (!CanSeek)
                {
                    PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Seek");
                    return false;
                }

                if (!RawSeek(offset, whence)) return false;
                int expectedOffset = 0, absoluteOffset = RawTell();

                switch (whence)
                {
                    case SeekOrigin.Begin:
                        expectedOffset = offset;
                        break;
                    case SeekOrigin.Current:
                        expectedOffset = current + offset;
                        break;
                    case SeekOrigin.End:
                        expectedOffset = RawLength() + offset;
                        break;
                    default:
                        PhpException.Throw(PhpError.Warning, ErrResources.invalid_argument_value, "whence", whence.ToString());
                        return false;
                }

                readOffset = writeOffset = absoluteOffset;

                // No data should be buffered when seeking the underlying stream!
                Debug.Assert(readBuffers == null);
                Debug.Assert(writeBuffer == null || writePosition == 0);
                readPosition = writePosition = 0;

                // EX: This is inaccurate, but there is no better information avalable (w/o processing the whole stream)
                readFilteredCount = readOffset;
                writeFilteredCount = readOffset;

                return absoluteOffset == expectedOffset;
                // Seek is successful if the two values match.
            }
            catch (System.Exception)
            {
                PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Seek");
                return false;
            }
        }
开发者ID:iolevel,项目名称:peachpie,代码行数:57,代码来源:PhpStream.cs

示例3: Seek

        public override long Seek(long offset, SeekOrigin origin)
        {
            long new_offset = ostream.Position + offset; // SeekOrigin.Current

            switch (origin) {
                case SeekOrigin.Begin:
                    new_offset = os_offset + offset;
                    goto case SeekOrigin.Current;
                case SeekOrigin.End:
                    new_offset = os_offset + os_length + offset;
                    goto case SeekOrigin.Current;
                case SeekOrigin.Current:
                    if ((new_offset < os_offset) || (new_offset >= (os_offset + os_length))) {
                        throw new Exception(
                            "OffsetStream.Seek() outside offset stream limits" +
                            String.Format(", parms({0},{1})",offset,origin.ToString()) +
                            String.Format(", new_offset({0}) os_offset({1}) os_length({2})", new_offset, os_offset,os_length));
                    }
                    return ostream.Seek(new_offset, SeekOrigin.Begin) - os_offset;
                default:
                    throw new Exception("unknown SeekOrigin value" + origin.ToString());
            }
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:23,代码来源:OffsetStream.cs

示例4: Seek

 public override long Seek(long offset, SeekOrigin origin)
 {
     FileSystemHelpers.Debug("FatStream.Seek", "aOffset = ", offset, ", origin = ", origin.ToString());
     throw new NotImplementedException();
 }
开发者ID:rebizu,项目名称:Cosmos,代码行数:5,代码来源:FatStream.cs

示例5: Seek

        public override long Seek(long offset, SeekOrigin origin)
        {
            long num = this._originalStream.Position + offset;
            switch (origin)
            {
                case SeekOrigin.Begin:
                    num = this._os_originalOffset + offset;
                    break;

                case SeekOrigin.Current:
                    break;

                case SeekOrigin.End:
                    if (offset > 0L)
                    {
                        throw new Exception("OffsetStream.Seek(offset,SeekOrigin.End) outside offset stream limits");
                    }
                    num = (this._os_originalOffset + this._of_length) + offset;
                    break;

                default:
                    throw new Exception("unknown SeekOrigin value" + origin.ToString());
            }
            if ((num < this._os_originalOffset) || (num >= (this._os_originalOffset + this._of_length)))
            {
                throw new Exception("OffsetStream.Seek() outside offset stream limits" + string.Format(", parms({0},{1})", offset, origin.ToString()) + string.Format(", new_offset({0}) os_offset({1}) os_length({2})", num, this._os_originalOffset, this._of_length));
            }
            return (this._originalStream.Seek(num, SeekOrigin.Begin) - this._os_originalOffset);
        }
开发者ID:RainsSoft,项目名称:sharpcompress,代码行数:29,代码来源:OffsetStream.cs

示例6: InvalidSeekOrigin

 internal static Exception InvalidSeekOrigin(SeekOrigin origin)
 {
     return Argument(System.Data.OracleClient.Res.GetString("ADP_InvalidSeekOrigin", new object[] { origin.ToString() }));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:ADP.cs

示例7: Seek

			public override long Seek(long offset, SeekOrigin origin)
			{
				if ((this.fileShare & FileShare.Write) != FileShare.Write)
				{
					switch (origin)
					{
						case SeekOrigin.Begin:
							if (this.position == offset)
							{
								return this.position;
							}
							break;
						case SeekOrigin.Current:
							if (offset == 0)
							{
								return this.position;
							}
							break;
					}
				}

				StabilizeClientState();

				var response = this.client.SendCommand(1, "seek -o={0} \"{1}\"", origin.ToString().ToLower(), offset).ProcessError();

				this.position = Convert.ToInt64(response.ResponseTuples["position"]);
				this.length = Convert.ToInt64(response.ResponseTuples["length"]);
				
				this.client.ReadReady();

				return this.position;
			}
开发者ID:Euphrates-Media,项目名称:Platform.VirtualFileSystem,代码行数:32,代码来源:TextRandomAccessNetworkFileSystemStream.cs


注:本文中的SeekOrigin.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。