-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add: DB_Attributes.TableNameAttribute
* Add: EnumerableExtensions
- Loading branch information
1 parent
4726d62
commit 3cfab81
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
| ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
#if XF | ||
using Xamarin.Forms; | ||
#endif | ||
|
||
public static class EnumerableExtensions | ||
{ | ||
/// <summary> | ||
/// Returns the index of the specified object in the collection. | ||
/// </summary> | ||
/// <param name="self">The self.</param> | ||
/// <param name="obj">The object.</param> | ||
/// <returns>If found returns index otherwise -1</returns> | ||
public static int IndexOf(this IEnumerable self, object obj) | ||
{ | ||
int index = -1; | ||
|
||
var enumerator = self.GetEnumerator(); | ||
enumerator.Reset(); | ||
int i = 0; | ||
|
||
while (enumerator.MoveNext()) | ||
{ | ||
if (enumerator.Current.Equals(obj)) | ||
{ | ||
index = i; | ||
break; | ||
} | ||
|
||
i++; | ||
} | ||
|
||
return index; | ||
} | ||
|
||
#if !NETSTANDARD1_2 && !NETSTANDARD1_3 && !NETSTANDARD1_4 | ||
public static IEnumerable<DataRow> EnumerateRows(this DataTable table) | ||
{ | ||
foreach (DataRow row in table.Rows) | ||
{ | ||
yield return row; | ||
} | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters