Customer IEnuramble Extension
public static class IEnurambleExtension
{
public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>(); foreach (TSource element in source)
if (keys.Add(keySelector(element)))
yield return element;
} public static IEnumerable<int> DistinctByReturnIndexes<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>();
int i = ;
foreach (TSource element in source)
{
if (!keys.Add(keySelector(element)))
yield return i;
i++;
}
} public static int FirstContainsWithIndex<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
return i;
i++;
} return -;
} public static IEnumerable<int> ContainsReturnIndexes<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
yield return i;
i++;
}
} public static void Print<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
foreach (TSource element in source)
Console.WriteLine(keySelector(element));
}
}
Customer IEnuramble Extension的更多相关文章
- Extension Method[下篇]
四.Extension Method的本质 通过上面一节的介绍,我们知道了在C#中如何去定义一个Extension Method:它是定义在一个Static class中的.第一个Parameter标 ...
- SAP Hybris Commerce启用customer coupon的前提条件
今天在工作中,我发现一个问题:在SAP帮助文档里,backoffice coupon 维护界面有个 Customer Assignment的区域: 而我工作的Hybris服务器上的backoffice ...
- 如何把SAP Kyma和SAP Cloud for Customer连接起来
首先进入SAP Cloud for Customer的Administration的工作中心,打开General Settings视图,进入Event Notification配置UI: 新建一个C4 ...
- EFCore之SQL扩展组件BeetleX.EFCore.Extension
EFCore是.NETCore团队开发的一个ORM组件,但这个组件在执行传统SQL的时候并不方便,因此BeetleX.EFCore.Extension的设计目的是让EFCore执行传 ...
- Windbg Extension NetExt 使用指南 【2】 ---- NetExt 的基本命令介绍
摘要 : 本章节介绍NetExt常用的命令. 并且对SOS进行一些对比. NetExt的帮助 要想玩好NetExt, 入门就得看帮助. 看NetExt的帮助可以调用!whelp 命令. 这样hi列举出 ...
- Windbg Extension NetExt 使用指南 【1】 ---- NetExt 介绍
摘要 : 在使用WINDBG做debugging的时候,需要一个好的工具帮助进行数据分析. 最常见的extension包括SOS, PSSCOR. NetExt则是另外一种提供了丰富命令功能的deb ...
- 「译」JUnit 5 系列:扩展模型(Extension Model)
原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...
- PHPmailer关于Extension missing: openssl报错的解决
最近在写一个网页的时候,需要用到PHPmailer来发送邮件,按照官网上给出的demo写出一个例子,却报错Extension missing: openssl 最后发现需要修改php.ini中的配置: ...
- 研究Extension和Category的一个例子
Category: 1. 无法添加实例变量 2.将类的实现分散到多个不同文件或多个不同框架中. Extension: 1. 可以添加实例变量 注: 如果Category的头文件中也使用Extensio ...
随机推荐
- iOS 开发中的CGFloat,CGPoint,CGSize和CGRect
CGGeometry类定义几何元素的结构和操作集合元素的函数 1. 数据类型 CGFloat: 浮点值的基本类型 CGPoint: 表示一个二维坐标系中的点 CGSize: 表示一个矩形的宽度和高度 ...
- 从0开始学Swift笔记整理(一)
Swift 是一种适用于 iOS 和 OS X 应用的全新编程语言,它建立在最好的 C 和 Objective-C 语言之上,并且没有 C 语言的兼容性限制.Swift 采用安全的编程模式,增加了现代 ...
- [Orchard] 通过指定RouteData设置Pager的链接地址
Orchard 中的Pager是一个很方便的用来分页的Shape, 但默认情况下,它是使用当前Action的地址作为链接地址,如果分页的数据要是由别的Action提供时,这样的分页链接就不对了,其实它 ...
- [ACM_水题] UVA 11729 Commando War [不可同时交代任务 可同时执行 最短完成全部时间 贪心]
There is a war and it doesn't look very promising for your country. Now it's time to act. You have a ...
- Web API 简单示例
一.RESTful和Web API Representational State Transfer (REST) is a software architecture style consisting ...
- 如何使用Coded UI Test对Webpage进行自动化测试
在Visual Studio中,Coded UI Test已经不是什么新特性了,较早版本的Visual Studio中就已经有这个东东了.它主要用来帮助自动化测试工程师和开发人员确保程序在UI方面没有 ...
- [BTS] Can't update the assembly.
Error Message In BizTalk =================================== Failed to add resources to application. ...
- centos安装firefox flash插件
centos下的firefox flash插件默认不是最新版的,安装过程如下: 将安装地址添加到repolist中 sudo yum -y install http://linuxdownload.a ...
- CentOS挂载NTFS移动硬盘
CentOS操作系统默认无法挂在NTFS格式的移动硬盘,解决方案之一为使用ntfs-3g挂在: 1. 在其官网上下载安装包: http://www.tuxera.com/community/open- ...
- textarea内部换行实现
当在使用textarea的时候,有一次需求,需要做到自定义换行,而不是通过textarea定宽来自动换行,其实在html中可以直接通过<br/>来换行,同时也想到用\n来实现换行,其结果是 ...