Skip to content

Commit b4a8347

Browse files
committed
Fixed problem with ConcreteTypeCreator in Medium Trust
1 parent 6602844 commit b4a8347

File tree

10 files changed

+64
-22
lines changed

10 files changed

+64
-22
lines changed

.gitignore

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ NDependOut
2222
*_mm_cache.bin
2323
Simple.Data.sln.DotSettings.user
2424
Simple.Data/Simple.Data.idc
25-
.DS_Store
26-
mono-release-*
27-
*ncrunch*
25+
.DS_Store
26+
mono-release-*
27+
*ncrunch*
28+
MediumTrustApp
29+
nohup.out
30+
packages/EntityFramework.5.0.0/
31+
packages/Microsoft.AspNet.Mvc.3.0.20105.1/
32+
packages/Microsoft.AspNet.Providers.Core.1.1/
33+
packages/Microsoft.AspNet.Providers.LocalDB.1.1/
34+
packages/Microsoft.AspNet.Razor.1.0.20105.408/
35+
packages/Microsoft.AspNet.WebPages.1.0.20105.408/
36+
packages/Microsoft.Web.Infrastructure.1.0.0.0/
37+
packages/Modernizr.2.5.3/
38+
packages/jQuery.1.7.1.1/
39+
packages/jQuery.UI.Combined.1.8.20.1/
40+
packages/jQuery.Validation.1.9.0.1/

