Example #1
0
        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);
        }
Example #2
0
            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();
            }
Example #3
0
 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);
     }
 }
Example #4
0
 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);
     }
 }
Example #5
0
 public TComponent TryResolve <TComponent>()
 {
     return(structureMapContainer.TryGetInstance <TComponent>());
 }
Example #6
0
        public object GetService(Type serviceType)
        {
            object instance = _container.TryGetInstance(serviceType);

            return(instance);
        }
Example #7
0
 object IDependencyScope.GetService(Type serviceType)
 {
     return(_container.TryGetInstance(serviceType));
 }