Ejemplo n.º 1
0
        public void Register(IDependencyContainer container, IDependencyResolver resolver)
        {
            container.RegisterType <IConfiguration, JsonConfiguration>();
            container.RegisterType <IConfiguration, JsonConfiguration>("json");
            container.RegisterType <IConfiguration, XmlConfiguration>("xml");

            container.RegisterSingletonType <IRocketSettingsProvider, RocketSettingsProvider>();

            container.RegisterSingletonType <ILogger, ConsoleLogger>("console_logger");
            container.RegisterSingletonType <ILogger, ProxyLogger>("proxy_logger", null);

            container.RegisterSingletonType <IEventManager, EventManager>();

            container.RegisterSingletonType <ICommandHandler, DefaultCommandHandler>("default_cmdhandler");
            container.RegisterSingletonType <ICommandHandler, ProxyCommandHandler>("proxy_cmdhandler", null);

            container.RegisterSingletonType <IPluginManager, DllPluginManager>("dll_plugins");
            container.RegisterSingletonType <IPluginManager, NuGetPluginManager>("nuget_plugins");
            container.RegisterSingletonType <IPluginManager, ProxyPluginManager>("proxy_plugins", null);

            container.RegisterSingletonType <ICommandProvider, RocketCommandProvider>("rocket_cmdprovider");
            container.RegisterSingletonType <ICommandProvider, ProxyCommandProvider>("proxy_cmdprovider", null);

            container.RegisterSingletonType <IPermissionProvider, ConfigurationPermissionProvider>(
                "default_permissions");
            container.RegisterSingletonType <IPermissionProvider, ConsolePermissionProvider>("console_permissions");
            container.RegisterSingletonType <IPermissionProvider, ProxyPermissionProvider>("proxy_permissions", null);

            container.RegisterType <ITranslationCollection, TranslationCollection>();

            container.RegisterSingletonType <IUserManager, ProxyUserManager>();
        }
Ejemplo n.º 2
0
        public void Register(IDependencyContainer container, IDependencyResolver resolver)
        {
            container.RegisterType <IConfiguration, YamlConfiguration>("yaml", null);
            container.RegisterType <IConfiguration, JsonConfiguration>("json");
            container.RegisterType <IConfiguration, XmlConfiguration>("xml");

            container.RegisterSingletonType <IRocketConfigurationProvider, RocketConfigurationProvider>();

            container.RegisterSingletonType <ILogger, ConsoleLogger>("console_logger");
            container.RegisterSingletonType <ILogger, LoggerProxy>("proxy_logger", null);

            container.RegisterSingletonType <IEventBus, EventBus>();

            container.RegisterSingletonType <ICommandHandler, DefaultCommandHandler>("default_cmdhandler");
            container.RegisterSingletonType <ICommandHandler, CommandHandlerProxy>("proxy_cmdhandler", null);

            container.RegisterSingletonType <IPluginLoader, DefaultClrPluginLoader>("dll_plugins");
            container.RegisterSingletonType <IPluginLoader, NuGetPluginLoader>("nuget_plugins");
            container.RegisterSingletonType <IPluginLoader, PluginLoaderProxy>("proxy_plugins", null);

            container.RegisterSingletonType <ICommandProvider, RocketCommandProvider>("rocket_cmdprovider");
            container.RegisterSingletonType <ICommandProvider, CommandProviderProxy>("proxy_cmdprovider", null);

            var configPermissions = container.Activate <ConfigurationPermissionProvider>();

            container.RegisterInstance <IPermissionProvider>(configPermissions, "default_permissions", null);
            container.RegisterInstance <IPermissionChecker>(configPermissions, "default_permissions");

            container.RegisterSingletonType <IPermissionChecker, ConsolePermissionChecker>("console_checker");
            container.RegisterSingletonType <IPermissionChecker, PermissionProviderProxy>("proxy_checker", null);

            container.RegisterType <ITranslationCollection, TranslationCollection>();
            container.RegisterSingletonType <IUserManager, UserManagerProxy>();
        }
