public void Register(IContainerRegister container) { container .RegisterPerRequestScope <IControllerResponseHelper, ControllerResponseHelper>() .RegisterPerRequestScope <ISettingsViewHelper, SettingsViewHelper>() .RegisterPerRequestScope <ICurrentUserViewHelper, CurrentUserViewHelper>() .RegisterPerRequestScope <IPageTemplateViewFileLocator, PageTemplateViewFileLocator>() .RegisterPerRequestScope <IHtmlSanitizerHelper, HtmlSanitizerHelper>() .RegisterPerRequestScope <IPageViewModelMapper, PageViewModelMapper>() .RegisterPerRequestScope <IJavascriptViewHelper, JavascriptViewHelper>() .RegisterPerRequestScope <ICofoundryHtmlHelper, CofoundryHtmlHelper>() .RegisterPerRequestScope <IUserSessionService, UserSessionService>() .RegisterPerRequestScope <IApiResponseHelper, ApiResponseHelper>() .RegisterAll <IPageModuleViewLocationRegistration>() .RegisterAll <IModelMetaDataDecorator>() .RegisterInstance <ModelMetadataProvider, CofoundryModelMetadataProvider>() .RegisterInstance <IAntiCSRFService, AntiCSRFService>() .RegisterType <ICustomEntityTemplateSectionTagBuilderFactory, CustomEntityTemplateSectionTagBuilderFactory>() .RegisterType <IPageTemplateSectionTagBuilderFactory, PageTemplateSectionTagBuilderFactory>() .RegisterType <IPageModuleRenderer, PageModuleRenderer>() .RegisterType <IRedirectResponseHelper, RedirectResponseHelper>() .RegisterType <IPathResolver, SitePathResolver>(RegistrationOptions.Override(RegistrationOverridePriority.Low)) .RegisterType <IWebApiStartupConfiguration, WebApiStartupConfiguration>() ; }
/// <summary> /// Initializes a new instance of the <see cref="ComponentRegistration"/> class. /// </summary> /// <param name="id">Unique identifier for the component.</param> /// <param name="activator">Activator used to activate instances.</param> /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param> /// <param name="sharing">Whether the component is shared within its lifetime scope.</param> /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param> /// <param name="pipelineBuilder">The resolve pipeline builder for the registration.</param> /// <param name="services">Services the component provides.</param> /// <param name="metadata">Data associated with the component.</param> /// <param name="options">The additional registration options.</param> public ComponentRegistration( Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, InstanceOwnership ownership, IResolvePipelineBuilder pipelineBuilder, IEnumerable <Service> services, IDictionary <string, object?> metadata, RegistrationOptions options = RegistrationOptions.None) { if (services == null) { throw new ArgumentNullException(nameof(services)); } Id = id; Activator = activator ?? throw new ArgumentNullException(nameof(activator)); Lifetime = lifetime ?? throw new ArgumentNullException(nameof(lifetime)); Sharing = sharing; Ownership = ownership; _lateBuildPipeline = pipelineBuilder; Services = Enforce.ArgumentElementNotNull(services, nameof(services)); Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); Options = options; }
public override void RegisterInstance(object instance, RegistrationOptions options) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (!options.AsTypes.Any()) { options.As(instance.GetType()); } var instanceType = instance.GetType().GetTypeInfo(); foreach (var asType in options.AsTypes) { if (!asType.GetTypeInfo().IsAssignableFrom(instanceType)) { throw new InvalidOperationException($"Type {instanceType.AsType()} is not assignable to {asType}"); } _items.AddOrUpdate(asType, _ => instance, (_, __) => instance); } if (!options.IsExternallyOwned) { EnlistDisposable(instance); } }
public async ValueTask RegisterUrl(RegistrationOptions options, CancellationToken token) { if (_initialized == 0) { await Initialize(token); } const string getUrlQuery = "INSERT INTO shortened_urls (key, url, ttl) VALUES (@key, @url, @ttl);"; #if !NETSTANDARD2_0 await #endif using var connection = new NpgsqlConnection(_options.ConnectionString); await connection.OpenAsync(token); #if !NETSTANDARD2_0 await #endif using var command = new NpgsqlCommand(getUrlQuery, connection); command.Parameters.AddWithValue("key", options.Key); command.Parameters.AddWithValue("url", options.Url); command.Parameters.AddWithValue("ttl", options.Ttl switch { { } i => i, _ => DBNull.Value });
private void Register(Type type, Func <IDependencyResolver, object> resolveFn, Action <RegistrationOptions> optionsFn, InstanceScope scope, bool instantResolution) { var registration = new RegistrationOptions(); optionsFn?.Invoke(registration); _descriptors.Add(new DependencyDescriptor(type, resolveFn, registration, scope, instantResolution)); }
private void _cbTransformation_SelectedIndexChanged(object sender, EventArgs e) { int type = _cbTransformation.SelectedIndex; switch (type) { case 0: Options = RegistrationOptions.Unknown; break; case 1: Options = RegistrationOptions.XY; break; case 2: Options = RegistrationOptions.RSXY; break; case 3: Options = RegistrationOptions.Affine6; break; case 4: Options = RegistrationOptions.Perspective; break; } //if (_form.TemplateList.Count >= 1 && OldOptions != Options) // EnableApplyButton(true); //else // EnableApplyButton(false); }
public static IContainerRegister RegisterDatabase <T>(this IContainerRegister container) where T : DbContext { var options = new RegistrationOptions(); options.InstanceScope = InstanceScope.PerLifetimeScope; return(container.RegisterType <T, T>(options)); }
public PlayerRegistrationLobby() { StatusTimer = new OneShotTimer(5 * 1000 * 1000, false); m_maxPlayers = 2; Status = CreateStatusDrawString(); Status.Visible = false; Strings.Add(Status); Strings.Add(new DrawableString(new DrawingOptions() { Position = new Vector2(117, 50) }, "Press <Delete> to remove a player.")); RegistrationSelection = new RegistrationOptions(); RegisteredPlayers = new List <PlayerEntry>(); RegistrationSelection.TopLeft = new Vector2(100, 130); StringAddPlayerEntry = CreateAddPlayerStringEntry(); InsertAddPlayerString(); OnAddPlayerSelection(); UpdateEntryPositions(); Lists.Add(RegistrationSelection); }
public static IContainerRegister RegisterPerRequestScope <TRegisterAs, TConcrete>(this IContainerRegister container) where TConcrete : TRegisterAs { var options = new RegistrationOptions(); options.InstanceScope = InstanceScope.PerLifetimeScope; return(container.RegisterType <TRegisterAs, TConcrete>(options)); }
public void Register(IContainerRegister container) { container .RegisterAll <IEntityDefinition>(RegistrationOptions.SingletonScope()) .RegisterSingleton <IEntityDefinitionRepository, EntityDefinitionRepository>() .Register <IDependableEntityDeleteCommandValidator, DependableEntityDeleteCommandValidator>(); }
public void Register(IContainerRegister container) { container .RegisterSingleton <CofoundryDisplayMetadataProvider>() .RegisterAll <IModelMetadataDecorator>(RegistrationOptions.SingletonScope()) ; }
public void Register(IContainerRegister container) { var singletonOptions = RegistrationOptions.SingletonScope(); container .Register <ICustomEntityDisplayModelMapper, CustomEntityDisplayModelMapper>() .Register <ICustomEntityDataModelMapper, CustomEntityDataModelMapper>() .Register <ICustomEntityCache, CustomEntityCache>() .Register <ICustomEntityRepository, CustomEntityRepository>() .RegisterAll <ICustomEntityRoutingRule>(singletonOptions) .RegisterAll <ICustomEntityDefinition>(singletonOptions) .RegisterAll <ICustomEntityDisplayModel>() .RegisterAllGenericImplementations(typeof(ICustomEntityDisplayModelMapper <,>)) .RegisterSingleton <ICustomEntityDefinitionRepository, CustomEntityDefinitionRepository>() .Register <ICustomEntityRenderSummaryMapper, CustomEntityRenderSummaryMapper>() .Register <ICustomEntitySummaryMapper, CustomEntitySummaryMapper>() .Register <ICustomEntityVersionSummaryMapper, CustomEntityVersionSummaryMapper>() .Register <ICustomEntityDefinitionMicroSummaryMapper, CustomEntityDefinitionMicroSummaryMapper>() .Register <ICustomEntityDefinitionSummaryMapper, CustomEntityDefinitionSummaryMapper>() .Register <ICustomEntityRouteMapper, CustomEntityRouteMapper>() .Register <ICustomEntityRouteDataBuilderFactory, CustomEntityRouteDataBuilderFactory>() .RegisterAllGenericImplementations(typeof(ICustomEntityRouteDataBuilder <,>)) ; }
public void Register(IContainerRegister container) { container .Register <IEntityFrameworkSqlExecutor, EntityFrameworkSqlExecutor>() .Register <ITransactionScopeFactory, TransactionScopeFactory>(RegistrationOptions.Scoped()) .Register <ISqlParameterFactory, SqlParameterFactory>() ; }
public void Register(IContainerRegister container) { var singleInstanceRegistrationOptions = RegistrationOptions.SingletonScope(); container .RegisterGeneric(typeof(IConfigurationSettingsFactory <>), typeof(ConfigurationSettingsFactory <>), singleInstanceRegistrationOptions) .RegisterAllWithFactory(typeof(IConfigurationSettings), typeof(IConfigurationSettingsFactory <>), singleInstanceRegistrationOptions); }
public EntitiesRegistrationManager(ILogger logger, RegistrationOptions registrationOptions, NamespaceEntityRegistrar namespaceEntityRegistrar, TypeEntityRegistrar typeEntityRegistrar, ClassEntityRegistrar classEntityRegistrar) { this.logger = logger; this.registrationOptions = registrationOptions; this.namespaceEntityRegistrar = namespaceEntityRegistrar; this.typeEntityRegistrar = typeEntityRegistrar; this.classEntityRegistrar = classEntityRegistrar; }
public override void RegisterInstance(object instance, RegistrationOptions options) { if (instance is null) { throw new ArgumentNullException(nameof(instance)); } _descriptors.Add(new DependencyDescriptor(instance.GetType(), _ => instance, options, InstanceScope.Single, true)); }
public AnonymousTypeProcessor(AnonymousTypeRegistrar anonymousTypeRegistrar, TypeEntityRegistrar typeEntityRegistrar, RegistrationOptions registrationOptions) { this.anonymousTypeRegistrar = anonymousTypeRegistrar; this.typeEntityRegistrar = typeEntityRegistrar; this.registrationOptions = registrationOptions; typesToRegister = new Dictionary <TypeReference, AnonymousTypeEntityRegistrationInfo>(); typeReferencesProcessed = new HashSet <string>(); }
public void Register(IContainerRegister container) { container.Register <IVisualEditorActionResultFactory, VisualEditorActionResultFactory>(); container.RegisterAll <IVisualEditorRequestExclusionRule>(); var overrideOptions = RegistrationOptions.Override(RegistrationOverridePriority.Low); container.Register <IVisualEditorStateService, AdminVisualEditorStateService>(overrideOptions); }
public void Register(IContainerRegister container) { var overrideOptions = RegistrationOptions.Override(); container .Register <IImageAssetFileService, ImageSharpImageAssetFileService>(overrideOptions) .Register <IResizedImageAssetFileService, ImageSharpResizedImageAssetFileService>(overrideOptions) ; }
public void Register(IContainerRegister container) { var overrideOptions = RegistrationOptions.Override(); container .Register <IPageViewModelFactory, ExamplePageViewModelFactory>(overrideOptions) .Register <IPageViewModelBuilder, ExamplePageViewModelBuilder>(overrideOptions) ; }
public ClassEntityRegistrar(ClassEntityRegistrarFactory classEntityRegistrarFactory, ApiRootClassEntityRegistrar rootApiClassEntityRegistrar, ApiClassEntityRegistrar apiClassEntityRegistrar, EntitiesContext entitiesContext, NamespaceApiToTypeDefinitionConverter namespaceApiToTypeDefinitionConverter, RegistrationOptions registrationOptions) { this.classEntityRegistrarFactory = classEntityRegistrarFactory; this.rootApiClassEntityRegistrar = rootApiClassEntityRegistrar; this.apiClassEntityRegistrar = apiClassEntityRegistrar; this.entitiesContext = entitiesContext; this.namespaceApiToTypeDefinitionConverter = namespaceApiToTypeDefinitionConverter; this.registrationOptions = registrationOptions; }
public void Register(IContainerRegister container) { var registrationOptions = new RegistrationOptions() { ReplaceExisting = false }; container .Register <IObjectCacheFactory, SqlDistributedObjectCacheFactory>(registrationOptions); }
public void Register(IContainerRegister container) { if (!container.Configuration.GetValue <bool>("Cofoundry:Azure:Disabled")) { var overrideOptions = RegistrationOptions.Override(); container .Register <IFileStoreService, AzureBlobFileService>(overrideOptions); } }
public void Register(IContainerRegister container) { container .Register <IMailService, SimpleMailService>() .Register <IMailMessageRenderer, MailMessageRenderer>() .Register <IMailViewRenderer, RazorMailViewRenderer>() .Register <IMailDispatchService, DefaultMailDispatchService>() .Register <IMailDispatchSession, DebugMailDispatchSession>(RegistrationOptions.TransientScope()) .Register <IMailDispatchSessionFactory, DefaultMailDispatchSessionFactory>() ; }
public LoginModel( IOptions <RegistrationOptions> options, SignInManager <IdentityUser> signInManager, ILogger <LoginModel> logger, UserManager <IdentityUser> userManager) { RegistrationOptions = options.Value; _userManager = userManager; _signInManager = signInManager; _logger = logger; }
public RegistrationController( IAuthenticateRegistration access, IOptions <RegistrationOptions> optionsAccessor, RegistrationOrchestrator orchestrator, ILogger <RegistrationController> logger) { this.access = access; this.options = optionsAccessor.Value; this.orchestrator = orchestrator; this.logger = logger; }
public DependencyDescriptor(Type type, Func <IDependencyResolver, object> resolveFn, RegistrationOptions registration, InstanceScope scope, bool instantResolution) { Type = type; ResolveFn = resolveFn; Registration = registration; if (!registration.AsTypes.Any()) { registration.As(type); } Scope = scope; InstantResolution = instantResolution; }
/// <summary> /// Default constructor. /// </summary> public ExecutionContextDescriptor(Func <object> contextProvider, bool takeOwnership) { var options = new RegistrationOptions().As <ContextWrapper>(); if (!takeOwnership) { options.ExternallyOwned(); } ScopeConfigurator = cfg => cfg.RegisterInstance(new ContextWrapper(contextProvider, takeOwnership), options); ContextResolver = ResolveContextWrapper; }
/// <summary> /// Initializes a new instance of the <see cref="ComponentRegistration"/> class. /// </summary> /// <param name="id">Unique identifier for the component.</param> /// <param name="activator">Activator used to activate instances.</param> /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param> /// <param name="sharing">Whether the component is shared within its lifetime scope.</param> /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param> /// <param name="services">Services the component provides.</param> /// <param name="metadata">Data associated with the component.</param> /// <param name="options">Contains options for the registration.</param> public ComponentRegistration( Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, InstanceOwnership ownership, IEnumerable <Service> services, IDictionary <string, object?> metadata, RegistrationOptions options = RegistrationOptions.None) : this(id, activator, lifetime, sharing, ownership, new ResolvePipelineBuilder(PipelineType.Registration), services, metadata, options) { }
public void Register(IContainerRegister container) { if (container.Configuration.GetValue <bool>("Cofoundry:Plugins:SendGrid:Disabled")) { return; } var overrideOptions = RegistrationOptions.Override(); container .Register <IMailDispatchSession, SendGridMailDispatchSession>(overrideOptions) ; }