Skip to content

Commit

Permalink
заинтернил
Browse files Browse the repository at this point in the history
  • Loading branch information
gusev_p committed Jun 28, 2016
1 parent 09617fc commit 0873ee8
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Simple1C/Impl/Com/DispatchObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Simple1C.Impl.Com
{
public class DispatchObject
internal class DispatchObject
{
private readonly object comObject;

Expand Down
12 changes: 6 additions & 6 deletions Simple1C/Impl/ComDataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ internal class ComDataContext : IDataContext
private readonly EnumMapper enumMapper;
private readonly ComObjectMapper comObjectMapper;
private readonly IQueryProvider queryProvider;
private readonly TypeMapper typeMapper;
private MetadataAccessor metadataAccessor;
private readonly TypeRegistry typeRegistry;
private readonly MetadataAccessor metadataAccessor;

public ComDataContext(object globalContext, Assembly mappingsAssembly)
{
this.globalContext = new GlobalContext(globalContext);
enumMapper = new EnumMapper(this.globalContext);
typeMapper = new TypeMapper(mappingsAssembly);
comObjectMapper = new ComObjectMapper(enumMapper, typeMapper);
queryProvider = RelinqHelpers.CreateQueryProvider(typeMapper, Execute);
typeRegistry = new TypeRegistry(mappingsAssembly);
comObjectMapper = new ComObjectMapper(enumMapper, typeRegistry);
queryProvider = RelinqHelpers.CreateQueryProvider(typeRegistry, Execute);
metadataAccessor = new MetadataAccessor(this.globalContext);
}

public Type GetTypeOrNull(string configurationName)
{
return typeMapper.GetTypeOrNull(configurationName);
return typeRegistry.GetTypeOrNull(configurationName);
}

public IQueryable<T> Select<T>(string sourceName = null)
Expand Down
8 changes: 4 additions & 4 deletions Simple1C/Impl/ComObjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Simple1C.Impl
internal class ComObjectMapper
{
private readonly EnumMapper enumMapper;
private readonly TypeMapper typeMapper;
private readonly TypeRegistry typeRegistry;
private static readonly DateTime nullDateTime = new DateTime(100, 1, 1);

public ComObjectMapper(EnumMapper enumMapper, TypeMapper typeMapper)
public ComObjectMapper(EnumMapper enumMapper, TypeRegistry typeRegistry)
{
this.enumMapper = enumMapper;
this.typeMapper = typeMapper;
this.typeRegistry = typeRegistry;
}

public object MapFrom1C(object source, Type type)
Expand All @@ -27,7 +27,7 @@ public object MapFrom1C(object source, Type type)
if (source is MarshalByRefObject)
{
var typeName = GetFullName(source);
type = typeMapper.GetTypeOrNull(typeName);
type = typeRegistry.GetTypeOrNull(typeName);
if (type == null)
{
const string messageFormat = "can't resolve .NET type by 1c type [{0}]";
Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/ComValueSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Simple1C.Impl
{
public class ComValueSource : IValueSource
internal class ComValueSource : IValueSource
{
private readonly ComObjectMapper comObjectMapper;
private readonly object comObject;
Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/EntityHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Simple1C.Impl
{
public class EntityHelpers
internal class EntityHelpers
{
public static bool IsTableSection(Type type)
{
Expand Down
4 changes: 2 additions & 2 deletions Simple1C/Impl/Helpers/RelinqHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace Simple1C.Impl.Helpers
{
internal static class RelinqHelpers
{
public static IQueryProvider CreateQueryProvider(TypeMapper typeMapper, Func<BuiltQuery, IEnumerable> execute)
public static IQueryProvider CreateQueryProvider(TypeRegistry typeRegistry, Func<BuiltQuery, IEnumerable> execute)
{
return new RelinqQueryProvider(QueryParser.CreateDefault(),
new RelinqQueryExecutor(typeMapper, execute));
new RelinqQueryExecutor(typeRegistry, execute));
}
}
}
6 changes: 3 additions & 3 deletions Simple1C/Impl/InMemoryDataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public class InMemoryDataContext : IDataContext
{
private readonly Dictionary<Type, InMemoryEntityCollection> committed = new Dictionary<Type, InMemoryEntityCollection>();

private readonly TypeMapper typeMapper;
private readonly TypeRegistry typeRegistry;

public InMemoryDataContext(Assembly mappingsAssembly)
{
typeMapper = new TypeMapper(mappingsAssembly);
typeRegistry = new TypeRegistry(mappingsAssembly);
}

public Type GetTypeOrNull(string configurationName)
{
return typeMapper.GetTypeOrNull(configurationName);
return typeRegistry.GetTypeOrNull(configurationName);
}

public int GetRevision(Type type)
Expand Down
8 changes: 4 additions & 4 deletions Simple1C/Impl/Queriables/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Simple1C.Impl.Queriables
{
internal class QueryBuilder
{
private readonly TypeMapper typeMapper;
private readonly TypeRegistry typeRegistry;
private readonly Dictionary<string, object> parameters = new Dictionary<string, object>();
private readonly List<string> whereParts = new List<string>();

public QueryBuilder(TypeMapper typeMapper)
public QueryBuilder(TypeRegistry typeRegistry)
{
this.typeMapper = typeMapper;
this.typeRegistry = typeRegistry;
}

public Ordering[] Orderings { get; set; }
Expand Down Expand Up @@ -83,7 +83,7 @@ public void SetSource(Type type, string name)
if (!string.IsNullOrEmpty(name))
{
sourceName = name;
sourceType = typeMapper.GetTypeOrNull(sourceName);
sourceType = typeRegistry.GetTypeOrNull(sourceName);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions Simple1C/Impl/Queriables/RelinqQueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace Simple1C.Impl.Queriables
{
internal class RelinqQueryExecutor : IQueryExecutor
{
private readonly TypeMapper typeMapper;
private readonly TypeRegistry typeRegistry;
private readonly Func<BuiltQuery, IEnumerable> execute;

public RelinqQueryExecutor(TypeMapper typeMapper, Func<BuiltQuery, IEnumerable> execute)
public RelinqQueryExecutor(TypeRegistry typeRegistry, Func<BuiltQuery, IEnumerable> execute)
{
this.typeMapper = typeMapper;
this.typeRegistry = typeRegistry;
this.execute = execute;
}

Expand All @@ -31,7 +31,7 @@ public T ExecuteSingle<T>(QueryModel queryModel, bool returnDefaultWhenEmpty)

public IEnumerable<T> ExecuteCollection<T>(QueryModel queryModel)
{
var builder = new QueryBuilder(typeMapper);
var builder = new QueryBuilder(typeRegistry);
queryModel.Accept(new QueryModelVisitor(builder));
return execute(builder.Build()).Cast<T>();
}
Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/Queries/QueryResultSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Simple1C.Impl.Queries
{
public class QueryResultSelection
internal class QueryResultSelection
{
private readonly object comObject;

Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/Queries/ValueTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Simple1C.Impl.Queries
{
public class ValueTable : DispatchObject, IEnumerable<ValueTableRow>
internal class ValueTable : DispatchObject, IEnumerable<ValueTableRow>
{
private readonly Dictionary<string, int> columnsMap;

Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/Queries/ValueTableColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Simple1C.Impl.Queries
{
public class ValueTableColumn : DispatchObject
internal class ValueTableColumn : DispatchObject
{
public ValueTableColumn(object comObject)
: base(comObject)
Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/Queries/ValueTableColumnCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Simple1C.Impl.Queries
{
public class ValueTableColumnCollection : DispatchObject
internal class ValueTableColumnCollection : DispatchObject
{
public ValueTableColumnCollection(object comObject)
: base(comObject)
Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/Queries/ValueTableRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Simple1C.Impl.Queries
{
public class ValueTableRow : DispatchObject
internal class ValueTableRow : DispatchObject
{
private readonly Dictionary<string, int> columnsMap;

Expand Down
2 changes: 1 addition & 1 deletion Simple1C/Impl/QueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Simple1C.Impl
{
public class QueryResult : DispatchObject
internal class QueryResult : DispatchObject
{
public QueryResult(object comObject)
: base(comObject)
Expand Down
60 changes: 30 additions & 30 deletions Simple1C/Impl/TypeMapper.cs → Simple1C/Impl/TypeRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Simple1C.Impl.Helpers;

namespace Simple1C.Impl
{
internal class TypeMapper
{
private readonly Dictionary<string, Type> typeMapping;

public TypeMapper(Assembly assembly)
{
typeMapping = assembly.GetTypes()
.Where(x => x.IsClass || x.IsEnum)
.Select(x => new
{
typeName1C = ConfigurationName.GetOrNull(x),
type = x
})
.Where(x => x.typeName1C.HasValue)
.ToDictionary(x => x.typeName1C.Value.Fullname, x => x.type);
}

public Type GetTypeOrNull(string configurationName)
{
return typeMapping.GetOrDefault(configurationName);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Simple1C.Impl.Helpers;

namespace Simple1C.Impl
{
internal class TypeRegistry
{
private readonly Dictionary<string, Type> typeMapping;

public TypeRegistry(Assembly assembly)
{
typeMapping = assembly.GetTypes()
.Where(x => x.IsClass || x.IsEnum)
.Select(x => new
{
typeName1C = ConfigurationName.GetOrNull(x),
type = x
})
.Where(x => x.typeName1C.HasValue)
.ToDictionary(x => x.typeName1C.Value.Fullname, x => x.type);
}

public Type GetTypeOrNull(string configurationName)
{
return typeMapping.GetOrDefault(configurationName);
}
}
}
2 changes: 1 addition & 1 deletion Simple1C/Simple1C.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Compile Include="Impl\QueryResult.cs" />
<Compile Include="Impl\ValueSource.cs" />
<Compile Include="Interface\IDataContext.cs" />
<Compile Include="Impl\TypeMapper.cs" />
<Compile Include="Impl\TypeRegistry.cs" />
<Compile Include="Interface\Connection1CType.cs" />
<Compile Include="Interface\ConnectionStringBuilder.cs" />
<Compile Include="Interface\GlobalContextFactory.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/QueryBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public class ОтветственныеЛицаОрганизаций

protected IQueryable<T> Source<T>(string sourceName = null)
{
var queryProvider = RelinqHelpers.CreateQueryProvider(new TypeMapper(typeof (Контрагенты).Assembly),
var queryProvider = RelinqHelpers.CreateQueryProvider(new TypeRegistry(typeof (Контрагенты).Assembly),
delegate(BuiltQuery query)
{
lastQuery = query;
Expand Down

0 comments on commit 0873ee8

Please sign in to comment.