unity-container

How to pass Owin context to a Repo being injected into Api controller

你离开我真会死。 提交于 2019-12-28 12:05:34
问题 I've got a MVC WebApi owin (soft hosted) project, that uses Unity for resolving controller dependencies which look like this public class PacientaiController : ODataController { private readonly IEntityRepo<Ent.Pacientas> repo; public PacientaiController(IEntityRepo<Ent.Pacientas> repo) { this.repo = repo; } the problem I'm trying to solve - is how do I pass 'OwinContex' into a Repo. public class PacientasEntityRepo:IEntityRepo<Pacientas>,IDisposable { public PacientasEntityRepo(IOwinContext

Have a module dependent Injection for State in PRISM WPF application

此生再无相见时 提交于 2019-12-25 16:00:40
问题 hi we have a PRISM WPF MVP application, we would like to have a state to share data between the views in the same module. Since PRISM by default doesnt have a state, was wondering if there is any way i could implement this. Presently i have injected a State with Dictionary as back-store, but the problem is its Global i.e available across the modules. i would really like to scope this injection being module specific. I believe unity allows registering different classes to the same interface

Unity IoC dynamic resolution

余生长醉 提交于 2019-12-25 09:43:31
问题 I want to resolve some dependencies which will only be known at runtime. I am using configuration file to configure Unity ( not programmatically ). Here is some code to show what I want to achieve. Classes: internal class WorkflowFactory : IWorkflowFactory { public IItemWorkflow GetWorkflow(string discriminator) { // return an implementation of IItemWorkflow as specified in config file return null; } } public interface IWorkflowFactory { IItemWorkflow GetWorkflow(string discriminator); }

Dependency Injection with unity in default MVC breaks sign in

蓝咒 提交于 2019-12-25 07:59:14
问题 I'm writing a web app and I have used the default Microsoft MVC site as a starting point. After this I created a database of recipes to use in my web app using entity framework and have written a repository and some business layer methods. I then used dependency injection with Unity to remove the coupling between them. I used this code placed in the MvcApplication class in global.asax.cs. private IUnityContainer Container; protected void Application_Start() { AreaRegistration.RegisterAllAreas

Initialize hierarchical tree viewmodels with unity

↘锁芯ラ 提交于 2019-12-25 07:44:47
问题 I'm investigating a change in our application to use Prism. At the moment I'm struggling with the initialization of hierarchical structures. Basically I have a base class of which other classes inherit, simplified like this: public class NodeViewModel : INodeViewModel { Node Node { get; private set; } public ObservableCollection<INodeViewModel> ChildNodeViewModels { get; private set; } public NodeViewModel(IUnityContainer container, Node node) { Node = node; ChildNodeViewModels = new

Unity Dependency Injection from usercontrol viewmodel to customUsercontrol Viewmodel

旧城冷巷雨未停 提交于 2019-12-25 07:04:12
问题 I have a UserControl which is bound to a viewmodel . The viewmodel has parameters in the constructor which is done via dependency injection. The dependency injection is working fine up to this point. And then I have a CustomUserControl which is Used in my UserControl1View . How do I get the Dependency injection working in my CustomUserControl ? I am new to dependency injection and did some research, but can't seem to get it working. I get an error on public partial class UserControl1View :

Unity & Prism Modularity - Load problems

随声附和 提交于 2019-12-25 05:05:19
问题 I need your help again please. I am working on a application with a modular concept. I want to use Prism and Unity for it. I have looked at the quickstart example from Prism and I also read this article on MSDN. My actual code looks like: public class Bootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { return this.Container.Resolve<Shell>(); } protected override void InitializeShell() { base.InitializeShell(); var window = this.Shell as Window; if (window !=

Unity & Prism Modularity - Load problems

牧云@^-^@ 提交于 2019-12-25 05:05:13
问题 I need your help again please. I am working on a application with a modular concept. I want to use Prism and Unity for it. I have looked at the quickstart example from Prism and I also read this article on MSDN. My actual code looks like: public class Bootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { return this.Container.Resolve<Shell>(); } protected override void InitializeShell() { base.InitializeShell(); var window = this.Shell as Window; if (window !=

Why does Microsoft warn from using PerRequestLifetimeManager

梦想与她 提交于 2019-12-25 04:44:11
问题 https://msdn.microsoft.com/en-us/library/microsoft.practices.unity.perrequestlifetimemanager(v=pandp.30).aspx states that: Although the PerRequestLifetimeManager lifetime manager works correctly and can help in working with stateful or thread-unsafe dependencies within the scope of an HTTP request, it is generally not a good idea to use it when it can be avoided, as it can often lead to bad practices or hard to find bugs in the end-user's application code when used incorrectly. It is

The type name or alias xxxx could not be resolved. Please check your configuration file and verify this type name

被刻印的时光 ゝ 提交于 2019-12-25 04:11:57
问题 I have the following interface defined in a RepositoryPattern project: using System.Collections.Generic; using Domain; namespace RepositoryPattern { public interface IRepository { List<Car> GetCars(); } } The unity section of my XML configuartion looks like this: <unity xmlns="http://schemas.microsoft.com/practices/2010/unity"> <namespace name="RepositoryPattern" /> <container> <register type="IRepository" mapTo="SqlServerRepository" /> </container> </unity> When I run the application, I get