本文整理汇总了C#中RangeCollection类的典型用法代码示例。如果您正苦于以下问题:C# RangeCollection类的具体用法?C# RangeCollection怎么用?C# RangeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RangeCollection类属于命名空间,在下文中一共展示了RangeCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergedRanges
public void MergedRanges ()
{
RangeCollection range = new RangeCollection ();
int [] indexes = new int [] { 0, 7, 5, 9, 1, 6, 8, 2, 10, 12 };
_TestRanges (range, indexes);
Assert.AreEqual (3, range.RangeCount);
int i= 0;
foreach (RangeCollection.Range r in range.Ranges) {
switch (i++) {
case 0:
Assert.AreEqual (0, r.Start);
Assert.AreEqual (2, r.End);
break;
case 1:
Assert.AreEqual (5, r.Start);
Assert.AreEqual (10, r.End);
break;
case 2:
Assert.AreEqual (12, r.Start);
Assert.AreEqual (12, r.End);
break;
default:
Assert.Fail ("This should not be reached!");
break;
}
}
}
示例2: ViaSocketWriter
public void ViaSocketWriter()
{
var ranges = new RangeCollection();
var fileStream = new FileStream(@"C:\Users\jgauffin\Downloads\AspNetMVC3ToolsUpdateSetup.exe", FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
ranges.Parse("bytes=0-50000", (int)fileStream.Length);
var stream = new ByteRangeStream(ranges, fileStream);
var job = new StreamSocketWriterJob(stream);
var buffer = new byte[65535];
var args = Substitute.For<SocketAsyncEventArgs>();
args.UserToken.Returns(buffer);
job.Write(args);
while (true)
{
if (job.WriteCompleted(5000))
{
job.Dispose();
break;
}
job.Write(args);
}
}
示例3: Init
//public ObservableCollection<ImageItem> Source = new ObservableCollection<ImageItem>();
public async Task Init()
{
var queryOptions = new QueryOptions(CommonFileQuery.OrderByDate,
new string[] { ".jpg", ".png", ".jpeg", ".bmp" })
{
FolderDepth = FolderDepth.Deep,
IndexerOption = IndexerOption.OnlyUseIndexer,
UserSearchFilter = "System.Kind:=System.Kind#Picture"
};
queryOptions.SetThumbnailPrefetch(ThumbnailMode.SingleItem, 256, ThumbnailOptions.UseCurrentScale);
var _fileQueryResult = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
var files = await _fileQueryResult.GetFilesAsync();
Debug.WriteLine("Count " + files.Count);
var list = new List<ImageItem>();
foreach (var f in files)
{
list.Add(new ImageItem()
{
LocalPath = f.Path
});
}
Source = new RangeCollection(list);
Source.Init();
}
示例4: ItemContainerGenerator
internal ItemContainerGenerator (ItemsControl owner)
{
Cache = new Queue <DependencyObject> ();
ContainerIndexMap = new DoubleKeyedDictionary <DependencyObject, int> ();
ContainerItemMap = new Dictionary <DependencyObject, object> ();
Owner = owner;
RealizedElements = new RangeCollection ();
}
示例5: SingleNumber
public void SingleNumber()
{
var range = new RangeCollection(1, 50);
range.AddRangeSpecifier("5");
RangeCollectionTests.AssertContains(new[] { 5 }, range, "range");
}
示例6: MultipleNumbers
public void MultipleNumbers()
{
var range = new RangeCollection(1, 50);
range.AddRangeSpecifier("5,7,9,5");
RangeCollectionTests.AssertContains(new[] { 5, 7, 9 }, range, "range");
}
示例7: SelectionModel
/// <summary>
/// Represents a <see cref="Model"/> that executes the appropriate selection logic requested by different commands.
/// </summary>
public SelectionModel()
: base(NAME)
{
this.items = new List<object>(0);
this.SelectedItems = new SelectedItemsCollection();
this.selectionMode = SelectionMode.Extended;
this.ranges = new RangeCollection();
}
示例8: Range
public void Range()
{
var range = new RangeCollection(1, 50);
range.AddRangeSpecifier("10-20");
RangeCollectionTests.AssertContains(
new[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }, range, "range");
}
示例9: RangeWithStep
public void RangeWithStep()
{
var range = new RangeCollection(1, 50);
range.AddRangeSpecifier("10-20/3");
RangeCollectionTests.AssertContains(
new[] { 10, 13, 16, 19 }, range, "range");
}
示例10: All
public void All()
{
var range = new RangeCollection(1, 10);
range.AddRangeSpecifier("*");
RangeCollectionTests.AssertContains(
new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, range, "range");
}
示例11: AddCommentsFromXml
private void AddCommentsFromXml()
{
var lst = new List<IRangeID>();
foreach (XmlElement node in CommentXml.SelectNodes("//d:commentList/d:comment", NameSpaceManager))
{
var comment = new ExcelComment(NameSpaceManager, node, new ExcelRangeBase(Worksheet, node.GetAttribute("ref")));
lst.Add(comment);
}
_comments = new RangeCollection(lst);
}
示例12: AddRange
private void AddRange(RangeCollection collection, string specifier, string name)
{
try
{
collection.AddRangeSpecifier(specifier);
}
catch (Exception ex)
{
throw new ArgumentException("Unable to process " + name + " specifier: " + ex.Message, ex);
}
}
示例13: ContainsTest
public void ContainsTest()
{
var c = new RangeCollection();
c.Add(new AddressRange(1, 100));
c.Add(new AddressRange(-10, -1));
for (var i = -15; i < 120; i++)
{
var shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
Assert.Equal(shouldContain, c.Contains(new AddressRange(i, i)));
}
}
示例14: ByteRangeStream
/// <summary>
/// Initializes a new instance of the <see cref="ByteRangeStream" /> class.
/// </summary>
/// <param name="ranges">The HTTP range header contents.</param>
/// <param name="innerStream">The inner stream which we should transfer a range from. The stream is owned by this class.</param>
public ByteRangeStream(RangeCollection ranges, Stream innerStream)
{
if (innerStream == null) throw new ArgumentNullException("innerStream");
if (innerStream.Position != 0)
throw new ArgumentException("The stream must be at position 0 for this range class to work",
"innerStream");
if (!innerStream.CanSeek) throw new ArgumentException("Stream must be seekable.", "innerStream");
if (!innerStream.CanRead) throw new ArgumentException("Stream must be readablle", "innerStream");
_ranges = ranges;
_innerStream = innerStream;
}
示例15: LargeSequentialContains
public void LargeSequentialContains ()
{
RangeCollection range = new RangeCollection ();
int i, n = 1000000;
for (i = 0; i < n; i++) {
range.Add (i);
}
for (i = 0; i < n; i++) {
Assert.AreEqual (true, range.Contains (i));
}
}