Ejemplo n.º 3
0
 protected virtual void ConfigureContainer(IDependencyContainer container)
 {
     container.RegisterType <IBootstrapperEnvironment, BootstrapperEnvironment>(true);
     container.RegisterType <ApplicationViewModel, ApplicationViewModel>(true);
     container.RegisterType <IWindowManager, WindowManager>(true);
     container.RegisterType <IViewModelManager, ViewModelManager>(true);
     container.RegisterInstance <ILayoutProvider>(CreateLayoutProvider());
 }
 public static void Instalize()
 {
     Container = new DependencyContainer();
     Container.RegisterType<CarPerformanceSimulator>().As<ICarPerformanceSimulator>();
     Container.RegisterType<RaceFactory>().As<IRaceFactory>();
     Container.RegisterType<CarFactory>().As<ICarFactory>();
     Container.RegisterType<DistanceCalculator>().As<IDistanceCalculator>();
 }
Ejemplo n.º 5
0
        public static IDependencyContainer RegisterFrameWorkTools(this IDependencyContainer container)
        {
            container.RegisterType <ICurrentDateTime, CurrentDateTime>();
            container.RegisterType <Framework.Contracts.Logging.ILoggerFactory, Framework.Tools.Logging.LoggerFactory>();
            container.RegisterType(typeof(Framework.Contracts.Logging.ILogger <>), typeof(Framework.Tools.Logging.Logger <>));

            return(container);
        }
        public void Register(IDependencyContainer container, IDependencyResolver resolver)
        {
            GameObject obj = new GameObject("Rocket.Rust");

            UnityEngine.Object.DontDestroyOnLoad(obj);

            container.RegisterSingletonInstance <IImplementation>(obj.AddComponent <Rust>());
            container.RegisterType <ILogger, UnityLogger>();
            container.RegisterType <IPlayerManager, RustPlayerManager>();
        }
Ejemplo n.º 7
0
        public void RegisterType_SuccessfullyRegistersType()
        {
            var lifecycle = Lifecycle.SingletonPerApplication;

            _container.RegisterType <IDependencyContainer, DependencyContainer>(lifecycle);

            _unityContainer
            .Received(1)
            .RegisterType <IDependencyContainer, DependencyContainer>(
                Arg.Any <ContainerControlledLifetimeManager>()
                );
        }
 public IDependencyContainer RegisterTypes(IDependencyContainer container)
 => container
 .RegisterType <IGuidWrapper, GuidWrapper>(Lifecycle.SingletonPerApplication)
 .RegisterType <IDateTimeWrapper, DateTimeWrapper>(Lifecycle.SingletonPerApplication)
 .RegisterType <IItemObtainingService, ItemObtainingService>(Lifecycle.SingletonPerRequest)
 .RegisterType <IItemCreatingService, ItemCreatingService>(Lifecycle.SingletonPerRequest)
 .RegisterType <IItemUpdatingService, ItemUpdatingService>(Lifecycle.SingletonPerRequest);
Ejemplo n.º 9
0
        protected void SetupDependencyContainer(FeatureContext context)
        {
            // register additional or swapped strategies
            foreach (var readerKeyValuePair in context.AdditionalStrategies)
            {
                var strategyType       = readerKeyValuePair.Key;
                var strategyReaderType = readerKeyValuePair.Value;

                if (_defaultImplementations.Keys.Contains(strategyType))
                {
                    // swap already registered strategy
                    _defaultImplementations[strategyType] = strategyReaderType;
                }
                else
                {
                    _defaultImplementations.Add(strategyType, strategyReaderType);
                }

                // TODO: review this
                if (!strategyReaderType.IsInterface)
                {
                    // we can create implementation only for concrete types
                    // if registered reader is interface - most probably it's registered in via IoC registry already
                    _container.RegisterType(strategyReaderType, strategyReaderType);
                }
            }
        }
 internal static void RegisterApiDependencies(Func <IRouteOptions> getRouteOptions, IDependencyContainer container)
 => container
 .RegisterType(getRouteOptions, LifetimeTypes.PerApplicationSingleton)
 .RegisterType <IResolver>(() => container, LifetimeTypes.PerApplicationSingleton)
 .RegisterDependency <RepositoryTypesBootstrapper>()
 .RegisterDependency <ApiServicesBootstrapper>()
 .RegisterDependency <ServicesTypesBootstrapper>();
