Skip to content

Commit

Permalink
Performed lots of clean up
Browse files Browse the repository at this point in the history
- moved every type to its own file
- added logical folders and grouped files into folders so they're easier
to find
- moved some internal types to other namespaces as they were in the
wrong namespace
- added some warnings on sqlclient using code in generic classes.
  • Loading branch information
FransBouma committed Dec 29, 2014
1 parent e2901b9 commit c4985f6
Show file tree
Hide file tree
Showing 67 changed files with 6,613 additions and 5,079 deletions.
34 changes: 34 additions & 0 deletions src/BindingLists/BindingList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Data.Linq.Mapping;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace System.Data.Linq.BindingLists
{
internal static class BindingList
{
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static IBindingList Create<T>(DataContext context, IEnumerable<T> sequence)
{
List<T> list = sequence.ToList();
MetaTable metaTable = context.Services.Model.GetTable(typeof(T));
if(metaTable != null)
{
ITable table = context.GetTable(metaTable.RowType.Type);
Type bindingType = typeof(DataBindingList<>).MakeGenericType(metaTable.RowType.Type);
return (IBindingList)Activator.CreateInstance(bindingType,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
new object[] { list, table }, null
);
}
else
{
return new SortableBindingList<T>(list);
}
}
}
}

21 changes: 2 additions & 19 deletions src/DataBindingList.cs → src/BindingLists/DataBindingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;

namespace System.Data.Linq.Provider {
internal static class BindingList {
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static IBindingList Create<T>(DataContext context, IEnumerable<T> sequence) {
List<T> list = sequence.ToList();
MetaTable metaTable = context.Services.Model.GetTable(typeof(T));
if (metaTable != null) {
ITable table = context.GetTable(metaTable.RowType.Type);
Type bindingType = typeof(DataBindingList<>).MakeGenericType(metaTable.RowType.Type);
return (IBindingList)Activator.CreateInstance(bindingType,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
new object[] { list, table }, null
);
} else {
return new SortableBindingList<T>(list);
}
}
}

namespace System.Data.Linq.BindingLists
{
internal class DataBindingList<TEntity> : SortableBindingList<TEntity>
where TEntity : class {
private Table<TEntity> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.Reflection;
using System.Diagnostics.CodeAnalysis;

namespace System.Data.Linq {
namespace System.Data.Linq.BindingLists
{
internal class EntitySetBindingList<TEntity> : SortableBindingList<TEntity>
where TEntity : class {
private EntitySet<TEntity> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Reflection;
using System.Xml.Linq;

namespace System.Data.Linq
namespace System.Data.Linq.BindingLists
{
/// <summary>
/// Adds sorting feature to BindingList<T>
Expand Down
Loading

0 comments on commit c4985f6

Please sign in to comment.