public long ForceSeek(long offset, SeekOrigin origin) { long newOffset; switch (origin) { case SeekOrigin.Begin: newOffset = offset; break; case SeekOrigin.Current: newOffset = this.currentOffset + offset; break; case SeekOrigin.End: newOffset = this.Length + offset; break; default: CommonUtility.ArgumentOutOfRange("origin", origin); throw new ArgumentOutOfRangeException(); } CommonUtility.AssertInBounds("offset", newOffset, 0, this.Length); this.currentOffset = (int)newOffset; return(this.currentOffset); }
/// <summary> /// Parses the snapshot time. /// </summary> /// <param name="snapshot">The snapshot time.</param> /// <returns>The parsed snapshot time.</returns> internal static DateTimeOffset ParseSnapshotTime(string snapshot) { DateTimeOffset snapshotTime; if (!DateTimeOffset.TryParse( snapshot, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out snapshotTime)) { CommonUtility.ArgumentOutOfRange("snapshot", snapshot); } return(snapshotTime); }
/// <summary> /// Determines which location can the listing command target by looking at the /// continuation token. /// </summary> /// <param name="token">Continuation token</param> /// <returns>Location mode</returns> internal static CommandLocationMode GetListingLocationMode(IContinuationToken token) { if ((token != null) && token.TargetLocation.HasValue) { switch (token.TargetLocation.Value) { case StorageLocation.Primary: return(CommandLocationMode.PrimaryOnly); case StorageLocation.Secondary: return(CommandLocationMode.SecondaryOnly); default: CommonUtility.ArgumentOutOfRange("TargetLocation", token.TargetLocation.Value); break; } } return(CommandLocationMode.PrimaryOrSecondary); }