private static void addEventHandlerToManager(IServiceResolver resolver, IEnumerable<Type> types) {
     IEventHandlerManager Manager = resolver.GetService(typeof(IEventHandlerManager)) as IEventHandlerManager;
     foreach (var type in types) {
         var handler = (resolver.GetService(type));
         Manager.AddHandler(type.GetInterfaces().Where(a => a.GetGenericArguments().Count() > 0).FirstOrDefault().GetGenericArguments().FirstOrDefault(), handler);
     }
 }
        public static void Init(IServiceResolver serviceResolver, string encodingKey)
        {
            TraderDocumentsPostgresRepository = serviceResolver.GetService <TraderDocumentsPostgresRepository>();
            PersonalDataRepository            = serviceResolver.GetService <PersonalDataPostgresRepository>();
            AzureBlobContainer = serviceResolver.GetService <IAzureBlobContainer>();
            //  AuditLogServiceGrpc = serviceResolver.GetService<IAuditLogServiceGrpc>();

            EncodingKey = Encoding.UTF8.GetBytes(encodingKey);
        }
Beispiel #3
0
 public ITextProcessingService Create <TAddingStrategy>() where TAddingStrategy : IUniqueWordsAddingStrategy
 {
     return(new TextProcessingService(
                _resolver.GetService <ITextProcessingDataContextFactory>(),
                _resolver.GetService <IUniqueWordsAddingStrategy, TAddingStrategy>(),
                _resolver.GetService <ITextAnalyzer>(),
                _resolver.GetService <ILogger <TextProcessingService> >()
                ));
 }
        public void SimpleServiceResolver_can_store_class_and_interface()
        {
            IServiceResolver resolver          = GetResolver();
            ITestService     expectedInterface = new TestService();
            TestService      expectedClass     = new TestService();

            resolver.RegisterService <ITestService>(() => expectedInterface);
            resolver.RegisterService <TestService>(() => expectedClass);
            ITestService actualInterface = resolver.GetService <ITestService>();
            TestService  actualClass     = resolver.GetService <TestService>();

            Assert.IsNotNull(actualInterface);
            Assert.IsNotNull(actualClass);
            Assert.AreNotSame(actualInterface, actualClass);
            Assert.AreEqual(expectedInterface, actualInterface);
            Assert.AreEqual(expectedClass, actualClass);
        }
        /// <summary>
        /// Creates sample user token
        /// </summary>
        /// <param name="context">context</param>
        /// <param name="userId">user identifier</param>
        /// <returns>sample user token</returns>
        public SampleUserToken CreateUserToken(Context context, int userId)
        {
            if (context == null)
            {
                throw new MemoryPointerIsNullException("context");
            }

            return(new SampleUserToken(userId, utcTimeProviderResolver.GetService(context).GetCurrentUTCTime()));
        }
Beispiel #6
0
        /// <summary>
        /// Gets yet another sample type structured data
        /// </summary>
        /// <param name="context">context</param>
        /// <returns>yet another sample type structured data</returns>
        public UITree GetYetAnotherTypeStructuredData(Context context)
        {
            var setProvider       = setProviderResolver.GetService(context);
            var structureProvider = structureProviderResolver.GetService(context);

            var descriptorTree = structureProvider.GetYetAnotherTypeDescriptorTree(context);

            return(UITree.Create <string, YetAnotherType>(descriptorTree, name => setProvider.GetYetAnotherTypeInstanceByName(context, name)));
        }
        /// <summary>
        /// Gets the service.
        /// </summary>
        /// <param name="serviceType">The service type.</param>
        /// <returns>An object.</returns>
        public object GetService(Type serviceType)
        {
            var plugin = cache.GetTypeOfPlugin(serviceType);

            if (plugin == null)
            {
                return(serviceProvider.GetService(serviceType));
            }

            var process = new ResolveProcess(plugin, cache);

            lock (GlobLock.LockObj)
            {
                aspectConfiguration.ResolveCall = process.ResolveType;
                var obj = serviceProvider.GetService(serviceType);
                aspectConfiguration.ResolveCall = null;
                return(obj);
            }
        }
        public void SimpleServiceResolver_registration_and_get_works()
        {
            IServiceResolver resolver = GetResolver();

            resolver.RegisterService <ITestService>(() => new TestService());
            var actual = resolver.GetService <ITestService>();

            Assert.IsInstanceOfType(actual, typeof(ITestService));
            Assert.IsInstanceOfType(actual, typeof(TestService));
        }
 private void Handle <TRequest, TResponse>()
     where TRequest : new()
     where TResponse : new()
 {
     Post[typeof(TRequest).Name, true] = async(ctx, ct) =>
     {
         IService <TRequest, TResponse> service = _serviceResolver.GetService <TRequest, TResponse>();
         var request = this.Bind <TRequest>();
         return(await service.Execute(request, ct));
     };
 }
Beispiel #10
0
 private static object Get(Type type)
 {
     return(_serviceResolver.GetService(type));
 }
 public Schema ResolveSchema()
 {
     return(_serviceResolver.GetService <CommonGraphScheme>());
 }
Beispiel #12
0
        /// <summary>
        /// Gets exception for the case when argument is null
        /// </summary>
        /// <param name="context">context</param>
        /// <returns>exception instance</returns>
        public EntityException <SampleType, TestError> GetTestErrorException(Context context)
        {
            var testErrorFactory = testErrorFactoryResolver.GetService(context);

            return(new EntityException <SampleType, TestError>(context, this, testErrorFactory.CreateInfoEntity()));
        }
 public static void Init(IServiceResolver sr)
 {
     AuthCredentialsRepository = sr.GetService <IAuthCredentialsRepository>();
     Logger = sr.GetService <Logger>();
 }