Ejemplo n.º 11
0
 public void Initialize(IDependencyContainer container)
 {
     container
         .RegisterType<IMethods,Managercs>()
         .RegisterType<IRedisConnectorFactory, RedisConnectorFactory>()
         ;
 }
Ejemplo n.º 12
0
 public static IDependencyContainer RegisterTypesByName(this IDependencyContainer container, Func <string, bool> checkname, params Assembly[] assemblies)
 {
     foreach (var assembly in assemblies)
     {
         foreach (var type in assembly.GetTypes().Where(t => t.IsClass && !t.IsAbstract))
         {
             if (checkname(type.Name))
             {
                 container.RegisterType(type, type);
             }
         }
     }
     return(container);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Registers public and internal types of the given assemblies with the unity container. This is necessary
 /// to workaround the internalsvisibleto hacks in the code base.
 /// </summary>
 /// <param name="container"></param>
 /// <param name="assemblies">List of assemblies in which all types should be registered with their interfaces.
 /// This includes internal types. </param>
 /// <returns>This instance.</returns>
 public static IDependencyContainer RegisterTypesIncludingInternals(this IDependencyContainer container, params Assembly[] assemblies)
 {
     foreach (var assembly in assemblies)
     {
         foreach (var type in assembly.GetTypes().Where(t => t.IsClass && !t.IsAbstract))
         {
             string interfacename = "I" + type.Name;
             var    interfacetype = type.GetInterface(interfacename);
             if (interfacetype != null)
             {
                 container.RegisterType(interfacetype, type);
             }
         }
     }
     return(container);
 }
Ejemplo n.º 14
0
 public void Register(IDependencyContainer container, IDependencyResolver resolver)
 {
     container.RegisterType <IEntityFrameworkDatabaseProvider, InMemoryDatabaseProvider> ("InMemory");
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Registers a type for the given interface.
 /// </summary>
 /// <returns>This instance.</returns>
 public static IDependencyContainer RegisterType <TType>(this IDependencyContainer container)
 {
     container.RegisterType(typeof(TType), typeof(TType));
     return(container);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Registers a type for the given interface.
 /// </summary>
 /// <typeparam name="TInterface">Interface that can be later resolved.</typeparam>
 /// <typeparam name="TType">Type that implements interface. On Resolve&lt;TInterface&gt;() calls a new instance is returned every time.</typeparam>
 /// <returns>This instance.</returns>
 public static IDependencyContainer RegisterType <TInterface, TType>(this IDependencyContainer container) where TType : TInterface
 {
     container.RegisterType(typeof(TInterface), typeof(TType));
     return(container);
 }
Ejemplo n.º 17
0
        public void Register(IDependencyContainer container, IDependencyResolver resolver)
        {
            container.RegisterType(typeof(IStateMachineBuilder <, ,>), typeof(StateMachineBuilder <, ,>));

            LoadModuleConfig(container);
        }
        public static IDependencyContainer AddDependencies(this IDependencyContainer container)
        {
            container.RegisterType <IMappingService, MappingService>();

            container.RegisterType <IConfig, DeveloperConfig>();

            //container.RegisterType<IConfig, Config>();
            container.RegisterSingleton <ILogger, Logger>();
            container.RegisterType <IExecutionTimerLogger, ExecutionTimerLogger>();

            container.RegisterType <IDependencyContainer, DependencyContainer>();
            container.RegisterType <IHost, Host>();
            container.RegisterType <IAuthenticationManager, AuthenticationManager>();

            container.RegisterType(typeof(IService <>), typeof(BaseService <>));
            container.RegisterType <IUserService, UserService>();
            container.RegisterType <ICryptographyService, CryptographyService>();
            container.RegisterType <ICarService, CarService>();

            container.RegisterType <IUserRepository, UserRepository>();
            container.RegisterType <ICarRepository, CarRepository>();

            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(s => s.GetExportedTypes())
                        .Where(t => !t.IsAbstract && t.IsClass && t.GetInterfaces()
                               .Any(c => c.IsGenericType && typeof(IRepository <>)
                                    .IsAssignableFrom(c.GetGenericTypeDefinition())));

            foreach (var type in types)
            {
                var inheritedFrom = type.GetInterfaces()
                                    .First(x => x.IsGenericType && typeof(IRepository <>).IsAssignableFrom(x.GetGenericTypeDefinition()));

                container.RegisterType(inheritedFrom, type);
            }

            container.RegisterType <IValidator, Validator>();

            container.RegisterType <ICommandUser, CommandUser>();

            container.RegisterType <IParser, Parser>();

            container.RegisterType <IModelBinder, DefaultModelBinder>();

            var commandTypes = AppDomain.CurrentDomain.GetAssemblies()
                               .SelectMany(s => s.GetExportedTypes())
                               .Where(x => typeof(ICommand).IsAssignableFrom(x) && !x.IsAbstract && x.IsClass && x.IsDefined(typeof(CommandRouteAttribute)));

            foreach (var type in commandTypes)
            {
                var attributeValue = type.GetCustomAttributesData()
                                     .First(c => c.AttributeType == typeof(CommandRouteAttribute))
                                     .ConstructorArguments
                                     .Select(z => z.Value)
                                     .First()
                                     .ToString();

                container.RegisterType(typeof(ICommand), type, attributeValue);
            }

            return(container);
        }
 /// <summary>
 /// Registers a mapping between two specified types to the dependency container.
 /// </summary>
 public static void RegisterType <T, TU>(this IDependencyContainer container)
 {
     container.RegisterType(typeof(T), typeof(TU));
 }
 public void Register(IDependencyContainer container, IDependencyResolver resolver)
 {
     container.RegisterType <IEntityFrameworkConnectionDescriptor, EntityFrameworkConnectionDescriptor>();
     container.RegisterSingletonType <IEntityFrameworkService, EntityFrameworkService>();
 }
 public void Register(IDependencyContainer container, IDependencyResolver resolver)
 {
     container.RegisterType <IEntityFrameworkDatabaseProvider, MySqlDatabaseProvider> ("MySQL");
 }
Ejemplo n.º 22
0
 public static IDependencyContainer RegisterType <TFrom, TTo>(this IDependencyContainer container)
     where TTo : TFrom
 {
     container.RegisterType(typeof(TFrom), typeof(TTo));
     return(container);
 }
Ejemplo n.º 23
0
 public static IDependencyContainer RegisterType <TFrom, TTo>(this IDependencyContainer container, string key, bool singleton = false)
 {
     return(container.RegisterType(typeof(TFrom), typeof(TTo), key, singleton));
 }
 public IDependencyContainer RegisterTypes(IDependencyContainer container)
 => container.RegisterType <IItemRepository, ItemRepository>(Lifecycle.SingletonPerApplication);
Ejemplo n.º 25
0
 public IDependencyContainer RegisterTypes(IDependencyContainer container)
 => container
 .RegisterType(CurrentHttpRequestMessage, Lifecycle.SingletonPerRequest)
 .RegisterType <IConnectionStringWrapper, ConnectionStringWrapper>(Lifecycle.SingletonPerApplication)
 .RegisterType <IUrlService, UrlService>(Lifecycle.SingletonPerRequest);
Ejemplo n.º 26
0
 public void Register(IDependencyContainer container, IDependencyResolver resolver)
 {
     container.RegisterType <IEntityFrameworkDatabaseProvider, SqlServerCompactDatabaseProvider> ("SqlServerCompact", "SqlServerCE");
 }