private bool ServiceRegistered <T>() { var instance = structureMapContainer.TryGetInstance(typeof(T)); var d = instance as Delegate; if (d != null) { try { d.DynamicInvoke(); } catch (TargetInvocationException ex) { var inner = ex.InnerException as StructureMapException; if (inner == null) { throw; } if (inner.ErrorCode == 202) { return(false); } throw; } } return(instance != null); }
public bool TryResolve(Type type, object data, out object value) { if (data is null) { value = _container.TryGetInstance(type); return(value != null); } if (data is IDictionary <string, object> ) { value = _container.TryGetInstance(type, new ExplicitArguments((IDictionary <string, object>)data)); return(value != null); } throw new NotSupportedException(); }
public object GetService(Type serviceType) { if (serviceType == null) { return(null); } try { return(serviceType.IsAbstract || serviceType.IsInterface ? _container.TryGetInstance(serviceType) : _container.GetInstance(serviceType)); } catch { return(null); } }
public object GetService(Type serviceType) { if (serviceType == null) { return(null); } try { return(serviceType.IsAbstract || serviceType.IsInterface ? _container.TryGetInstance(serviceType) : _container.GetInstance(serviceType)); } catch (Exception ex) { //System.Diagnostics.EventLog.WriteEntry("Web Distribution System", ex.ToString()); return(null); } }
public TComponent TryResolve <TComponent>() { return(structureMapContainer.TryGetInstance <TComponent>()); }
public object GetService(Type serviceType) { object instance = _container.TryGetInstance(serviceType); return(instance); }
object IDependencyScope.GetService(Type serviceType) { return(_container.TryGetInstance(serviceType)); }