public static void RegisterComponents() { var container = new UnityContainer(); // register all your components with the container here // it is NOT necessary to register your controllers // e.g. container.RegisterType<ITestService, TestService>(); container.RegisterTypes( AllClasses.FromLoadedAssemblies(), WithMappings.FromMatchingInterface, WithName.Default); container.RegisterType <DbContext, BosalMontazeDbContext>(new PerThreadLifetimeManager()); // register Automapper var config = new MapperConfiguration(cfg => { cfg.AddProfile(new BosalMappingProfile()); }); container.RegisterInstance(config.CreateMapper()); GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); }
private IList <Conflict> DetectConflicts(List <Assembly> allAssemblies) { Dictionary <Assembly, IList <Type> > providedInterfaces = new(); List <Conflict> conflictingAssemblies = new(); foreach (var assembly in allAssemblies) { var implementedInterfaces = AllClasses.FromAssemblies(assembly) .Where(t => t.IsDefined(typeof(AutoRegisterAttribute), true)) .SelectMany(t => t.GetInterfaces()) .Where(t => t.IsDefined(typeof(UniqueProviderAttribute))) .ToList(); if (!implementedInterfaces.Any()) { continue; } foreach (var otherAssembly in providedInterfaces) { var intersection = otherAssembly.Value.Intersect(implementedInterfaces).ToList(); if (intersection.Count > 0) { conflictingAssemblies.Add(new Conflict(assembly, otherAssembly.Key)); } } providedInterfaces.Add(assembly, implementedInterfaces.ToList()); } return(conflictingAssemblies); }
public ActionResult View(int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { AllClasses Data = new AllClasses(); Books book = new Cateloge().SelectBook(id); if (book == null) { ViewBag.StatusMessage = " No Any Result Founded ! "; } else { Data.Book_ = new Book { Id = book.db_Id, Name = book.Name, Class_name = (book.Class_name != null) ? book.Class_name.Name : null, Picture = book.Picture, Publish = book.Publish }; return(View(Data)); } return(View()); } }
public static void Install(IUnityContainer container) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); container.AddNewExtension <Interception>(); Assembly dataService = assemblies. SingleOrDefault(assembly => assembly.GetName().Name == "Admin.DataService"); foreach (Type t in AllClasses.FromAssemblies(dataService) .Where(t => t.Name.EndsWith("Service") && t.Name != "BaseService")) { Type interfaceType = dataService.GetType("Admin.DataService.Interface.I" + t.Name); IList <MethodInfo> mInfo = t.GetType().GetMethods().ToList(); Attribute a = Attribute.GetCustomAttribute(t, typeof(TransactionAttribute)); if (a != null) { container.RegisterType(interfaceType, t, new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <TransactionBehavior>() ); } else { container.RegisterType(interfaceType, t); } } }
public ActionResult View(int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { AllClasses Data = new AllClasses(); Data.Uniform_ = new Uniform(); Uniforms uniform = new Cateloge().SelectUniforms(id); if (uniform == null) { ViewBag.StatusMessage = " No Any Result Founded ! "; } else { Data.Uniform_ = new Uniform { Id = uniform.db_Id, Name = uniform.Name, Class_lvl_id = uniform.Class_lvl_id, Picture = uniform.Picture, Publish = uniform.Publish }; return(View(Data)); } return(View()); } }
public static void RegisterTypes(IUnityContainer container) { // Register your types here var assemblies = new Assembly[] { typeof(IConfigGateway).Assembly, typeof(IAnnouncementRepository).Assembly, typeof(IAnnouncementService).Assembly, typeof(ISessionRepository).Assembly, typeof(ISessionService).Assembly }; Func <Type, LifetimeManager> getLifetimeManager = type => { return(new PerRequestLifetimeManager()); }; container.RegisterTypes(AllClasses.FromAssemblies(assemblies), WithMappings.FromMatchingInterface, WithName.Default, getLifetimeManager); container.RegisterType <IDatabase, Database>( getLifetimeManager(typeof(Database)), new InjectionConstructor("LCMSDB")); TraceRegistrations(container); }
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) { base.ConfigureModuleCatalog(moduleCatalog); List <Assembly> allAssemblies = new List <Assembly>(); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); foreach (string dll in Directory.GetFiles(path + "/Modules/", "*.dll")) { allAssemblies.Add(Assembly.LoadFile(dll)); } AutoRegisterClasses(allAssemblies); var modules = AllClasses.FromAssemblies(allAssemblies).Where(t => t.GetInterfaces().Contains(typeof(IModule))); foreach (var module in modules) { moduleCatalog.AddModule( new ModuleInfo() { ModuleName = module.Name, ModuleType = module.AssemblyQualifiedName, Ref = "file://" + module.Assembly.Location }); } }
public ActionResult View(int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { Achvmnts achvmnt = new Cateloge().SelectAchvmnts(id); if (achvmnt == null) { ViewBag.StatusMessage = " No Any Result Founded ! "; } else { AllClasses Data = new AllClasses(); Data.Achvmnt = new Achvmnt { Id = achvmnt.db_Id, Name = achvmnt.Name, Detail = achvmnt.Detail, Picture = achvmnt.Picture, Publish = achvmnt.Publish }; return(View(Data)); } return(RedirectToAction("Index")); } }
public static void RegisterDao(IUnityContainer unityContainer) { unityContainer.RegisterTypes( AllClasses.FromLoadedAssemblies().Where(t => t.Namespace.StartsWith("Hangfire.Dao.EntityFrameworkImpl.Dao") && !t.IsAbstract), FromMatchingInterface, WithName.Default, WithLifetime.ContainerControlled, getInjectionMembers: t => InterceptorSupport); }
public ActionResult Create(AllClasses Add) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { Subjects AddSubject = new Subjects(); AddSubject.ClassLevel = Add.Subject.ClassLevel; AddSubject.Name = Add.Subject.Name; AddSubject.Date = DateTime.Today.ToString("dd-MM-yyyy"); AddSubject.Month = DateTime.Today.ToString("MMM"); AddSubject.Year = DateTime.Today.ToString("yyyy"); AddSubject.Time = DateTime.Now.ToString("HH:mm:ss"); new Cateloge().AddSubject(AddSubject); TempData["msg"] = "New Subject Have Added Successfully"; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); } }
public ActionResult All(string Search_key) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { List <Subjects> Subjects = new Cateloge().Subjects(); AllClasses Data = new AllClasses(); if (Subjects == null) { ViewBag.StatusMessage = " No Any Data Found ! "; } else { Data.Subject_s = new List <Subject>(); foreach (var gdfc in Subjects) { Subject dbr = new Subject(); dbr.Id = gdfc.db_Id; dbr.ClassLevel = gdfc.ClassLevel; dbr.ClassName = (gdfc.ClassName != null) ? gdfc.ClassName.Name : null; dbr.Name = gdfc.Name; Data.Subject_s.Add(dbr); } Data.Subject_s.TrimExcess(); return(View(Data)); } return(View()); } }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { container.RegisterType <IUnitOfWork, MyDbContext>(new PerRequestLifetimeManager()); container.RegisterType <DbContext, MyDbContext>(new PerRequestLifetimeManager()); container.RegisterType <ApplicationUserManager>(new PerRequestLifetimeManager()); container.RegisterType <IAuthenticationManager>( new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication)); container.RegisterType <ApplicationSignInManager>(new PerRequestLifetimeManager()); container.RegisterType <IIdentityMessageService, EmailService>(); RepositoriesRegistraton.Register(container); Services.Impl.Services.Register(container); container.RegisterType <IExportDataService, ExportDataServiceImpl>(); container.RegisterType <IUriService>(new InjectionFactory(c => new UriServiceImpl(new HttpContextWrapper(HttpContext.Current)))); container.RegisterType <IEmailService, EmailServiceImpl>(); container.RegisterType <IMailGunConfig, ApiSecretsStorage>(); container.RegisterType <IUserStore <User, int>, MyUserStore>(); container.RegisterType <IPluginFactory, PluginFactoryImpl>(); //TODO Automatically load all assemblies that start with JoinRpg.Experimental.Plugin.* container.RegisterTypes(AllClasses.FromLoadedAssemblies().Where(type => typeof(IPlugin).IsAssignableFrom(type)), WithMappings.FromAllInterfaces, WithName.TypeName); }
public override IEnumerable <Type> GetTypes() { var types = AllClasses.FromAssemblies(_prefixMapping.Keys) .Where(t => typeof(ValidationRule).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()) && t != typeof(CompositeValidationRule <>)); return(types); }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container.RegisterType<IProductRepository, ProductRepository>(); //My Custom codes container.RegisterTypes( AllClasses.FromLoadedAssemblies(), WithMappings.FromMatchingInterface, WithName.Default); //container.RegisterType<IProteinRepository, ProteinRepository>(new InjectionConstructor("test.data.source")); //container.RegisterInstance(typeof(IProteinRepository), new ProteinRepository("data.source")); container.RegisterType <IProteinRepository, ProteinRepository>("StandardRepository", new InjectionConstructor("std.data.source")); container.RegisterType <IProteinRepository, DebugProteinRepository>("DebugRepository", new InjectionConstructor("debug.data.source")); var repositoryType = WebConfigurationManager.AppSettings["RepositoryType"]; container.RegisterType <IProteinTrackingService, ProteinTrackingService>( new InjectionConstructor(container.Resolve <IProteinRepository>(repositoryType))); //container.RegisterType<IProteinTrackingService, ProteinTrackingService>(); //container.RegisterType<IProteinRepository, ProteinRepository>(); }
private static void AutoRegisterInterfaces(IUnityContainer container) { var allowedRootNamespaces = new[] { "VleisurePartner", "" }; var excludedRootNamespaces = new[] { "VleisurePartner.EF", "VleisurePartner.Domain" }; var interfacesWithOneImplementation = AllClasses.FromLoadedAssemblies() .Where(TypeNamespacesStartWith(allowedRootNamespaces)) .Where(TypeNamespacesNotStartWith(excludedRootNamespaces)) .SelectMany(t => t.GetInterfaces() .Select(i => new { ClassType = t, Interface = t.IsGenericType && i.IsGenericType ? i.GetGenericTypeDefinition() : i })) .Where(x => !container.IsRegistered(x.Interface)) .GroupBy(x => x.Interface) .Where(x => x.Count() == 1) .SelectMany(x => x); foreach (var registerTypePair in interfacesWithOneImplementation) { container.RegisterType(registerTypePair.Interface, registerTypePair.ClassType); } }
public static IUnityContainer CreateUnityContainer() { var container = new UnityContainer(); container.RegisterType <IMediator, Mediator>(); var types = AllClasses.FromAssemblies(typeof(Program).Assembly); container.RegisterTypes( types, WithMappings.FromAllInterfaces, GetName, GetLifetimeManager, null, true); container.RegisterInstance <SingleInstanceFactory>(t => { var pipeline = container.Resolve( typeof(MediatorPipeline <,>).MakeGenericType(t.GetGenericArguments()) ); return(pipeline); }); container.RegisterInstance <MultiInstanceFactory>(t => container.ResolveAll(t)); return(container); }
public static void Main(string[] args) { // Register var container = new UnityContainer(); container.RegisterTypes( AllClasses.FromAssembliesInBasePath(), WithMappings.FromMatchingInterface, WithName.Default, WithLifetime.PerResolve); container.RegisterType <ILogger, ConsoleLogger>(); // Resolve var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 100000; i++) { var application = container.Resolve <Application>(); } sw.Stop(); // Observe Console.WriteLine($"Unity - {sw.ElapsedMilliseconds}"); Console.Read(); }
public static void RegisterTypes(IUnityContainer container) { container.RegisterTypes( AllClasses.FromLoadedAssemblies(), WithMappings.FromMatchingInterface, WithName.Default); }
public void WithLifetimeExternallyControlled() { var container = new UnityContainer(); container.RegisterTypes( AllClasses.FromAssemblies(Assembly.Load(new AssemblyName(RegistrationByConventionAssembly1Name))), WithMappings.FromAllInterfaces, WithName.TypeName, WithLifetime.ExternallyControlled); var reg = container.Resolve <IInterface3>("TypeImplementingI3"); var reg1 = container.Resolve <IInterface3>("TypeImplementingI3"); Assert.AreSame(reg, reg1); reg = null; reg1 = null; LifetimeManager lifetimeManager = null; foreach (var registration in container.Registrations) { if (registration == null || registration.Name == null) { continue; } if (registration.Name.Contains("TypeImplementingI3")) { lifetimeManager = registration.LifetimeManager; } } Assert.IsInstanceOfType(lifetimeManager, typeof(ExternallyControlledLifetimeManager)); }
private static void RegisterTypes(IUnityContainer container) { RegisterBitlyService(container); container.RegisterType <ILuceneService, LuceneRamService>(); container.RegisterType <IUnitOfWork, UnitOfWork>(); container.RegisterType <IUserRepository, UserRepository>(); container.RegisterInstance <IDbSession>(new DbSession()); container.RegisterTypes( AllClasses.FromAssembliesInBasePath() .Where(t => t.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEntityRepository <>))), WithMappings.FromMatchingInterface, WithName.Default); container.RegisterTypes( AllClasses.FromAssembliesInBasePath() .Where(t => Attribute.IsDefined(t, typeof(BusinessLogicAttribute))), WithMappings.FromMatchingInterface, WithName.Default); // Logging registered types. foreach (var item in container.Registrations) { Debug.WriteLine(item.RegisteredType + " - " + item.MappedToType + " - " + item.Name); } }
/// <summary> /// Registers the type mappings with the Unity container. /// </summary> /// <param name="container">The unity container to configure.</param> /// <remarks> /// There is no need to register concrete types such as controllers or /// API controllers (unless you want to change the defaults), as Unity /// allows resolving a concrete type even if it was not previously /// registered. /// </remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. // Make sure to add a Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your type's mappings here. // container.RegisterType<IProductRepository, ProductRepository>(); container.RegisterTypes ( types: AllClasses.FromLoadedAssemblies().Where(x => x.Namespace.Contains("MoneyTemplateMVC")), getFromTypes: WithMappings.FromMatchingInterface, getName: WithName.Default, getLifetimeManager: WithLifetime.Custom <TransientLifetimeManager>, getInjectionMembers: null, overwriteExistingMappings: true ); var connectionString = WebConfigurationManager.ConnectionStrings["SkillTreeHomeWork"].ToString(); var providerName = WebConfigurationManager.ConnectionStrings["SkillTreeHomeWork"].ProviderName; container.RegisterType <IConnectionFactory, ConnectionFactory> ( new HierarchicalLifetimeManager(), new InjectionConstructor(connectionString, providerName) ); }
/// <summary> /// Registers the type mappings with the Unity container. /// </summary> /// <param name="container">The unity container to configure.</param> /// <remarks> /// There is no need to register concrete types such as controllers or /// API controllers (unless you want to change the defaults), as Unity /// allows resolving a concrete type even if it was not previously /// registered. /// </remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. // Make sure to add a Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your type's mappings here. // container.RegisterType<IProductRepository, ProductRepository>(); //container.RegisterType<IProteinTrackerService, ProteinTrackerService>(); //container.RegisterType<IProteinRepository, ProteinRepository>(); //container.RegisterType(AllClasses) var assemblylist = new List <Assembly> { typeof(Controllers.ProteinTrackerController).Assembly }; container.RegisterTypes( AllClasses.FromAssemblies(assemblylist), WithMappings.FromMatchingInterface, WithName.Default, WithLifetime.Transient); //container.RegisterType<IProteinRepository, ProteinRepository>(new InjectionConstructor("Default Datasource")); container.RegisterInstance(typeof(IProteinRepository), new ProteinRepository("Instance Datasource")); container.RegisterType <IProteinRepository, ProteinRepository>("StandardRepository", new InjectionConstructor("Default Datasource")); container.RegisterType <IProteinRepository, DebugProteinRepository>("DebugRepository"); container.RegisterType <IProteinTrackerService, ProteinTrackerService>( new InjectionConstructor(container.Resolve <IProteinRepository>("DebugRepository"))); }
public static void RegisterComponents() { var container = new UnityContainer(); // register all your components with the container here // it is NOT necessary to register your controllers // e.g. container.RegisterType<ITestService, TestService>(); container.RegisterType <ILeagueContext, LeagueContext>(new HierarchicalLifetimeManager()); container.RegisterType <IAuthenticationContext, AuthenticationContext>(new HierarchicalLifetimeManager()); container.RegisterType <ILeagueService, LeagueService>(new HierarchicalLifetimeManager()); container.RegisterType <IAuthenticationService, AuthenticationService>(new HierarchicalLifetimeManager()); var objectTypeInList = new List <Type>() { typeof(object) }; container.RegisterTypes(AllClasses.FromAssemblies(Assembly.GetExecutingAssembly()), type => objectTypeInList, WithName.TypeName); //container.RegisterType<HomeController, HomeController>(); container.RegisterTypes(AllClasses.FromAssemblies(typeof(UnityConfig).Assembly), WithMappings.FromMatchingInterface, WithName.Default); GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); DependencyResolver.SetResolver(new Microsoft.Practices.Unity.Mvc.UnityDependencyResolver(container)); }
private void ConfigureUnityContainer() { // This registers all classes that implements an interface using the default naming convention // (the interface has the same name as the class but with an I added in the beginning) // Example: FileSystemUtilities implement IFileSystemUtilities // All are registers as types and will be instantiated for every resolve // this is also called "register by convention" this.RegisterTypes( AllClasses.FromLoadedAssemblies(), WithMappings.FromMatchingInterface, WithName.Default, WithLifetime.PerResolve); // thanks to the above code we only need to register things that does not follow the convention // or things that we want to resolve in special ways, like singletons. // singleton, and it must be registered first sicnce everybody else may depend on config information. //unityContainer.RegisterInstance<IConfigurationContainer>(configurationContainer); // singleton. The logger must be second since everybody can be expected to create logging information. //unityContainer.RegisterInstance<ITimecutLogger>(new TimecutLogger()); // singleton //this.RegisterInstance<IFunctionAdapter>(new DefaultFunctionAdapter()); // singleton //this.RegisterInstance<IInformationAdapter>(new DefaultInformationAdapter()); }
public ActionResult View(int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { ContactsInfo contactsinfo = new Cateloge().SelectContactInfo(id); if (contactsinfo == null) { ViewBag.StatusMessage = " No Any Result Founded ! "; } else { AllClasses Data = new AllClasses(); Data.ContactInfo = new ContactInfo { Id = contactsinfo.db_Id, Title = contactsinfo.Title, Contact_Cell = contactsinfo.Contact_Cell, Contact_Phone = contactsinfo.Contact_Phone, Contact_Email = contactsinfo.Contact_Email, Contact_Website = contactsinfo.Contact_Website, Contact_Location = contactsinfo.Contact_Location, Contact_Address = contactsinfo.Contact_Address, Publish = contactsinfo.Publish }; return(View(Data)); } return(RedirectToAction("Index")); } }
public virtual IUnityContainer RegisterComponents(HttpConfiguration httpConfig, IUnityContainer aContainer = null) { var container = aContainer ?? ContainerConfiguration.Create(); container.RegisterTypes( AllClasses.FromAssemblies(Assembly.GetExecutingAssembly(), Assembly.GetAssembly(typeof(ContainerConfiguration)), Assembly.GetAssembly(typeof(SourceSystemConfiguration)), Assembly.GetAssembly(typeof(SimpleMappingEngineConfiguration))) .Where(t => t.Implements <IGlobalConfigurationTask>()), WithMappings.FromAllInterfaces, ConfiguratorName); container.RegisterType <IWebOperationContextWrapper, WebOperationContextWrapper>(); container.RegisterType <IConfigurationManager, AppConfigConfigurationManager>(new ContainerControlledLifetimeManager()); RegisterMdmServiceAssemblyNameLocators(container); AdditionalRegistrations(container); // Now get them all, and initialize them, bootstrapper takes care of ordering // There appears to be a bug in Unity 3.5 where ResolveAll fails to do exactly that.. // var globalTasks = container.ResolveAll<IGlobalConfigurationTask>().ToList(); var globalTasks = new List <IGlobalConfigurationTask>(); var registrations = container.Registrations.Where(reg => reg.RegisteredType == typeof(IGlobalConfigurationTask)); registrations.ForEach(reg => globalTasks.Add(container.Resolve <IGlobalConfigurationTask>(reg.Name))); var tasks = globalTasks.Select(task => task as IConfigurationTask).ToList(); LogConfigurationTasks(tasks); ConfigurationBootStrapper.Initialize(tasks); httpConfig.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container); return(container); }
public static void RegisterComponents() { var container = new UnityContainer(); var dbContext = new NorthwindEntities(); // register all your components with the container here // it is NOT necessary to register your controllers // e.g. container.RegisterType<ITestService, TestService>(); //Repository container.RegisterType( typeof(IRepository <>), typeof(GenericRepository <>), new TransientLifetimeManager(), new InjectionConstructor(dbContext) ); //Service container.RegisterTypes( AllClasses.FromAssemblies(true, Assembly.Load("WebApplication1.Service")), // 掃描Service組件。 WithMappings.FromMatchingInterface, overwriteExistingMappings: true, getName: WithName.Default); DependencyResolver.SetResolver(new UnityDependencyResolver(container)); }
static void Main(string[] args) { IUnityContainer container = new UnityContainer(); container.RegisterTypes( AllClasses.FromLoadedAssemblies().Where(x => x.Namespace.Contains("UnityAutoRegistration")), WithMappings.FromAllInterfaces, WithName.Default, WithLifetime.ContainerControlled); IMyMessage message = container.Resolve <IMyMessage>(); message.Write("Vulcan"); Console.WriteLine(); foreach (var item in container.Registrations) { if (item.MappedToType.Name == item.RegisteredType.Name) { continue; } Console.WriteLine($"Name : {item.Name}"); Console.WriteLine($"RegisteredType : {item.RegisteredType.Name}"); Console.WriteLine($"MappedToType : {item.MappedToType.Name}"); Console.WriteLine($"LifetimeManager : {item.LifetimeManager.LifetimeType.Name}"); Console.WriteLine(); } Console.WriteLine("Press any key for continuing..."); Console.ReadKey(); }
public ActionResult Active() { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { List <Books> Books = new Cateloge().ActiveBooks(); if (Books == null) { ViewBag.StatusMessage = " No Any Data Found ! "; } else { AllClasses Data = new AllClasses(); Data.Book_s = new List <Book>(); foreach (var gdfc in Books) { Book dbr = new Book(); dbr.Id = gdfc.db_Id; dbr.Name = gdfc.Name; dbr.Class_name = (gdfc.Class_name != null) ? gdfc.Class_name.Name : null; dbr.Picture = gdfc.Picture; Data.Book_s.Add(dbr); } Data.Book_s.TrimExcess(); return(View(Data)); } return(View()); } }
void ConfigureContainer() { _unityContainer = new UnityContainer(); //register items by convention scanning //specific assemblies var assembliesToScan = new Assembly[] { /*MyCompany.Vacation.Data*/ typeof(IEmployeeRepository).Assembly, /*MyCompany.Vacation.Web*/ typeof(ISecurityHelper).Assembly, /*MyCompany.Common.Notification*/ typeof(INotificationService).Assembly, }; _unityContainer.RegisterTypes( AllClasses.FromAssemblies(assembliesToScan), WithMappings.FromMatchingInterface, WithName.Default, WithLifetime.Transient); // Event Bus _unityContainer.RegisterType <IEventBus, AzureVacationEventBus>(); bool eventBusEnabled = false; Boolean.TryParse(WebConfigurationManager.AppSettings["EventBusEnabled"], out eventBusEnabled); _unityContainer.RegisterType <IVacationRequestRepository, VacationRequestRepository>(new InjectionConstructor(typeof(MyCompanyContext), typeof(IEventBus), typeof(IWorkingDaysCalculator), eventBusEnabled)); // Notification service _unityContainer.RegisterType <IEmailTemplatesRepository, EmailTemplatesInFileRepository>(); _unityContainer.RegisterType <INotificationService, BaseNotificationService>(); }