protected void RegisterCommands() { var baseType = typeof(ICommandExecutor <>); foreach (var assembly in assemblies) { try { if (assembly.IsDynamic) { continue; } var types = assembly.GetExportedTypes(); foreach (var type in types) { foreach (var item in type.GetInterfaces()) { if (item.IsInterface && item.IsGenericType && item.GetGenericTypeDefinition() == baseType) { register.Register(item, type); break; } } } } catch (FileNotFoundException ex) { } catch (Exception ex) { throw ex; } } }
private static void RegisterPaymentProviders(IDependencyRegister host) { host.Register <IPaymentProviderRegistry>(CartConfiguration.PaymentProviderRegistry); host.Register <PaymentProviderFactory, IPaymentProviderFactory>(ComponentLifestyle.Transient); host.Register <MonerisCanadaPaymentProvider>(ComponentLifestyle.Transient); host.Register <OnSitePOSPaymentProvider>(ComponentLifestyle.Transient); }
private static void RegisterShippingTrackingProviders(IDependencyRegister host) { host.Register <IShippingTrackingProviderRegistry>(CartConfiguration.ShippingTrackingProviderRegistry); host.Register <ShippingTrackingProviderFactory, IShippingTrackingProviderFactory>(ComponentLifestyle.Transient); host.Register <NullShippingTrackingProvider>(ComponentLifestyle.Transient); CartConfiguration.ShippingTrackingProviderRegistry.RegisterProvider <NullShippingTrackingProvider>(CartConfiguration.DefaultShippingTrackingProviderName); }
public MongoDBWriteDataTest() { _dependencyRegister = new UnityDependencyRegister(); ApplicationConfig.SetDependencyResolver(_dependencyRegister.GetResolver()); _dependencyRegister.Register <IDBService, MongoDBService>(); _dependencyRegister.Register <IJSONValidator, JSONValidator>(); _dependencyRegister.RegisterInstance <IAppSettingService>(AppSettingService.Instance); _dependencyRegister.Register <IEncryption, EncryptionService>(); _dependencyRegister.RegisterInstance <IViewEngine>(RazorTemplateEngine.GetEngine()); _dependencyRegister.Register <IKeyValueStorage, FileKeyValueFileStorage>(); }
public static IDependencyRegister AddSingleton <TService, TImplementation>(this IDependencyRegister register) where TImplementation : class, TService where TService : class { register.Register(typeof(TService), typeof(TImplementation), Lifetime.Singleton); return(register); }
public static IDependencyRegister AddSingleton <TService, TImplementation>(this IDependencyRegister register, Func <IDependencyResolver, TService> instanceCreator) where TImplementation : class, TService where TService : class { register.Register(typeof(TService), instanceCreator, Lifetime.Singleton); return(register); }
public static IDependencyRegister AddSingleton <TService>(this IDependencyRegister register, TService instance) where TService : class { register.Register(typeof(TService), _ => instance, Lifetime.Singleton); return(register); }
public static IDependencyRegister AddSingleton(this IDependencyRegister register, Type type, Type implementationType) { register.Register(type, implementationType, Lifetime.Singleton); return(register); }
public static IDependencyRegister AddTransient <TService, TImplementation>(this IDependencyRegister register, Func <IDependencyResolver, TImplementation> instanceCreator) where TService : class where TImplementation : class, TService { register.Register(typeof(TService), instanceCreator, Lifetime.Transient); return(register); }