init
This commit is contained in:
21
Common/DTS.Common/Classes/UnityExtensions.cs
Normal file
21
Common/DTS.Common/Classes/UnityExtensions.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Unity;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public static class UnityExtensions
|
||||
{
|
||||
public static T TryResolve<T>(this IUnityContainer container)
|
||||
where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)container.Resolve(typeof(T));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user