unity-container

Why does my Moq IEventAggregator verification fail?

旧城冷巷雨未停 提交于 2019-12-11 09:26:34
问题 I use Composite WPF(Prism) and I am trying to unit test that my Controller does in fact subscribe to a Composite Event. My subscription code looks as follows... //Init Events. this.eventAggregator.GetEvent<PlantTreeNodeSelectedEvent>().Subscribe( ShowNodeDetails, ThreadOption.UIThread); My unit testing code looks as follows (I use Moq as my Mocking Framework and Unity as my DI Framework)... Mock<PlantTreeNodeSelectedEvent> eventBeingListenedTo = new Mock<PlantTreeNodeSelectedEvent>();

Unity Interception - Custom Interception Behaviour

倾然丶 夕夏残阳落幕 提交于 2019-12-11 09:06:13
问题 I'm using a custom interception behaviour to filter records (filter is based upon who the current user is) however I'm having some difficulty (this is the body of the interceptors Invoke method) var companies = methodReturn.ReturnValue as IEnumerable<ICompanyId>; List<string> filter = CompaniesVisibleToUser(); methodReturn.ReturnValue = companies.Where(company => filter.Contains(company.CompanyId)).ToList(); The CompaniesVisibleToUser provides a string list of company id's that the user is

Cannot figure out why Unity is not injecting Identity DbContext properly

谁说我不能喝 提交于 2019-12-11 08:57:16
问题 I am new to Unity, and Identity, and I have restructured my implementation of Identity 2 to use int Keys instead of strings. I followed this article. It works great at this point. However, I am using Unity for IoC, and it works wonderfully with my repositories, however, I am struggling getting it to work with the Identity side. I followed this article to switch. I have seen questions similar to this, but all of them were using string Keys, so I assume I have something funky somewhere since I

Configuring Unity Container in Web.config

杀马特。学长 韩版系。学妹 提交于 2019-12-11 08:33:11
问题 I am trying to configure Unity with a Type that accepts as input a parameter of type Array: <type type="IPermissionCheckPlan" mapTo="CompositePlanTeamWorkroomMove" name="MovePlan"> <constructor> <param name="checks" parameterType="IPermissionCheck" > <array> <dependency name="TWR_Move" /> <dependency name="TWR_Copy" /> </array> </param> </constructor> </type> I am getting an exception when loading the container saying "Unrecognized element 'constructor'". I am using Unity 2.0. Regards 来源:

How can I set up Unity 3 to work in a console application?

可紊 提交于 2019-12-11 08:30:00
问题 I would like to get some experience using Unity 3 so I set up a console application and downloaded Unity from nuGet. However I didn't find any examples on how I can start Unity? Do I need to add some code to my main method to make a Unity container or is it normal to put that code into another file and call that? Note that I did find the "Unity hands-on labs" but these look far too complicated for a starter tutorial. I would really like to find some starter example coded in C# if anyone has

Unity Decorator Extension fails with multiple implementations

萝らか妹 提交于 2019-12-11 08:10:07
问题 I've been struggling with this problem for a couple days, and I still am not sure how to solve it. I've created a container extension for the Unity Container to enable me to easily register decorator classes in the container. This is the implementation I currently have, which is almost identical to the one in this article: public class DecoratorExtension : UnityContainerExtension { private int m_order; private Dictionary<Type, IList<DecoratorRegistration>> m_typeStacks; protected override

Problem with Prism RegionManager and Unity container

别等时光非礼了梦想. 提交于 2019-12-11 07:51:26
问题 I have a main Silverilght project and other modules and I'm using Prism to glue them together along with Unity for Dependency Injection. I have one of my modules that depends on an IRegionManager which, naturally, gets injected to it by Unity. The issue I'm running to is that, the Regions property of the RegionManager that I get doesn't contain any regions even though I have declared two of them in my Shell as follows: regions:RegionManager.RegionName="MainRegion" I can't figure out the

Registering cascading dependencies (Take 2)

狂风中的少年 提交于 2019-12-11 07:47:45
问题 I attempted to ask this question yesterday and failed completely to make sense. So I've built a reproduction to demonstrate my problem. In the following program I am resolving Bar witch should have a Foo and a Fool injected into it. Fool also has a Foo injected into it. The catch is I want Bar and Fool to both use the same Foo. In the following code that is not happening. class Program { static void Main(string[] args) { IUnityContainer container = new UnityContainer(); Console.WriteLine(

Using iBATIS.NET with generic custom collection interfaces and Unity

妖精的绣舞 提交于 2019-12-11 07:45:56
问题 I'm trying to use a generic custom collection interface (to support injection with Microsoft Patterns and Practices Unity) in a class O/R mapped with iBATIS.NET. Does anyone know if this is possible and if so how to do it? I have an IDataItemCollection<T> interface that I map to SqlDataItemCollection<T> which extends CollectionBase. I want to use the IDataItemCollection<T> in my classes so I can swap SqlDataItemCollection<T> with other classes that extend the interface through Unity. The

UnityContainer.BuildUp() - Can I make it inject new instances into properties only if these are null?

戏子无情 提交于 2019-12-11 07:44:20
问题 I'm deserializing a class like this one class AClass{ [Dependency] AnotherClass Property{ get; set; } } When I then BuildUp() the object I'd like Unity to create a new instance of AnotherClass only if the property is null and otherwise just perform a BuildUp on it. Is there a simple way to achieve this? Edit: I'm doing mvvm with wpf. The classes are view-models, I serialize them as there are some properties I want to preserve between runs and they also have some dependencies I want unity to