Commits

Inside Zhou  committed e816ef7

让Linq扩展中的Contains可以使用谓词函数。

  • Participants
  • Parent commits 9555ba8

Comments (0)

Files changed (2)

File Inside.Util.csproj

   <ItemGroup>
     <Compile Include="ByteExtension.cs" />
     <Compile Include="DyObj.cs" />
+    <Compile Include="LinqExtension.cs" />
     <Compile Include="ListExtension.cs" />
     <Compile Include="Json\ByteArrayConverter.cs" />
     <Compile Include="Json\DBNullConverter.cs" />

File LinqExtension.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Inside.Util {
+	public static class LinqExtension {
+		public static bool Contains<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
+			foreach(var item in source) {
+				if(predicate(item)) {
+					return true;
+				}
+			}
+
+			return false;
+		}
+	}
+}