Skip to content

Commit 3cfab81

Browse files
committed
* Add: DB_Attributes.TableNameAttribute
* Add: EnumerableExtensions
1 parent 4726d62 commit 3cfab81

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Basics for .Net ( .Net Standard 2.0 )
1313
[ ] ...
1414

1515
## Changelog
16+
### Version 1.1.10 - 09/2019
17+
* Add: DB_Attributes.TableNameAttribute
18+
* Add: EnumerableExtensions
19+
1620
### Version 1.1.9 - 08/2019
1721
* NameValue: override string ToString()
1822
* Open source ...

Sources/CS/EnumerableExtensions.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+

2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Collections.Specialized;
6+
using System.Data;
7+
using System.Diagnostics;
8+
using System.Linq;
9+
using System.Reflection;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
13+
#if XF
14+
using Xamarin.Forms;
15+
#endif
16+
17+
public static class EnumerableExtensions
18+
{
19+
/// <summary>
20+
/// Returns the index of the specified object in the collection.
21+
/// </summary>
22+
/// <param name="self">The self.</param>
23+
/// <param name="obj">The object.</param>
24+
/// <returns>If found returns index otherwise -1</returns>
25+
public static int IndexOf(this IEnumerable self, object obj)
26+
{
27+
int index = -1;
28+
29+
var enumerator = self.GetEnumerator();
30+
enumerator.Reset();
31+
int i = 0;
32+
33+
while (enumerator.MoveNext())
34+
{
35+
if (enumerator.Current.Equals(obj))
36+
{
37+
index = i;
38+
break;
39+
}
40+
41+
i++;
42+
}
43+
44+
return index;
45+
}
46+
47+
#if !NETSTANDARD1_2 && !NETSTANDARD1_3 && !NETSTANDARD1_4
48+
public static IEnumerable<DataRow> EnumerateRows(this DataTable table)
49+
{
50+
foreach (DataRow row in table.Rows)
51+
{
52+
yield return row;
53+
}
54+
}
55+
#endif
56+
}

Sources/DBSQL/DB_SQL_Attributes.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,13 @@ public MaxLengthAttribute(int Length)
3737
{
3838
}
3939
}
40+
41+
[AttributeUsage(AttributeTargets.Class)]
42+
public class TableNameAttribute : Attribute
43+
{
44+
public TableNameAttribute(string TableName)
45+
{
46+
}
47+
}
4048
}
4149
}

0 commit comments

Comments
 (0)