本文整理汇总了C#中ObservableCollection.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Distinct方法的具体用法?C# ObservableCollection.Distinct怎么用?C# ObservableCollection.Distinct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Distinct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Result_is_updated_after_Move
public void Result_is_updated_after_Move()
{
var subject = new ObservableCollection<int>(new [] { 10, 11, 12, 11, 12, 10, 12, 17 });
var result = subject.ToQueryable().Distinct().ToObservable();
var expected = subject.Distinct();
Assert.IsInstanceOfType(result, typeof(IQueryableObservableCollection<int>));
var events = new Queue<NotifyCollectionChangedEventArgs>();
result.CollectionChanged += (s, e) => events.Enqueue(e);
subject.Move(4, 7);
expected = subject.Distinct();
EnumerableAssert.AreEqual(result, expected);
Assert.AreEqual(0, events.Count);
subject.Move(3, 0);
expected = subject.Distinct();
EnumerableAssert.AreEqual(result, expected);
Assert.AreEqual(NotifyCollectionChangedAction.Move, events.Dequeue().Action);
subject.Move(2, 1);
expected = subject.Distinct();
EnumerableAssert.AreEqual(result, expected);
Assert.AreEqual(0, events.Count);
subject.Move(5, 1);
expected = subject.Distinct();
EnumerableAssert.AreEqual(result, expected);
Assert.AreEqual(NotifyCollectionChangedAction.Move, events.Dequeue().Action);
}
示例2: updateVillageNameList
public ObservableCollection<string> updateVillageNameList(string villageLayerName, string villageLayerFieldName, AxMapControl mapControl)
{
ILayer baseLayer = GisUtil.getLayerByName(villageLayerName, mapControl);
IFeatureLayer fBaseLayer = baseLayer as IFeatureLayer;
if (fBaseLayer == null)
return null;
IFeatureClass fBaseFeatureClass = fBaseLayer.FeatureClass;
ObservableCollection<string> villageNameList = new ObservableCollection<string>(GisUtil.GetValueListFromFeatureClass(fBaseFeatureClass, villageLayerFieldName));
if (villageNameList == null)
return null;
//在list中去除重复
villageNameList = new ObservableCollection<string>(villageNameList.Distinct().ToList<string>());
return villageNameList;
}
示例3: CreateReportSource
protected object CreateReportSource(ObservableCollection<BenchMarkViewModel> source)
{
ObservableCollection<ReportViewModel> report = new ObservableCollection<ReportViewModel>();
IEnumerable<BenchMarkViewModel> noduplicates = source.Distinct(new BenchMarkSymbolComparer());
int nodupsym = 0;
foreach (var product in noduplicates)
nodupsym++;
report.Add(new ReportViewModel()
{
LiveSymbolsTraded = nodupsym
});
return report;
}
示例4: SaveToFile
private Boolean SaveToFile()
{
Run temp;
StringBuilder builder = new StringBuilder();
ObservableCollection<int> periods = new ObservableCollection<int>();
ObservableCollection<int> dutyCycles = new ObservableCollection<int>();
ObservableCollection<int> backgrounds = new ObservableCollection<int>();
try
{
if (SelectedType == 0)
{
builder.AppendLine("Period(ms),Duty Cycle(%),Latency Resolution(ns),Background Size,Missed(pulses),Max Latency(1024th of a period),Max Latency(us),Task Unit Processed(units),");
foreach (Run run in Results)
{
builder.AppendLine(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", run.Period, run.DutyCycle, run.LatencyResolution, run.BackgroundBatchSize, run.PulseMissed, run.LatencyByPeriod, run.LatencyByTime, run.TaskUnitsProcessed));
}
}
else
{
foreach (Run run in Results)
{
periods.Add(run.Period);
dutyCycles.Add(run.DutyCycle);
if (BackGround)
{
backgrounds.Add(run.BackgroundBatchSize);
}
}
periods = new ObservableCollection<int>(periods.Distinct());
dutyCycles = new ObservableCollection<int>(dutyCycles.Distinct());
if (BackGround)
{
backgrounds = new ObservableCollection<int>(backgrounds.Distinct());
}
do
{
if (BackGround)
{
builder.AppendLine("===========================================================================================================================================================");
builder.AppendFormat("Background size: {0}\n", backgrounds[0]);
builder.AppendLine("===========================================================================================================================================================");
}
builder.AppendLine("Missed Pulses");
builder.Append("v Duty Cycle\\Period->,");
foreach (int i in periods)
{
builder.AppendFormat("{0},", i);
}
builder.AppendLine("");
foreach (int i in dutyCycles)
{
builder.AppendFormat("{0},", i);
foreach (int j in periods)
{
temp = Results.Where(item => item.BackgroundBatchSize == backgrounds[0]).SingleOrDefault(item => item.Period == j && item.DutyCycle == i);
if (temp != null)
builder.AppendFormat("{0},", temp.PulseMissed);
}
builder.AppendLine("");
}
builder.AppendLine("");
builder.AppendLine("");
builder.AppendLine("Max Latency (ms)");
builder.Append("Period->,");
foreach (int i in periods)
{
builder.AppendFormat("{0},", i);
}
builder.AppendLine("");
foreach (int i in dutyCycles)
{
builder.AppendFormat("{0},", i);
foreach (int j in periods)
{
temp = Results.Where(item => item.BackgroundBatchSize == backgrounds[0]).SingleOrDefault(item => item.Period == j && item.DutyCycle == i);
if (temp != null)
builder.AppendFormat("{0},", temp.LatencyByTime);
}
builder.AppendLine("");
}
builder.AppendLine("");
builder.AppendLine("");
builder.AppendLine("Task Unit Processed");
builder.Append("Period->,");
foreach (int i in periods)
{
builder.AppendFormat("{0},", i);
}
builder.AppendLine("");
foreach (int i in dutyCycles)
{
//.........这里部分代码省略.........