Simple.Data.Ado/ProviderAssemblyAttributeBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static IEnumerable<ProviderAssemblyAttributeBase> Get(Assembly assembly)
4040
{
4141
foreach (var referencedAssembly in assembly.GetReferencedAssemblies())
4242
{
43-
if (AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().All(a => a.GetName().FullName != referencedAssembly.FullName))
43+
if (AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().All(a => a.GetFullName() != referencedAssembly.FullName))
4444
{
4545
try
4646
{
@@ -56,7 +56,7 @@ public static IEnumerable<ProviderAssemblyAttributeBase> Get(Assembly assembly)
5656
cad => typeof (ProviderAssemblyAttributeBase).IsAssignableFrom(cad.Constructor.DeclaringType));
5757
if (hasAttribute)
5858
{
59-
assembly = Assembly.Load(assembly.GetName());
59+
assembly = Assembly.Load(assembly.GetFullName());
6060
}
6161
else
6262
{

Simple.Data.Ado/ProviderHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static bool LoadUsingAssemblyAttribute(string connectionString, ICollect
208208
private static List<ProviderAssemblyAttributeBase> LoadAssemblyAttributes()
209209
{
210210
var attributes = AppDomain.CurrentDomain.GetAssemblies()
211-
.Where(a => a.GetName().Name.StartsWith("Simple.Data.", StringComparison.OrdinalIgnoreCase))
211+
.Where(a => a.GetFullName().StartsWith("Simple.Data.", StringComparison.OrdinalIgnoreCase))
212212
.SelectMany(ProviderAssemblyAttributeBase.Get)
213213
.ToList();
214214

Simple.Data.sln

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 11.00
3-
# Visual Studio 2010
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
44
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple.Data", "Simple.Data\Simple.Data.csproj", "{148CEE80-2E84-4ABD-B5AB-20415B2BBD21}"
55
EndProject
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10F43335-5672-4BDA-91BB-5311C2BFA409}"
@@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProfilingApp", "ProfilingAp
5555
EndProject
5656
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple.Data.InMemoryTest", "Simple.Data.InMemoryTest\Simple.Data.InMemoryTest.csproj", "{1B6A87C0-4ACA-4411-8879-844537A52126}"
5757
EndProject
58+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediumTrustApp", "MediumTrustApp\MediumTrustApp.csproj", "{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}"
59+
EndProject
5860
Global
5961
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6062
Debug|Any CPU = Debug|Any CPU
@@ -225,6 +227,16 @@ Global
225227
{1B6A87C0-4ACA-4411-8879-844537A52126}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
226228
{1B6A87C0-4ACA-4411-8879-844537A52126}.Release|Mixed Platforms.Build.0 = Release|Any CPU
227229
{1B6A87C0-4ACA-4411-8879-844537A52126}.Release|x86.ActiveCfg = Release|Any CPU
230+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
231+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
232+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
233+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
234+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Debug|x86.ActiveCfg = Debug|Any CPU
235+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
236+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Release|Any CPU.Build.0 = Release|Any CPU
237+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
238+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
239+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D}.Release|x86.ActiveCfg = Release|Any CPU
228240
EndGlobalSection
229241
GlobalSection(SolutionProperties) = preSolution
230242
HideSolutionNode = FALSE
@@ -237,6 +249,7 @@ Global
237249
{70536BA8-AF0D-46F3-B04C-45177F56B320} = {182AEEFE-9B89-4264-BCED-91A00D1EF896}
238250
{E9160373-8BD2-4D69-B88E-1D3B5BC0A6FB} = {182AEEFE-9B89-4264-BCED-91A00D1EF896}
239251
{1B6A87C0-4ACA-4411-8879-844537A52126} = {182AEEFE-9B89-4264-BCED-91A00D1EF896}
252+
{CCAEC8D8-0090-4DE2-AF6C-44CF75268A0D} = {182AEEFE-9B89-4264-BCED-91A00D1EF896}
240253
{9AAF3008-8033-4A26-93D2-97928E7801E9} = {2AAC5DFA-3851-4324-A51F-5BC46BEB777C}
241254
EndGlobalSection
242255
GlobalSection(NDepend) = preSolution

Simple.Data/AssemblyEx.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Reflection;
3+
4+
namespace Simple.Data
5+
{
6+
public static class AssemblyEx
7+
{
8+
public static string GetFullName(this Assembly assembly)
9+
{
10+
return assembly.FullName.Substring(0, assembly.FullName.IndexOf(",", StringComparison.OrdinalIgnoreCase));
11+
}
12+
}
13+
}

Simple.Data/ConcreteTypeCreator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ private ConcreteTypeCreator(Lazy<Func<IDictionary<string, object>, object>> func
3131

3232
public object Create(IDictionary<string, object> source)
3333
{
34-
return _func.Value(source);
34+
var func = _func.Value;
35+
return func(source);
3536
}
36-
37+
3738
public bool TryCreate(IDictionary<string,object> source, out object result)
3839
{
3940
try

Simple.Data/MefHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static CompositionContainer CreateAppDomainContainer()
9595

9696
private static bool IsSimpleDataAssembly(Assembly assembly)
9797
{
98-
return assembly.GetName().Name.StartsWith("Simple.Data.", StringComparison.OrdinalIgnoreCase);
98+
return assembly.GetFullName().StartsWith("Simple.Data.", StringComparison.OrdinalIgnoreCase);
9999
}
100100
}
101101
}

Simple.Data/PropertySetterBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private TryExpression CreateTrySimpleAssign()
298298
var changeTypeMethod = typeof (PropertySetterBuilder).GetMethod("SafeConvert",
299299
BindingFlags.Static | BindingFlags.NonPublic);
300300
callConvert = Expression.Call(changeTypeMethod, _itemProperty,
301-
Expression.Constant(_property.PropertyType.GetEnumUnderlyingType()));
301+
Expression.Constant(_property.PropertyType.GetEnumUnderlyingType(), typeof(Type)));
302302
}
303303
else if (_property.PropertyType.IsGenericType && _property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
304304
{
@@ -313,7 +313,7 @@ private TryExpression CreateTrySimpleAssign()
313313
var changeTypeMethod = typeof (PropertySetterBuilder).GetMethod("SafeConvert",
314314
BindingFlags.Static | BindingFlags.NonPublic);
315315
callConvert = Expression.Call(changeTypeMethod, _itemProperty,
316-
Expression.Constant(_property.PropertyType));
316+
Expression.Constant(_property.PropertyType, typeof(Type)));
317317
}
318318

319319
var assign = Expression.Assign(_nameProperty, Expression.Convert(callConvert, _property.PropertyType));
@@ -323,7 +323,7 @@ private TryExpression CreateTrySimpleAssign()
323323
Expression.IfThenElse(Expression.TypeIs(_itemProperty, typeof (string)),
324324
Expression.Assign(_nameProperty,
325325
Expression.Convert(Expression.Call(typeof (Enum).GetMethod("Parse", new[] {typeof(Type), typeof(string), typeof(bool)}),
326-
Expression.Constant(_property.PropertyType),
326+
Expression.Constant(_property.PropertyType, typeof(Type)),
327327
Expression.Call(_itemProperty, typeof(object).GetMethod("ToString")), Expression.Constant(true)), _property.PropertyType)),
328328
assign), Expression.Catch(typeof(Exception), Expression.Empty()));
329329
}
@@ -344,7 +344,7 @@ private TryExpression CreateTrySimpleArrayAssign()
344344
Expression.IfThenElse(Expression.TypeIs(_itemProperty, typeof (string)),
345345
Expression.Assign(_nameProperty,
346346
Expression.Convert(Expression.Call(typeof (Enum).GetMethod("Parse", new[] {typeof(Type), typeof(string), typeof(bool)}),
347-
Expression.Constant(_property.PropertyType),
347+
Expression.Constant(_property.PropertyType, typeof(Type)),
348348
Expression.Call(_itemProperty, typeof(object).GetMethod("ToString")), Expression.Constant(true)), _property.PropertyType)),
349349
assign), Expression.Catch(typeof(Exception), Expression.Empty()));
350350
}

Simple.Data/Simple.Data.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Compile Include="AdapterWithFunctionsExtensions.cs" />
5858
<Compile Include="AdoCompatibleComparer.cs" />
5959
<Compile Include="AllColumnsSpecialReference.cs" />
60+
<Compile Include="AssemblyEx.cs" />
6061
<Compile Include="BinderHelper.cs" />
6162
<Compile Include="CachingAdapterFactory.cs" />
6263
<Compile Include="CastEnumerable.cs" />

packages/repositories.config

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<repositories>
3-
<repository path="..\Simple.Data.SqlCe40\packages.config" />
3+
<repository path="..\MediumTrustApp\packages.config" />
4+
<repository path="..\PerformanceTestConsole\packages.config" />
5+
<repository path="..\Simple.Data.Ado.Test\packages.config" />
6+
<repository path="..\Simple.Data.BehaviourTest\packages.config" />
7+
<repository path="..\Simple.Data.InMemoryTest\packages.config" />
8+
<repository path="..\Simple.Data.Mocking.Test\packages.config" />
49
<repository path="..\Simple.Data.SqlCe35Test\packages.config" />
10+
<repository path="..\Simple.Data.SqlCe40\packages.config" />
511
<repository path="..\Simple.Data.SqlCe40Test\packages.config" />
12+
<repository path="..\Simple.Data.SqlTest\packages.config" />
613
<repository path="..\Simple.Data.TestHelper\packages.config" />
7-
<repository path="..\Simple.Data.BehaviourTest\packages.config" />
8-
<repository path="..\Simple.Data.Ado.Test\packages.config" />
9-
<repository path="..\Simple.Data.Mocking.Test\packages.config" />
1014
<repository path="..\Simple.Data.UnitTest\packages.config" />
11-
<repository path="..\Simple.Data.SqlTest\packages.config" />
12-
<repository path="..\PerformanceTestConsole\packages.config" />
13-
<repository path="..\Simple.Data.InMemoryTest\packages.config" />
1415
</repositories>

0 commit comments

Comments
 (0)