Пример #1
0
        public T GetInstance()
        {
            try
            {
                if (_container != null)
                {
                    return((T)_container.Resolve <IUserRepository>());
                }

                _container = new UnityContainer();
                //var frissDmsContextDb = new FRISSDMSContext();
                var userContextRepo = new Repository <User>(new FRISSDMSContext());

                _container.RegisterType <IUserRepository, T>
                (
                    new InjectionConstructor(userContextRepo)
                );
                return((T)_container.Resolve <IUserRepository>());
            }
            catch (ResolutionFailedException resFailExp)
            {
                _logger = new CustomLogger.CustomLogger();
                _logger.Log(LogLevel.Error, resFailExp.Message, "UserFactory..." + typeof(T));
                throw;
            }
        }
Пример #2
0
        public T GetInstance()
        {
            try
            {
                if (_container != null)
                {
                    return((T)_container.Resolve <IDocumentRepository>());
                }

                _container = new UnityContainer();
                _container.RegisterType <IDocumentRepository, T>
                (
                    new InjectionConstructor()
                );
                return((T)_container.Resolve <IDocumentRepository>());
            }
            catch (ResolutionFailedException resFailExp)
            {
                _logger = new CustomLogger.CustomLogger();
                _logger.Log(LogLevel.Error, resFailExp.Message, "DocumentFactory..." + typeof(T));
                throw;
            }
        }