本文整理汇总了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;
}
示例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;
}
}
示例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());
}
}
示例4: Seek
public override long Seek(long offset, SeekOrigin origin)
{
FileSystemHelpers.Debug("FatStream.Seek", "aOffset = ", offset, ", origin = ", origin.ToString());
throw new NotImplementedException();
}
示例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);
}
示例6: InvalidSeekOrigin
internal static Exception InvalidSeekOrigin(SeekOrigin origin)
{
return Argument(System.Data.OracleClient.Res.GetString("ADP_InvalidSeekOrigin", new object[] { origin.ToString() }));
}
示例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