コード例 #1
0
        public void CreateInstance()
        {
            IServiceProvider           provider    = GetServiceProvider();
            ILaboratoryDelegateFactory labDelegate = new LaboratoryDelegateFactory(this.configuration, provider);
            ILaboratoryDelegate        instance    = labDelegate.CreateInstance();

            Assert.NotNull(instance);
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of ILaboratoryDelegate via configuration.
        /// </summary>
        /// <returns>The ILaboratoryDelegate.</returns>
        public ILaboratoryDelegate CreateInstance()
        {
            string typeStr = this.configuration.GetValue <string>("LaboratoryDelegate", DefaultInstance);
            Type   type    = Type.GetType(typeStr) !;
            ILaboratoryDelegate instance = (ILaboratoryDelegate)ActivatorUtilities.CreateInstance(this.serviceProvider, type);

            return(instance);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LaboratoryService"/> class.
 /// </summary>
 /// <param name="logger">Injected Logger Provider.</param>
 /// <param name="httpAccessor">The injected http context accessor provider.</param>
 /// <param name="laboratoryDelegateFactory">The laboratory delegate factory.</param>
 public LaboratoryService(
     ILogger <LaboratoryService> logger,
     IHttpContextAccessor httpAccessor,
     ILaboratoryDelegateFactory laboratoryDelegateFactory)
 {
     this.logger = logger;
     this.httpContextAccessor = httpAccessor;
     this.laboratoryDelegate  = laboratoryDelegateFactory.CreateInstance();
 }