22 lines
444 B
Plaintext
22 lines
444 B
Plaintext
|
|
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|