You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http.Dependencies; using Unity; using Unity.Exceptions;
namespace JsonRx.Resolver { public class UnityResolver : IDependencyResolver { protected IUnityContainer container;
public UnityResolver(IUnityContainer container) { if (container == null) { throw new ArgumentNullException("container"); } this.container = container; }
public IDependencyScope BeginScope() { var child = container.CreateChildContainer(); return new UnityResolver(child); }
public object GetService(Type serviceType) { try { return container.Resolve(serviceType); } catch (ResolutionFailedException) { return null; } }
public IEnumerable<object> GetServices(Type serviceType) { try { return container.ResolveAll(serviceType); } catch (ResolutionFailedException) { return new List<object>(); } }
public void Dispose() { container.Dispose(); } } }
|