コード例 #1
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
        container
        .RegisterType <IAnnotationIssuesProvider, IssueAnnotationsProvider>(reuseScope)
        .RegisterType <IVulnerabilitiesProcessor, VulnerabilitiesProcessor>(reuseScope)
        .RegisterType <IIssueNameBuilder, IssueNameBuilder>(reuseScope)
        .RegisterType <IIssueAnnotationStateSerializer, IssueAnnotationStateSerializer>(reuseScope)
        .RegisterType <IIssueAnnotationWorkflow, IssueAnnotationWorkflow>(reuseScope)
        .RegisterType <IIssueAnnotationFormatter, SharpSingleLineIssueAnnotationFormatter>(reuseScope)
        .RegisterType <IIssueAnnotationSerializer, IssueAnnotationSerializer>(reuseScope)
        .RegisterType <IBackendPluginProvider, BackendPluginProvider>(reuseScope)
        .RegisterType <IPostProcessingStageProvider, PostProcessingStageProvider>()
        .RegisterType <IVulnerabilityInfoProvider, VulnerabilityInfoProvider>()

        .RegisterPortStage <FilterByBranchPostProcessingStage>(reuseScope)
        .RegisterPortStage <GetRemainingIssuesPostProcessingStage>(reuseScope)
        .RegisterPortStage <LoadIssueAnnotationsPostProcessingStage>(reuseScope)
        .RegisterPortStage <LoadIssuesPostProcessingStage>(reuseScope)
        .RegisterPortStage <LoadItPluginPostProcessingStage>(reuseScope)
        .RegisterPortStage <LoadVcsPluginPostProcessingStage>(reuseScope)
        .RegisterPortStage <LoadVulnInfoPostProcessingStage>(reuseScope)
        .RegisterPortStage <ProcessRemainingIssuesPostProcessingStage>(reuseScope)
        .RegisterPortStage <SaveToItPostProcessingStage>(reuseScope)
        .RegisterPortStage <SaveToVcsPostProcessingStage>(reuseScope)
        .RegisterPortStage <UpdatePairsPostProcessingStage>(reuseScope)
        .RegisterPortStage <UpdateVulnerabilitiesPostProcessingStage>(reuseScope);
コード例 #2
0
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container

        // Query block translators
        .RegisterBlockTranslator <DslGroupBlock, GroupBlockTranslator>(reuseScope)
        .RegisterBlockTranslator <DslLimitBlock, LimitBlockTranslator>(reuseScope)
        .RegisterBlockTranslator <DslOrderBlock, OrderBlockTranslator>(reuseScope)
        .RegisterBlockTranslator <DslFormatBlock, FormatBlockTranslator>(reuseScope)
        .RegisterBlockTranslator <DslFilterBlock, FilterBlockTranslator>(reuseScope)

        // Filter query block specification translators
        .RegisterFilterSpecTranslator <FilterArraySpecification, FilterArraySpecificationTranslator>(reuseScope)
        .RegisterFilterSpecTranslator <FilterConstantSpecification, FilterConstantSpecificationTranslator>(reuseScope)
        .RegisterFilterSpecTranslator <FilterGroupSpecification, FilterGroupSpecificationTranslator>(reuseScope)
        .RegisterFilterSpecTranslator <FilterSpecification, FilterSpecificationTranslator>(reuseScope)
        .RegisterFilterSpecTranslator <FilterConditionSpecification, FilterConditionTranslator>(reuseScope)
        .RegisterFilterSpecTranslator <FilterParameterSpecification, FilterParameterSpecificationTranslator>(reuseScope)

        // Other types
        .RegisterType <IFilterSpecificationTranslatorResolver, FilterSpecificationTranslatorResolver>(reuseScope)
        .RegisterType <IFilterSpecificationTranslatorDirector, FilterSpecificationTranslatorDirector>(reuseScope)
        .RegisterType <IQueryBlockTranslatorResolver, QueryBlockTranslatorResolver>(reuseScope)
        .RegisterType <IQueryBlockTranslationManager, QueryBlockTranslationManager>(reuseScope)
        .RegisterType <IQueryTranslator, QueryTranslator>(reuseScope)
        .RegisterType <IQueryToTableRenderer, QueryToTableRenderer>(reuseScope)
        .RegisterType <IQueryBuilder, QueryBuilder>(reuseScope)
        .RegisterType <IQueryVariableNameBuilder, QueryVariableNameBuilder>(reuseScope)
        .RegisterType <IDataQueryExecutor, DataQueryExecutor>(reuseScope)
        .RegisterType <IDataQueryExpressionTranslator, DataQueryExpressionTranslator>(reuseScope)
        .RegisterType <IQueryEntityNameTranslator, QueryEntityNameTranslator>(reuseScope)
        .RegisterType <IUserProvider, UserProvider>(reuseScope)
        .RegisterType <IUserDataProvider, UserDataProvider>(reuseScope)
        .RegisterType <IWorkflowActionProvider, WorkflowActionProvider>(reuseScope);
コード例 #3
0
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
        container
        .RegisterType <IEventHandlerDispatcher, EventHandlerDispatcher>(reuseScope)
        .RegisterType <IEventProcessor, EventProcessor>(reuseScope)
        .RegisterType <INotificationProcessor, NotificationProcessor>(reuseScope)
        .RegisterType <IBranchNameBuilder, BranchNameBuilder>(reuseScope)
        .RegisterType <IVcsSynchronizer, VcsSynchronizer>(reuseScope)
        .RegisterType <ICustomJobInitializer, VcsPollJobInitializer>(typeof(VcsPollJobInitializer).FullName, reuseScope)
        .RegisterType <ICustomJobInitializer, NotificationPollJobInitializer>(
            typeof(NotificationPollJobInitializer).FullName,
            reuseScope)

        // Event handlers
        .RegisterEvent <VcsCommittedEventHandler>(reuseScope)
        .RegisterEvent <ExternalSystemActionEventHandler>(reuseScope)
        .RegisterEvent <NotificationEventHandler>(reuseScope)
        .RegisterEvent <WorkflowEventHandler>(reuseScope)
        .RegisterEvent <PostprocessingScanTaskFinishedEventHandler>(reuseScope)
        .RegisterEvent <PolicyCheckEventHandler>(reuseScope)

        // Scheduled jobs
        .RegisterJob <EventProcessingJob>(reuseScope)
        .RegisterJob <NotificationProcessingJob>(reuseScope)
        .RegisterJob <SyncVcsJob>(reuseScope)
        .RegisterJob <NotificationPollJob>(reuseScope)
        .RegisterJob <VcsPollJob>(reuseScope);
コード例 #4
0
        /// <summary>
        ///   Builds the lifetime manager using specified reuse scope.
        /// </summary>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>Lifetime manager.</returns>
        public LifetimeManager Build(ReuseScope reuseScope)
        {
            switch (reuseScope)
            {
            case ReuseScope.Container:
                return(new ContainerControlledLifetimeManager());

            case ReuseScope.Hierarchy:
                return(new HierarchicalLifetimeManager());

            case ReuseScope.PerRequest:
                return(new PerRequestLifetimeManager());

            case ReuseScope.PerResolve:
                return(new PerResolveLifetimeManager());

            case ReuseScope.PerThread:
                return(new PerThreadLifetimeManager());

            case ReuseScope.External:
                return(new ExternallyControlledLifetimeManager());

            default:
                throw new InvalidEnumArgumentException(nameof(reuseScope), (int)reuseScope, reuseScope.GetType());
            }
        }
コード例 #5
0
 /// <summary>
 ///   Registers binding to the specified container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="reuseScope">The reuse scope.</param>
 /// <returns>The container.</returns>
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
 container
 .RegisterType <IJobFactory, ContainerJobFactory>(reuseScope)
 .RegisterType <ITriggerBuilder, SequentialTriggerBuilder>(reuseScope)
 .RegisterType <ISchedulerJobTypesLoader, SchedulerJobTypesLoader>(reuseScope)
 .RegisterType <IJobNameBuilder, JobNameBuilder>(reuseScope)
 .RegisterType <IJobScheduler, JobScheduler>(ReuseScope.Container);
コード例 #6
0
 /// <summary>
 /// Registers the types in the IoC container and
 /// adds auto-wiring to the specified types.
 /// The reuse scope is set to none (transient).
 /// </summary>
 /// <param name="serviceTypes"></param>
 public static void RegisterAutoWiredTypes(this Container container, IEnumerable <Type> serviceTypes,
                                           ReuseScope scope = ReuseScope.None)
 {
     foreach (var serviceType in serviceTypes)
     {
         container.RegisterAutoWiredType(serviceType, scope);
     }
 }
コード例 #7
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
        container
        .RegisterType <IRuleParser, RuleParser>(reuseScope)
        .RegisterType <IRuleExecutorDirector, RuleExecutorDirector>(reuseScope)

        .RegisterRuleExecutor <INotificationRule, NotificationRuleResult, NotificationRuleExecutor>(reuseScope)
        .RegisterRuleExecutor <IPolicyRule, PolicyRuleResult, PolicyRuleExecutor>(reuseScope)
        .RegisterRuleExecutor <IWorkflowRule, WorkflowRuleResult, WorkflowRuleExecutor>(reuseScope);
コード例 #8
0
        public static IUnityContainer Register(
            this IUnityContainer container,
            IEnumerable <IContainerModule> modules,
            ReuseScope reuseScope)
        {
            modules.ForEach(_ => _.Register(container, reuseScope));

            return(container);
        }
コード例 #9
0
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
 container
 .RegisterType <IProjectPluginSettingsProvider, ProjectPluginSettingsProvider>(reuseScope)
 .RegisterType <IUserPluginSettingsProvider, UserPluginSettingsProvider>(reuseScope)
 .RegisterType <IPluginProvider, PluginProvider>(reuseScope)
 .RegisterType <IPluginSettingProvider, PluginSettingProvider>(reuseScope)
 .RegisterType <IPluginActivator, PluginActivator>(reuseScope)
 .RegisterType <IPluginFactory, PluginFactory>(reuseScope)
 .RegisterType <IPluginInitializer, PluginInitializer>(reuseScope)
 .RegisterType <IPluginContainerManager, PluginContainerManager>(reuseScope);
