本文整理汇总了C#中RangeCollection类的典型用法代码示例。如果您正苦于以下问题:C# RangeCollection类的具体用法?C# RangeCollection怎么用?C# RangeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RangeCollection类属于命名空间,在下文中一共展示了RangeCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
开发者ID:rubenv,项目名称:tripod,代码行数:29,代码来源:RangeCollectionTests.cs
示例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);
}
}
开发者ID:2594636985,项目名称:griffin.networking,代码行数:28,代码来源:ByteRangeStreamTests.cs
示例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();
}
开发者ID:HppZ,项目名称:UniversalTest,代码行数:27,代码来源:MainController.cs
示例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 ();
}
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:ItemContainerGenerator.cs
示例5: SingleNumber
public void SingleNumber()
{
var range = new RangeCollection(1, 50);
range.AddRangeSpecifier("5");
RangeCollectionTests.AssertContains(new[] { 5 }, range, "range");
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:8,代码来源:RangeCollectionExtensionsTests.cs
示例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");
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:8,代码来源:RangeCollectionExtensionsTests.cs
示例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();
}
开发者ID:guidgets,项目名称:XamlGrid,代码行数:11,代码来源:SelectionModel.cs
示例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");
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:9,代码来源:RangeCollectionExtensionsTests.cs
示例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");
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:9,代码来源:RangeCollectionExtensionsTests.cs
示例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");
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:9,代码来源:RangeCollectionExtensionsTests.cs
示例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);
}
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:10,代码来源:ExcelCommentCollection.cs
示例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);
}
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:11,代码来源:TraditionalJob.cs
示例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)));
}
}
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:11,代码来源:RangeCollectionTests.cs
示例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;
}
开发者ID:2594636985,项目名称:griffin.networking,代码行数:17,代码来源:ByteRangeStream.cs
示例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));
}
}
开发者ID:rubenv,项目名称:tripod,代码行数:13,代码来源:RangeCollectionTests.cs
示例16: ReadOneRangePartially
public void ReadOneRangePartially()
{
var stream = CreateTextStream();
var ranges = new RangeCollection();
ranges.Parse("bytes=0-99", (int)stream.Length);
byte[] target = new byte[100];
var stream2 = new ByteRangeStream(ranges, stream);
stream2.Read(target, 0, 50);
stream2.Read(target, 50, 50);
Assert.Equal(GetString().Substring(0,100), Encoding.ASCII.GetString(target, 0, 100));
}
开发者ID:2594636985,项目名称:griffin.networking,代码行数:13,代码来源:ByteRangeStreamTests.cs
示例17: TraditionalJob
private TraditionalJob(Action jobDelegate)
{
if (jobDelegate == null)
throw new ArgumentNullException("jobDelegate");
this.jobDelegate = jobDelegate;
MinuteRange = new RangeCollection(0, 59);
HourRange = new RangeCollection(0, 23);
DateRange = new RangeCollection(1, 31);
MonthRange = new RangeCollection(1, 12);
DayOfWeekRange = new RangeCollection(0, 6);
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:13,代码来源:TraditionalJob.cs
示例18: ExcelVmlDrawingCommentCollection
internal ExcelVmlDrawingCommentCollection(ExcelPackage pck, ExcelWorksheet ws, Uri uri) :
base(pck, ws,uri)
{
if (uri == null)
{
VmlDrawingXml.LoadXml(CreateVmlDrawings());
_drawings = new RangeCollection(new List<IRangeID>());
}
else
{
AddDrawingsFromXml(ws);
}
}
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:13,代码来源:ExcelVmlDrawingCommentCollection.cs
示例19: AddRangeSpecifier
public static void AddRangeSpecifier(this RangeCollection self, string specifier)
{
if (self == null)
throw new ArgumentNullException("self");
if (specifier == null)
throw new ArgumentNullException("specifier");
string[] list = specifier.Split(',');
RangeCollection staging = new RangeCollection(self.Minimum, self.Maximum);
foreach (string i in list)
{
Match match = rangeRegex.Match(i);
if (!match.Success)
ThrowBadRangeSpecifier(specifier);
if (match.Groups["single"].Success)
{
staging.Add(int.Parse(match.Groups["single"].Value));
}
else
{
int start = self.Minimum;
int end = self.Maximum;
int step = 1;
if (match.Groups["step"].Success)
step = int.Parse(match.Groups["step"].Value);
if (match.Groups["start"].Success)
{
start = int.Parse(match.Groups["start"].Value);
end = int.Parse(match.Groups["end"].Value);
}
if (end < start)
ThrowBadRangeSpecifier(specifier);
for (int j = start; j <= end; j += step)
staging.Add(j);
}
}
foreach (int i in staging)
self.Add(i);
}
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:49,代码来源:RangeCollectionExtensions.cs
示例20: RunTasks
/// <summary>
/// Run Tasks.
/// </summary>
/// <param name="tasksToRun">Tasks to Run.</param>
/// <param name="taskCount">Task Count.</param>
public override void RunTasks(RangeCollection tasksToRun, long taskCount)
{
#if !SILVERLIGHT
using (Process proc = new Process())
{
proc.StartInfo.FileName = ExeName;
proc.StartInfo.Arguments = CommandArgs;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
if (proc.ExitCode > 0)
throw new Exception("Unable to execute " + ExeName + " " + CommandArgs);
}
#endif
}
开发者ID:cpatmoore,项目名称:bio,代码行数:20,代码来源:CommandApp.cs
注:本文中的RangeCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论