Skip to content

Commit

Permalink
* Add: DB_Attributes.TableNameAttribute
Browse files Browse the repository at this point in the history
 * Add: EnumerableExtensions
  • Loading branch information
ZeProgFactory committed Sep 5, 2019
1 parent 4726d62 commit 3cfab81
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Basics for .Net ( .Net Standard 2.0 )
[ ] ...

## Changelog
### Version 1.1.10 - 09/2019
* Add: DB_Attributes.TableNameAttribute
* Add: EnumerableExtensions

### Version 1.1.9 - 08/2019
* NameValue: override string ToString()
* Open source ...
Expand Down
56 changes: 56 additions & 0 deletions Sources/CS/EnumerableExtensions.cs
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
}
8 changes: 8 additions & 0 deletions Sources/DBSQL/DB_SQL_Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,13 @@ public MaxLengthAttribute(int Length)
{
}
}

[AttributeUsage(AttributeTargets.Class)]
public class TableNameAttribute : Attribute
{
public TableNameAttribute(string TableName)
{
}
}
}
}

0 comments on commit 3cfab81

Please sign in to comment.