コード例 #10
0
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
        .RegisterType <IAuthorityProvider, ApiAuthorityProvider>(reuseScope)
        .RegisterType <ProjectNodeProvider>(reuseScope)

        .RegisterType <IApiService>(reuseScope,
                                    new InjectionFactory(x => CreateProxy <IApiService>("ApiService")))
        .RegisterType <IQueryService>(reuseScope,
                                      new InjectionFactory(x => CreateProxy <IQueryService>("QueryService")))
        .RegisterType <IReportService>(reuseScope,
                                       new InjectionFactory(x => CreateProxy <IReportService>("ReportService")));
コード例 #11
0
 public static void Initialize(
     IContainerModule[] modules,
     ReuseScope reuseScope,
     [NotNull] Action <IUnityContainer> action)
 {
     using (var container = InitializeContainer(modules, reuseScope))
     {
         action(container);
     }
 }
コード例 #12
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
        container
        .RegisterType <INotificationProvider, NotificationProvider>(reuseScope)
        .RegisterType <INotificationRuleProvider, NotificationRuleProvider>(reuseScope)
        .RegisterType <INotificationSendDirector, NotificationSendDirector>(reuseScope)
        .RegisterType <INotificationSenderProvider, NotificationSenderProvider>(reuseScope)

        .RegisterNotificationSender <MailNotificationSender>(NotificationProtocolType.Email, reuseScope)

        .RegisterValidator <Notification, NotificationValidator>(reuseScope);
コード例 #13
0
 /// <summary>
 ///   Registers the repository.
 /// </summary>
 /// <typeparam name="TEntity">The type of the entity.</typeparam>
 /// <typeparam name="TInterface">The type of the interface.</typeparam>
 /// <typeparam name="TRepository">The type of the repository.</typeparam>
 /// <param name="container">The container.</param>
 /// <param name="reuseScope">The reuse scope.</param>
 /// <returns>The container.</returns>
 public static IUnityContainer RegisterRepository <TEntity, TInterface, TRepository>(
     this IUnityContainer container,
     ReuseScope reuseScope)
     where TEntity : class, IEntity
     where TInterface : IWriteRepository <TEntity>
     where TRepository : class, TInterface => container
 .RegisterType <IReadRepository <TEntity>, TRepository>(reuseScope)
 .RegisterType <IWriteRepository <TEntity>, TRepository>(reuseScope)
 .RegisterType <TInterface, TRepository>(reuseScope)
 .RegisterType <IDataSource <TEntity>, TRepository>(reuseScope)
 .RegisterType <IDataSource, TRepository>(typeof(TEntity).Name, reuseScope);
コード例 #14
0
 /// <summary>Auto-scans the provided assemblies for a <see cref="IValidator"/>and registers it in the provided IoC container.</summary>
 ///
 /// <param name="container"> The IoC container.</param>
 /// <param name="scope">     The scope.</param>
 /// <param name="assemblies">The assemblies to scan for a validator.</param>
 public static void RegisterValidators(this Container container, ReuseScope scope, params Assembly[] assemblies)
 {
     foreach (var assembly in assemblies)
     {
         foreach (var validator in assembly.GetTypes()
         .Where(t => t.IsOrHasGenericInterfaceTypeOf(typeof(IValidator<>))))
         {
             RegisterValidator(container, validator, scope);
         }
     }
 }
コード例 #15
0
 public static void RegisterValidators(this Container container, ReuseScope scope, params Assembly[] assemblies)
 {
     foreach (var assembly in assemblies)
     {
         foreach (var validator in assembly.GetTypes()
                  .Where(t => t.IsOrHasGenericInterfaceTypeOf(typeof(IValidator <>))))
         {
             container.RegisterValidator(validator, scope);
         }
     }
 }
コード例 #16
0
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
 .RegisterType <IQueryAccessValidator, QueryAccessValidator>(reuseScope)
 .RegisterType <IQueryStorage, QueryStorage>(reuseScope)
 .RegisterType <IQueryExecutor, QueryExecutor>(reuseScope)
 .RegisterType <IDslDataQueryEvaluator, DslDataQueryEvaluator>(reuseScope)
 .RegisterType <IDslDataQueryEvaluator, DslDataQueryEvaluator>(reuseScope)
 .RegisterType <IQueryModelProcessor, QueryModelProcessor>(reuseScope)
 .RegisterType <IQueryModelAccessValidator, QueryModelAccessValidator>(reuseScope)
 .RegisterType <IFormatBlockValueAccessEvaluator, FormatBlockValueAccessEvaluator>(reuseScope)
 .RegisterType <IQueryProjectRestrictor, QueryProjectRestrictor>(reuseScope)
 .RegisterType <IQueryEntityNamePropertyTypeNameResolver, QueryEntityNamePropertyTypeNameResolver>(reuseScope)
 .RegisterType <IQueryModelValidator, QueryModelValidator>(reuseScope);
