• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Labeled类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Labeled的典型用法代码示例。如果您正苦于以下问题:C# Labeled类的具体用法?C# Labeled怎么用?C# Labeled使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Labeled类属于命名空间,在下文中一共展示了Labeled类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ILookup_MembersBehaveCorrectly

        public static void ILookup_MembersBehaveCorrectly(Labeled<ParallelQuery<int>> labeled, int count)
        {
            int NonExistentKey = count * 2;
            ILookup<int, int> lookup = labeled.Item.ToLookup(x => x);

            // Count
            Assert.Equal(count, lookup.Count);

            // Contains
            Assert.All(lookup, group => lookup.Contains(group.Key));
            Assert.False(lookup.Contains(NonExistentKey));

            // Indexer
            Assert.All(lookup, group => Assert.Equal(group, lookup[group.Key]));
            Assert.Equal(Enumerable.Empty<int>(), lookup[NonExistentKey]);

            // GetEnumerator
            IEnumerator e1 = ((IEnumerable)lookup).GetEnumerator();
            IEnumerator<IGrouping<int, int>> e2 = lookup.GetEnumerator();
            while (e1.MoveNext())
            {
                e2.MoveNext();
                Assert.Equal(((IGrouping<int,int>)e1.Current).Key, e2.Current.Key);
            }
            Assert.False(e2.MoveNext());
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:26,代码来源:ToLookupTests.cs


示例2: AsSequential_LinqBinding

        public static void AsSequential_LinqBinding(Labeled<ParallelQuery<int>> labeled, int count)
        {
            IEnumerable<int> seq = labeled.Item.AsSequential();

            // The LINQ Cast<T>() retains origin type for ParallelEnumerable  and Partitioner when unordered,
            // (and for all sources when ordered, due to the extra wrapper)
            // although aliased as IEnumerable<T>, so further LINQ calls work as expected.
            // If this test starts failing, update this test, and maybe mention it in release notes.
            Assert.IsNotType<ParallelQuery<int>>(seq.Cast<int>());
            Assert.True(seq.Cast<int>() is ParallelQuery<int>);

            Assert.False(seq.Concat(Enumerable.Range(0, count)) is ParallelQuery<int>);
            Assert.False(seq.DefaultIfEmpty() is ParallelQuery<int>);
            Assert.False(seq.Distinct() is ParallelQuery<int>);
            Assert.False(seq.Except(Enumerable.Range(0, count)) is ParallelQuery<int>);
            Assert.False(seq.GroupBy(x => x) is ParallelQuery<int>);
            Assert.False(seq.GroupJoin(Enumerable.Range(0, count), x => x, y => y, (x, g) => x) is ParallelQuery<int>);
            Assert.False(seq.Intersect(Enumerable.Range(0, count)) is ParallelQuery<int>);
            Assert.False(seq.Join(Enumerable.Range(0, count), x => x, y => y, (x, y) => x) is ParallelQuery<int>);
            Assert.False(seq.OfType<int>() is ParallelQuery<int>);
            Assert.False(seq.OrderBy(x => x) is ParallelQuery<int>);
            Assert.False(seq.OrderByDescending(x => x) is ParallelQuery<int>);
            Assert.False(seq.Reverse() is ParallelQuery<int>);
            Assert.False(seq.Select(x => x) is ParallelQuery<int>);
            Assert.False(seq.SelectMany(x => new[] { x }) is ParallelQuery<int>);
            Assert.False(seq.Skip(count / 2) is ParallelQuery<int>);
            Assert.False(seq.SkipWhile(x => true) is ParallelQuery<int>);
            Assert.False(seq.Take(count / 2) is ParallelQuery<int>);
            Assert.False(seq.TakeWhile(x => true) is ParallelQuery<int>);
            Assert.False(seq.Union(Enumerable.Range(0, count)) is ParallelQuery<int>);
            Assert.False(seq.Where(x => true) is ParallelQuery<int>);
            Assert.False(seq.Zip(Enumerable.Range(0, count), (x, y) => x) is ParallelQuery<int>);
        }
开发者ID:benpye,项目名称:corefx,代码行数:33,代码来源:AsSequentialTests.cs


示例3: Any_AllFalse

 public static void Any_AllFalse(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.False(query.Any(x => !seen.Add(x)));
     seen.AssertComplete();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:AnyTests.cs


示例4: ToList

 public static void ToList(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     int seen = 0;
     Assert.All(query.ToList(), x => Assert.Equal(seen++, x));
     Assert.Equal(count, seen);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:ToListTests.cs


示例5: Distinct_Unordered_NotPipelined

 public static void Distinct_Unordered_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.All(query.Distinct(new ModularCongruenceComparer(count)).ToList(), x => seen.Add(x % count));
     seen.AssertComplete();
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:DistinctTests.cs


示例6: Where_NotPipelined

 public static void Where_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     int seen = -2;
     Assert.All(query.Where(x => x % 2 == 0).ToList(), x => Assert.Equal(seen += 2, x));
     Assert.Equal(count - (count - 1) % 2 - 1, seen);
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:WhereTests.cs


示例7: ForAll

 public static void ForAll(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     query.ForAll<int>(x => seen.Add(x));
     seen.AssertComplete();
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:7,代码来源:ForAllTests.cs


示例8: Cast_Unordered_Valid_NotPipelined

 public static void Cast_Unordered_Valid_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.All(query.Select(x => (object)x).Cast<int>().ToList(), x => seen.Add(x));
     seen.AssertComplete();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:CastTests.cs


示例9: Single_NoMatch

 public static void Single_NoMatch(Labeled<ParallelQuery<int>> labeled, int count, int element)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.Throws<InvalidOperationException>(() => query.Single(x => !seen.Add(x)));
     seen.AssertComplete();
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:SingleSingleOrDefaultTests.cs


示例10: SingleOrDefault_NoMatch

 public static void SingleOrDefault_NoMatch(Labeled<ParallelQuery<int>> labeled, int count, int element)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.Equal(default(int), query.SingleOrDefault(x => !seen.Add(x)));
     seen.AssertComplete();
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:7,代码来源:SingleSingleOrDefaultTests.cs


示例11: Sum_Int_Overflow

 public static void Sum_Int_Overflow(Labeled<ParallelQuery<int>> labeled, int count)
 {
     Functions.AssertThrowsWrapped<OverflowException>(() => labeled.Item.Select(x => x == 0 ? int.MaxValue : x).Sum());
     Functions.AssertThrowsWrapped<OverflowException>(() => labeled.Item.Select(x => x == 0 ? int.MaxValue : (int?)x).Sum());
     Functions.AssertThrowsWrapped<OverflowException>(() => labeled.Item.Sum(x => x == 0 ? int.MinValue : -x));
     Functions.AssertThrowsWrapped<OverflowException>(() => labeled.Item.Sum(x => x == 0 ? int.MinValue : -(int?)x));
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:SumTests.cs


示例12: ToList_OperationCanceledException_PreCanceled

        public static void ToList_OperationCanceledException_PreCanceled(Labeled<ParallelQuery<int>> labeled, int count)
        {
            CancellationTokenSource cs = new CancellationTokenSource();
            cs.Cancel();

            Functions.AssertIsCanceled(cs, () => labeled.Item.WithCancellation(cs.Token).ToList());
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:ToListTests.cs


示例13: ToArray_Unordered

 public static void ToArray_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.All(query.ToArray(), x => seen.Add(x));
     seen.AssertComplete();
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:ToArrayTests.cs


示例14: AsEnumerable

 public static void AsEnumerable(Labeled<ParallelQuery<int>> labeled, int count)
 {
     int seen = 0;
     IEnumerable<int> enumerable = labeled.Item.AsEnumerable();
     Assert.All(enumerable, x => Assert.Equal(seen++, x));
     Assert.Equal(count, seen);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:AsEnumerableTests.cs


示例15: GetEnumerator_Unordered

        public static void GetEnumerator_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
        {
            IntegerRangeSet seen = new IntegerRangeSet(0, count);
            IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                int current = enumerator.Current;
                seen.Add(current);
                Assert.Equal(current, enumerator.Current);
            }
            seen.AssertComplete();

            if (labeled.ToString().StartsWith("Enumerable.Range") || labeled.ToString().StartsWith("Partitioner"))
            {
                Assert.Throws<NotSupportedException>(() => enumerator.Reset());
            }
            else
            {
                enumerator.Reset();
                seen = new IntegerRangeSet(0, count);
                while (enumerator.MoveNext())
                {
                    Assert.True(seen.Add(enumerator.Current));
                }
                seen.AssertComplete();
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:GetEnumeratorTests.cs


示例16: Contains_OneMatching

 public static void Contains_OneMatching(Labeled<ParallelQuery<int>> labeled, int count, int position)
 {
     ParallelQuery<int> query = labeled.Item;
     Assert.True(query.Contains(position));
     Assert.True(query.Contains(position, null));
     Assert.True(query.Contains(position, new ModularCongruenceComparer(count)));
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:ContainsTests.cs


示例17: GetEnumerator

        public static void GetEnumerator(Labeled<ParallelQuery<int>> labeled, int count)
        {
            int seen = 0;
            IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                int current = enumerator.Current;
                Assert.Equal(seen++, current);
                Assert.Equal(current, enumerator.Current);
            }
            Assert.Equal(count, seen);

            if (labeled.ToString().StartsWith("Enumerable.Range") || labeled.ToString().StartsWith("Partitioner"))
            {
                Assert.Throws<NotSupportedException>(() => enumerator.Reset());
            }
            else
            {
                enumerator.Reset();
                seen = 0;
                while (enumerator.MoveNext())
                {
                    Assert.Equal(seen++, enumerator.Current);
                }
                Assert.Equal(count, seen);
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:GetEnumeratorTests.cs


示例18: Cast_Valid_NotPipelined

 public static void Cast_Valid_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     int seen = 0;
     Assert.All(query.Select(x => (object)x).Cast<int>().ToList(), x => Assert.Equal(seen++, x));
     Assert.Equal(count, seen);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:CastTests.cs


示例19: Reverse_Unordered_NotPipelined

 public static void Reverse_Unordered_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     Assert.All(query.Reverse().ToList(), x => seen.Add(x));
     seen.AssertComplete();
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:7,代码来源:ReverseTests.cs


示例20: Where_Unordered_NotPipelined

 public static void Where_Unordered_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(0, (count + 1) / 2);
     Assert.All(query.Where(x => x % 2 == 0).ToList(), x => seen.Add(x / 2));
     seen.AssertComplete();
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:WhereTests.cs



注:本文中的Labeled类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LabeledOperation类代码示例发布时间:2022-05-24
下一篇:
C# LabelTarget类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap