Skip to content

Commit 7c1c98f

Browse files
committed
Removed resx addition and throwing exception for @Inject scenario
1 parent 9f0bc8e commit 7c1c98f

File tree

6 files changed

+11
-39
lines changed

6 files changed

+11
-39
lines changed

Source/Csla.NetStandard2.0/Properties/Resources.Designer.cs

+1-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Csla.Shared.Resources/Resources.Designer.cs

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Csla.Shared.Resources/Resources.resx

-3
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,4 @@
475475
<data name="OneOfTwoParametersRequiredException" xml:space="preserve">
476476
<value>{0} requires a value for either the {1} or the {2} parameter.</value>
477477
</data>
478-
<data name="MethodInjectFailed" xml:space="preserve">
479-
<value>Method can not be injected as there is no IServiceProvider currently in scope.</value>
480-
</data>
481478
</root>

Source/Csla.Shared.Resources/Resources1.Designer.cs

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Csla.Shared/Reflection/ServiceProviderMethodCaller.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -403,18 +403,17 @@ public static async Task<object> CallMethodTryAsync(object obj, ServiceProviderM
403403
int index = 0;
404404
int criteriaIndex = 0;
405405
#if !NET40 && !NET45
406-
var service = ApplicationContext.ScopedServiceProvider;
406+
var service = ApplicationContext.ScopedServiceProvider;
407407
#endif
408408
foreach (var item in method.Parameters)
409409
{
410410
if (method.IsInjected[index])
411411
{
412412
#if !NET40 && !NET45
413-
if (service == null)
414-
{
415-
throw new InjectException(obj.GetType().Name + "." + info.Name + " " + Resources.MethodInjectFailed);
416-
}
417-
plist[index] = service.GetService(item.ParameterType);
413+
if (service != null)
414+
plist[index] = service.GetService(item.ParameterType);
415+
//throw new InjectException(obj.GetType().Name + "." + info.Name + " " + Resources.MethodInjectFailed);
416+
418417
#endif
419418
}
420419
else

Source/csla.netcore.test/DataPortal/ServiceProviderInvocationTests.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ public void Initialize()
3636
}
3737

3838
[TestMethod]
39-
public async Task NoServiceProvider_Throws()
39+
public async Task NoServiceProvider()
4040
{
4141
var obj = new TestMethods();
4242
var method = new ServiceProviderMethodInfo { MethodInfo = obj.GetType().GetMethod("Method1") };
4343
Assert.IsNotNull(method, "needed method");
44-
await Assert.ThrowsExceptionAsync<InjectException>(async () => await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 }));
44+
var result = (bool)await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 });
45+
Assert.IsTrue(result);
46+
47+
// await Assert.ThrowsExceptionAsync<InjectException>(async () => await ServiceProviderMethodCaller.CallMethodTryAsync(obj, method, new object[] { 123 }));
4548
}
4649

4750
[TestMethod]

0 commit comments

Comments
 (0)