コード例 #17
0
        /// <summary>
        /// Registers a named instance of type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="inFunqAsType"></param>
        public static void RegisterAutoWiredType(this Container container, string name, Type serviceType, Type inFunqAsType,
            ReuseScope scope = ReuseScope.None)
        {
            if (serviceType.IsAbstract() || serviceType.ContainsGenericParameters())
                return;

            var methodInfo = typeof(Container).GetMethodInfo("RegisterAutoWiredAs", new[] { typeof(string) });
            var registerMethodInfo = methodInfo.MakeGenericMethod(serviceType, inFunqAsType);

            var registration = registerMethodInfo.Invoke(container, new[] { name }) as IRegistration;
            registration.ReusedWithin(scope);
        }
コード例 #18
0
		/// <summary>
		/// Registers the type in the IoC container and
		/// adds auto-wiring to the specified type.
		/// </summary>
		/// <param name="serviceType"></param>
		/// <param name="inFunqAsType"></param>
		public static void RegisterAutoWiredType(this Container container, Type serviceType, Type inFunqAsType,
			ReuseScope scope = ReuseScope.None)
		{
			if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
				return;

			var methodInfo = typeof(Container).GetMethod("RegisterAutoWiredAs", Type.EmptyTypes);
			var registerMethodInfo = methodInfo.MakeGenericMethod(new[] { serviceType, inFunqAsType });

			var registration = registerMethodInfo.Invoke(container, new object[0]) as IRegistration;
			registration.ReusedWithin(scope);
		}
コード例 #19
0
ファイル: ValidationFeature.cs プロジェクト: jmaucher/SStack
        public static void RegisterValidator(this Container container, Type validator, ReuseScope scope=ReuseScope.None)
        {
            var baseType = validator.BaseType;
            while (!baseType.IsGenericType)
            {
                baseType = baseType.BaseType;
            }

            var dtoType = baseType.GetGenericArguments()[0];
            var validatorType = typeof(IValidator<>).MakeGenericType(dtoType);

            container.RegisterAutoWiredType(validator, validatorType, scope);
        }
コード例 #20
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// The reuse scope is set to none (transient).
        /// </summary>
        /// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredType(this Container container, Type serviceType,
            ReuseScope scope = ReuseScope.None)
        {
            //Don't try to register base service classes
            if (serviceType.IsAbstract() || serviceType.ContainsGenericParameters())
                return;

            var methodInfo = typeof(Container).GetMethodInfo("RegisterAutoWired", Type.EmptyTypes);
            var registerMethodInfo = methodInfo.MakeGenericMethod(serviceType);

            var registration = registerMethodInfo.Invoke(container, TypeConstants.EmptyObjectArray) as IRegistration;
            registration.ReusedWithin(scope);
        }
コード例 #21
0
        public static void RegisterValidator(this Container container, Type validator, ReuseScope scope=ReuseScope.None)
        {
            var baseType = validator.BaseType();
            if (validator.IsInterface() || baseType == null) return;
            while (!baseType.IsGenericType())
            {
                baseType = baseType.BaseType();
            }

            var dtoType = baseType.GetGenericArguments()[0];
            var validatorType = typeof(IValidator<>).GetCachedGenericType(dtoType);

            container.RegisterAutoWiredType(validator, validatorType, scope);
        }
コード例 #22
0
        public static UnityContainer InitializeContainer(
            [CanBeNull][ItemNotNull] IReadOnlyCollection <IContainerModule> modules,
            ReuseScope reuseScope = ReuseScope.Container)
        {
            var container = new UnityContainer();

            if ((modules != null) &&
                (modules.Count > 0))
            {
                container.Register(modules, reuseScope);
            }

            return(container);
        }
コード例 #23
0
        /// <summary>
        /// Registers a named instance of type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="inFunqAsType"></param>
        public static void RegisterAutoWiredType(this Container container, string name, Type serviceType, Type inFunqAsType,
                                                 ReuseScope scope = ReuseScope.None)
        {
            if (serviceType.IsAbstract() || serviceType.ContainsGenericParameters())
            {
                return;
            }

            var methodInfo         = typeof(Container).GetMethodInfo("RegisterAutoWiredAs", new[] { typeof(string) });
            var registerMethodInfo = methodInfo.MakeGenericMethod(serviceType, inFunqAsType);

            var registration = registerMethodInfo.Invoke(container, new[] { name }) as IRegistration;

            registration.ReusedWithin(scope);
        }
コード例 #24
0
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
 .RegisterType <IActiveDirectoryClient, ActiveDirectoryClient>(reuseScope)
 .RegisterType <IAdUserInfoProvider, AdUserInfoProvider>(reuseScope)
 .RegisterType <IUserRoleProvider, AdUserRoleProvider>(reuseScope)
 .RegisterType <IUserAuthorityValidator, AdUserAuthorityValidator>(reuseScope)
 .RegisterType <IGroupNameBuilder, GroupNameBuilder>(reuseScope)
 .RegisterType <ISolutionGroupManager, SolutionGroupManager>(reuseScope)
 .RegisterType <IRoleProvider, RoleProvider>(reuseScope)
 .RegisterType <IUserPrincipalProvider, WindowsIdentityUserPrincipalProvider>(reuseScope)
 .RegisterType <ICurrentUserDataProvider, CurrentUserDataProvider>(reuseScope)
 .RegisterType <IActiveDirectoryPathProvider, ActiveDirectoryPathProvider>(reuseScope)
 .RegisterType <IUserPrincipal, UserPrincipal>(reuseScope)
 .RegisterType <IUserInfoProvider, UserInfoProvider>(reuseScope)
 .RegisterType <IUserGroupMembershipProvider, UserGroupMembershipProvider>(reuseScope)
 .RegisterType <IUserProvider, UserProvider>(reuseScope);
コード例 #25
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="inFunqAsType"></param>
        public static void RegisterAutoWiredType(this Container container, Type serviceType, Type inFunqAsType,
                                                 ReuseScope scope = ReuseScope.None)
        {
            if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
            {
                return;
            }

            var methodInfo         = typeof(Container).GetMethod("RegisterAutoWiredAs", Type.EmptyTypes);
            var registerMethodInfo = methodInfo.MakeGenericMethod(new[] { serviceType, inFunqAsType });

            var registration = registerMethodInfo.Invoke(container, new object[0]) as IRegistration;

            registration.ReusedWithin(scope);
        }
コード例 #26
0
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
 .RegisterType <ScheduledJob, ScanAgent>(typeof(ScanAgent).FullName, reuseScope)
 .RegisterType <IUnitOfWork, EmptyUnitOfWork>(reuseScope)
 .RegisterType <IPluginLoader <IAgentClientPlugin>, PluginLoader <IAgentClientPlugin> >(reuseScope)
 .RegisterType <IPluginProvider, PluginProvider>(reuseScope)
 .RegisterType <IScanAgentIdGenerator, ScanAgentIdGenerator>(reuseScope)
 .RegisterType <IScanAgentIdProvider, FileScanAgentIdProvider>(reuseScope)
 .RegisterType <IScanAgentIdFilePathProvider, ScanAgentIdFilePathProvider>(reuseScope)
 .RegisterType <IApiService>(
     reuseScope,
     new InjectionFactory(
         x =>
 {
     var factory = new ChannelFactory <IApiService>("ApiService");
     return(factory.CreateChannel());
 }));
コード例 #27
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// The reuse scope is set to none (transient).
        /// </summary>
        /// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredType(this Container container, string name, Type serviceType,
                                                 ReuseScope scope = ReuseScope.None)
        {
            //Don't try to register base service classes
            if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
            {
                return;
            }

            var methodInfo         = typeof(Container).GetMethod("RegisterAutoWired", new[] { typeof(string) });
            var registerMethodInfo = methodInfo.MakeGenericMethod(new[] { serviceType });

            var registration = registerMethodInfo.Invoke(container, new[] { name }) as IRegistration;

            registration.ReusedWithin(scope);
        }
コード例 #28
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// The reuse scope is set to none (transient).
        /// </summary>
        /// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredType(this Container container, Type serviceType,
                                                 ReuseScope scope = ReuseScope.None)
        {
            //Don't try to register base service classes
            if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
            {
                return;
            }

            var methodInfo         = typeof(Container).GetMethodInfo("RegisterAutoWired", Type.EmptyTypes);
            var registerMethodInfo = methodInfo.MakeGenericMethod(serviceType);

            var registration = registerMethodInfo.Invoke(container, TypeConstants.EmptyObjectArray) as IRegistration;

            registration.ReusedWithin(scope);
        }
コード例 #29
0
        private static void Init(
            IUnityContainer container,
            ReuseScope reuseScope,
            params IContainerModule[] modules)
        {
            lock (Sync)
            {
                foreach (var module in modules)
                {
                    container.Register(module, reuseScope);
                }

                _container?.Dispose();

                _container = container;
            }
        }
コード例 #30
0
        public static ILifetimeStrategy Get(ReuseScope scope, INCopDependencyResolver container)
        {
            switch (scope)
            {
            case ReuseScope.None:
                return(defaultLifetimeStrategy);

            case ReuseScope.Hierarchy:
                return(new HierarchySingletonStrategy());

            case ReuseScope.Container:
                return(new ContainerSingletonStrategy(container));

            default:
                throw new ResolutionException(Resources.UnknownReuseScope);
            }
        }
コード例 #31
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
        .RegisterType <IReportStorage, ReportStorage>(reuseScope)
        .RegisterType <IReportBuilder, ReportBuilder>(reuseScope)
        .RegisterType <IReportFolderPathStorage, ConfigReportFolderPathStorage>(reuseScope)
        .RegisterType <IReportFileExtensionProvider, ReportFileExtensionProvider>(reuseScope)
        .RegisterType <IReportFileStorage, ReportFileStorage>(reuseScope)
        .RegisterType <IReportAuthorityValidator, ReportAuthorityValidator>(reuseScope)
        .RegisterType <IReportFolderPathProvider, ReportFolderPathProvider>(reuseScope)
        .RegisterType <IReportFolderPathStorage, ConfigReportFolderPathStorage>(reuseScope)
        .RegisterType <IReportBlockVizualizerFabric, ReportBlockVizualizerFabric>(reuseScope)
        .RegisterType <IReportBlockVizualizationManager, ReportBlockVizualizationManager>(reuseScope)
        .RegisterType <IChartScriptProvider, ResourceChartScriptProvider>(reuseScope)
        .RegisterType <IReportQueryLinkDirector, ReportQueryLinkDirector>(reuseScope)

        // report query types
        .RegisterReportQueryExecutor <ReportQuery, ReportQueryExecutor>(reuseScope)
        .RegisterReportQueryExecutor <ReportQueryLink, ReportQueryLinkExecutor>(reuseScope)

        // report generation componenets
        .RegisterType <IReportGenerationPipelineManager, ReportGenerationPipelineManager>(reuseScope)
        .RegisterType <IReportGenerationStageDispatcher, ReportGenerationStageDispatcher>(reuseScope)
        .RegisterGenerationStage <ExecuteQueriesStage>()
        .RegisterGenerationStage <AddDefaultParametersStage>()
        .RegisterGenerationStage <ValidateParametersStage>()
        .RegisterGenerationStage <ReportVizualizationStage>()
        .RegisterGenerationStage <RenderTitleStage>()

        // report block vizualizers
        .RegisterVisualizer <ContainerReportBlock, ContainerReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <ChartReportBlock, ChartReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <IteratorReportBlock, IteratorReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <HtmlDocReportBlock, HtmlDocReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <LabelReportBlock, LabelReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <TableReportBlock, TableReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <ImageReportBlock, ImageReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <HtmlReportBlock, HtmlReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <LinkReportBlock, LinkReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <BoolReportBlock, BoolReportBlockVizualizer>(reuseScope)
        .RegisterVisualizer <QueryScopeReportBlock, QueryScopeReportBlockVizualizer>(reuseScope)

        // report translation components
        .RegisterType <IReportTranslationManager, ReportTranslationManager>(reuseScope)
        .RegisterType <IReportTranslatorFabric, ReportTranslatorFabric>(reuseScope)
        .RegisterTranslator <HtmlReportTranslator>(ReportFileType.Html, reuseScope)
        .RegisterTranslator <PdfReportTranslator>(ReportFileType.Pdf, reuseScope);
コード例 #32
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container

        // repositories
        .RegisterRepository <Authorities, IAuthorityRepository, AuthorityRepository>(reuseScope)
        .RegisterRepository <Configuration, IConfigurationRepository, ConfigurationRepository>(reuseScope)
        .RegisterRepository <Cultures, ICultureRepository, CultureRepository>(reuseScope)
        .RegisterRepository <NotificationRules, INotificationRuleRepository, NotificationRuleRepository>(reuseScope)
        .RegisterRepository <Projects, IProjectRepository, ProjectRepository>(reuseScope)
        .RegisterRepository <Plugins, IPluginRepository, PluginRepository>(reuseScope)
        .RegisterRepository <UserProjectSettings, IUserProjectSettingsRepository, UserProjectSettingsRepository>(
            reuseScope)
        .RegisterRepository <Reports, IReportRepository, ReportRepository>(reuseScope)
        .RegisterRepository <Roles, IRoleRepository, RoleRepository>(reuseScope)
        .RegisterRepository <RoleAuthorities, IRoleAuthorityRepository, RoleAuthorityRepository>(reuseScope)
        .RegisterRepository <Tasks, ITaskRepository, TaskRepository>(reuseScope)
        .RegisterLocalized <Tables, ITableRepository, TableRepository>(reuseScope)
        .RegisterLocalized <TableColumns, ITableColumnsRepository, TableColumnsRepository>(reuseScope)
        .RegisterRepository <Users, IUserRepository, UserRepository>(reuseScope)
        .RegisterRepository <UserInterfaces, IUserInterfaceRepository, UserInterfaceRepository>(reuseScope)
        .RegisterRepository <ScanAgents, IScanAgentRepository, ScanAgentRepository>(reuseScope)
        .RegisterRepository <TaskResults, ITaskResultRepository, TaskResultRepository>(reuseScope)
        .RegisterRepository <Events, IEventRepository, EventRepository>(reuseScope)
        .RegisterRepository <Queries, IQueryRepository, QueryRepository>(reuseScope)
        .RegisterRepository <Queue, IQueueRepository, QueueRepository>(reuseScope)
        .RegisterRepository <Templates, ITemplateRepository, TemplateRepository>(reuseScope)
        .RegisterRepository <QueryEntityNames, IQueryEntityNameRepository, QueryEntityNameRepository>(reuseScope)
        .RegisterRepository <WorkflowActions, IWorkflowActionRepository, WorkflowActionRepository>(reuseScope)
        .RegisterRepository <WorkflowRules, IWorkflowRuleRepository, WorkflowRuleRepository>(reuseScope)
        .RegisterRepository <PolicyRules, IPolicyRuleRepository, PolicyRuleRepository>(reuseScope)
        .RegisterRepository <SettingValues, ISettingValuesRepository, SettingValuesRepository>(reuseScope)
        .RegisterRepository <Settings, ISettingRepository, SettingRepository>(reuseScope)
        .RegisterRepository <SettingGroups, ISettingGroupRepository, SettingGroupRepository>(reuseScope)

        .RegisterRepository <ProjectTelemetry, IProjectTelemetryRepository, ProjectTelemetryRepository>(reuseScope)
        .RegisterRepository <QueryTelemetry, IQueryTelemetryRepositroy, QueryTelemetryRepository>(reuseScope)
        .RegisterRepository <ReportTelemetry, IReportTelemetryRepository, ReportTelemetryRepository>(reuseScope)
        .RegisterRepository <TaskTelemetry, ITaskTelemetryRepository, TaskTelemetryRepository>(reuseScope)
        .RegisterRepository <VcsPluginTelemetry, IVcsPluginTelemetryRepository, VcsPluginTelemetryRepository>(reuseScope)
        .RegisterRepository <ItPluginTelemetry, IItPluginTelemetryRepository, ItPluginTelemetryRepository>(reuseScope)

        // tools
        .RegisterType <IUserLocalizationProvider, UserLocalizationProvider>(reuseScope)
        .RegisterType <IDbContextFactory, SdlContextFactory>(reuseScope)
        .RegisterType <IUnitOfWork, UnitOfWork>(reuseScope)
        .RegisterType <IDbContextProvider, UnitOfWork>(reuseScope);
コード例 #33
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// The reuse scope is set to none (transient).
        /// </summary>
        /// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredType(this Container container, Type serviceType,
                                                 ReuseScope scope = ReuseScope.None)
        {
            //Don't try to register base service classes
            if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
            {
                return;
            }

            //获取到Container 的 RegisterAutoWired 方法
            //但是 都是接受泛型参数的
            //所以要把获取到的Method改成用泛型Method
            var methodInfo         = typeof(Container).GetMethod("RegisterAutoWired", Type.EmptyTypes);
            var registerMethodInfo = methodInfo.MakeGenericMethod(new[] { serviceType });

            //调用泛型注册ICO
            var registration = registerMethodInfo.Invoke(container, new object[0]) as IRegistration;

            registration.ReusedWithin(scope);
        }
コード例 #34
0
 /// <summary>
 ///   Registers binding to the specified container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="reuseScope">The reuse scope.</param>
 /// <returns>The container.</returns>
 public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) =>
 container
 .RegisterType <IRequestExecutorProvider, RequestExecutorProvider>(reuseScope)
 .RegisterType <IRequestExecutor, ScanAgentRequestExecutor>("SA", reuseScope)
 .RegisterType <ISAParameterTranslatorProvider, SAParameterTranslatorProvider>(reuseScope)
 .RegisterType <ISAParameterTranslator, VulnerabilitySearchTimeoutSAParameterTranslator>(
     typeof(VulnerabilitySearchTimeoutSAParameterTranslator).FullName,
     reuseScope)
 .RegisterType <ISAParameterTranslator, SiteAddressSAParameterTranslator>(
     typeof(SiteAddressSAParameterTranslator).FullName,
     reuseScope)
 .RegisterType <ISAParameterTranslator, LaunchParameterTranslator>(
     typeof(LaunchParameterTranslator).FullName,
     reuseScope)
 .RegisterType <ISAParameterTranslator, SolutionFileParameterTranslator>(
     typeof(SolutionFileParameterTranslator).FullName,
     reuseScope)
 .RegisterType <ISAParameterTranslator, RootScanFolderParameterTranslator>(
     typeof(RootScanFolderParameterTranslator).FullName,
     reuseScope);
コード例 #35
0
        /// <summary>
        ///   Registers binding to the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="reuseScope">The reuse scope.</param>
        /// <returns>The container.</returns>
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope)
        {
            container
            .RegisterType <IFileWriter, FileWriter>(reuseScope)
            .RegisterType <ITimeService, DateTimeService>(reuseScope)
            .RegisterType <ILog, NLogLog>(new ContainerControlledLifetimeManager())
            .RegisterType <ICommandHandlerProvider, ContainerCommandHandlerProvider>(reuseScope)
            .RegisterType <ICommandDispatcher, CommandDispatcher>(reuseScope)
            .RegisterType <IDataQueryHandlerProvider, DataQueryHandlerProvider>(reuseScope)
            .RegisterType <IDataQueryDispatcher, DataQueryDispatcher>(reuseScope)
            .RegisterType <IConfigManager, AppConfigManager>(reuseScope)
            .RegisterType <IDataSourceProvider, DataSourceProvider>(reuseScope)
            .RegisterType <IFileSystemInfoProvider, FileSystemInfoProvider>(reuseScope)
            .RegisterType <ISystemVersionProvider, AssemblySystemVersionProvider>(reuseScope)
            .RegisterType <IHtmlEncoder, HtmlEncoder>(reuseScope)

            .RegisterType <IInstallationLicenceIdProvider, ConfigInstallationLicenceIdProvider>(reuseScope)
            .RegisterType <ILicenceProvider, LicenceProvider>(reuseScope);

            return(container);
        }
コード例 #36
0
        public IUnityContainer Register(IUnityContainer container, ReuseScope reuseScope) => container
        .RegisterType <IDataSourceAccessValidator, DataSourceAccessValidator>(reuseScope)
        .RegisterType <IDataSourceFieldAccessValidator, DataSourceFieldAccessValidator>(reuseScope)
        .RegisterType <IDataSourceFieldInfoProvider, DataSourceFieldInfoProvider>(reuseScope)
        .RegisterType <IDataSourceInfoProvider, DataSourceInfoProvider>(reuseScope)
        .RegisterType <IConfigurationProvider, DatabaseConfigurationProvider>(reuseScope)
        .RegisterType <IMailClient, MailClient>(reuseScope)
        .RegisterType <IMailConnectionParametersProvider, DatabaseMailConnectionParametersProvider>(reuseScope)
        .RegisterType <IMailProvider, MailProvider>(reuseScope)
        .RegisterType <IEventProvider, EventProvider>(reuseScope)
        .RegisterType <IMessageQueue, DatabaseMessageQueue>(reuseScope)
        .RegisterType <ISdlPolicyProvider, SdlPolicyProvider>(reuseScope)
        .RegisterType <ITemplateProvider, TemplateProvider>(reuseScope)
        .RegisterType <ITemplateBuilder, TemplateBuilder>(reuseScope)
        .RegisterType <IAuthorityProvider, AuthorityProvider>(reuseScope)
        .RegisterType <IVulnerabilitySeverityResolver, XmlVulnerabilitySeverityResolver>(reuseScope)
        .RegisterType <IVulnerabilityShortTypeResolver, XmlVulnerabilityShortTypeResolver>(reuseScope)
        .RegisterType <IDataSourceAuthorityNameBuilder, DataSourceAuthorityNameBuilder>(reuseScope)
        .RegisterType <IDataSourceAuthorityProvider, DataSourceAuthorityProvider>(reuseScope)
        .RegisterType <ITagDataSourceProvider, TagDataSourceProvider>(reuseScope)
        .RegisterType <ITagEntityProvider, TagEntityProvider>(reuseScope)
        .RegisterType <ITagEntityRepositoryProvider, TagEntityRepositoryProvider>(reuseScope)
        .RegisterType <ITagProvider, TagProvider>(reuseScope)
        .RegisterType <ITagService, TagService>(reuseScope)
        .RegisterType <ITagValidator, TagValidator>(reuseScope)

        .RegisterType <IEntityTelemetryCreatorProvider, EntityTelemetryCreatorProvider>(reuseScope)
        .RegisterType <ITelemetryInitializer, TelemetryInitializer>(reuseScope)
        .RegisterType <ITelemetryRepositoryResolver, TelemetryRepositoryResolver>(reuseScope)
        .RegisterType <ITelemetryQueue, TelemetryQueue>(reuseScope)
        .RegisterType <ITelemetryRouter, TelemetryRouter>(reuseScope)
        .RegisterType <ITelemetryScopeProvider, TelemetryScopeProvider>(reuseScope)
        .RegisterType <ITelemetryScopeProvider, TelemetryScopeProvider>(reuseScope)

        .RegisterEntityTelemetryCreator <Projects, ProjectTelemetryCreator>(reuseScope)
        .RegisterEntityTelemetryCreator <Queries, QueryTelemetryCreator>(reuseScope)
        .RegisterEntityTelemetryCreator <Reports, ReportTelemetryCreator>(reuseScope)
        .RegisterEntityTelemetryCreator <Tasks, TaskTelemetryCreator>(reuseScope)
        .RegisterEntityTelemetryCreator <VcsPluginInfo, VcsPluginTelemetryCreator>(reuseScope)
        .RegisterEntityTelemetryCreator <ItPluginInfo, ItPluginTelemetryCreator>(reuseScope);
コード例 #37
0
		/// <summary>
		/// Registers the types in the IoC container and
		/// adds auto-wiring to the specified types.
		/// The reuse scope is set to none (transient).
		/// </summary>
		/// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredTypes(this Container container, IEnumerable<Type> serviceTypes, 
            ReuseScope scope = ReuseScope.None)
		{
			foreach (var serviceType in serviceTypes)
                container.RegisterAutoWiredType(serviceType, scope);
		}
コード例 #38
0
ファイル: ServiceEntry.cs プロジェクト: Qasemt/NServiceKit
		/// <summary>
		/// Specifies the scope for instances, which determines 
		/// visibility of instances across containers and hierarchies.
		/// </summary>
		public IOwned ReusedWithin(ReuseScope scope)
		{
			this.Reuse = scope;
			return this;
		}
コード例 #39
0
        /// <summary>
        /// Registers the type in the IoC container and
        /// adds auto-wiring to the specified type.
        /// The reuse scope is set to none (transient).
        /// </summary>
        /// <param name="serviceTypes"></param>
        public static void RegisterAutoWiredType(this Container container, string name, Type serviceType,
            ReuseScope scope = ReuseScope.None)
        {
            //Don't try to register base service classes
            if (serviceType.IsAbstract || serviceType.ContainsGenericParameters)
                return;

            var methodInfo = typeof(Container).GetMethod("RegisterAutoWired", new[] { typeof(string) });
            var registerMethodInfo = methodInfo.MakeGenericMethod(new[] { serviceType });

            var registration = registerMethodInfo.Invoke(container, new[] { name }) as IRegistration;
            registration.ReusedWithin(scope);
        }