unity-container

ControllerFactory for specific portable area

心不动则不痛 提交于 2019-12-13 11:51:10
问题 My main ASP.NET MVC composite application uses a global Unity container to register types. The app sets the controller factory up to use this global container. I would like to refactor this such that each one of my portable areas leverages it's own child Unity container, so that different areas can implement interfaces in varying ways. It seems like I would need to have a different ControllerFactory per area. How would I accomplish that, given that the following sets the factory for all?

Unity IOC inject interface in ASP Control

北城以北 提交于 2019-12-13 08:18:10
问题 I want to inject an interface into an asp user control. My classes look like: public partial class PercentByState : CommonControlsData { [Dependency] public IChartService ChartService { get; set; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = ReportService.DoSomething(); } } } public class CommonControlsData : System.Web.UI.UserControl { [Dependency] public IReportService ReportService { get; set; } } I use Unity and Unity.WebForms nuget packages.

Dependency Injection using Unity in ASP.NET

这一生的挚爱 提交于 2019-12-13 07:43:30
问题 I have a pretty straight forward setup. namespace ObjectNamespace { public class CustomProcessor : ICustomProcessor<myObject> { public CustomProcessorResult Execute(myObject Data) { try { var container = new UnityContainer(); // UnityConfigurationSection section = new UnityConfigurationSection(); var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); // this gives Microsoft.Practices.Unity.Configuration.UnityConfigurationSection section.Containers.Default.Configure

C# MVC Logging method execution and performance

牧云@^-^@ 提交于 2019-12-13 07:39:00
问题 There are many other posts regarding the recording of method execution time (for example through postsharp, through action filters, or through a custom method attribute). So to record the time for a method to complete is relatively straightforward at this point. What I am looking to do however, is to get more fine-grained performance metrics on a per-request basis utilizing, for example, session id to track all operations that occured for a given request - and the time elapses for all of them

Microsoft Unity base class interception

Deadly 提交于 2019-12-13 06:12:28
问题 I have an application that has a base class and derived classes from it with each implementation class having it's own interface. I would like to use Unity's interception for exception handling on derived types of a base class. I am new to interception so I don't know all the quirks. As far as I know, I have to register interception with each implementation resolve. The point is that all of my implementations have a base class, so I thought that I could skip the redundancy and set the

Enterprise Library - Get value from ParameterValue Expression

喜夏-厌秋 提交于 2019-12-13 05:03:32
问题 I am trying to convert Enterprise Library TypeRegistration ConstructorParameters to a collection of key/value pair (a HashTable or an IDictionary in general). The ConstructorParameters property is an IEnumerableOf(ParameterValue) so my problem is how to extract the values from each ParameterValue object. Every ParameterValue object contains a Type and an Expression. For ex. if a ParameterValue contains: "EventLoggingEnabled = false" then I can get the key (which is the EventLoggingEnabled)

WPF Module toolbar prism

喜你入骨 提交于 2019-12-13 03:11:30
问题 Can anyone provide a hint on how I would populate a navigation toolbar similar to the StaffLynx Entity toolbar that the Billy Hollis video displays across bottom of the app? I only want to show a "Client" icon in the toolbar if indeed the application version running has the Client module loaded and available but am unsure how to perform this MVVM style? Thanks 回答1: What you want is your toolbar to have a region: <controls:MyToolbar Prism:RegionManager.RegionName="ToolbarRegion" /> Then ensure

ASP.Net MVC 3 - unitOfWork.Commit() not saving anything

早过忘川 提交于 2019-12-13 02:47:27
问题 I created a web application using ASP.Net MVC 3 and EF 4.1, and I am using the UnitOfWork pattern, but nothing is getting committed to the database. All this is quite new to me, and I don't know where to start to resolve this issue. I based myself on this post to create my web application: http://weblogs.asp.net/shijuvarghese/archive/2011/01/06/developing-web-apps-using-asp-net-mvc-3-razor-and-ef-code-first-part-1.aspx The final code, which can be obtained here also has a service layer and

Unity Container trying to resolve non registered type, throwing error

淺唱寂寞╮ 提交于 2019-12-13 02:11:35
问题 I've inherited an existing ASP.Net MVC project that makes use of a Unity DI container. All of its registrations are defined in web.config. When a new service / class is introduced into the project, I create it along with an Interface, and then update the config file to handle the registration. For example : <unity xmlns="http://schemas.microsoft.com/practices/2010/unity"> <assembly name="UnityDi.Contracts" /> <assembly name="UnityDi.Domain" /> <assembly name="UnityDi.Services" /> <assembly

looking for various way of implemention Dependency injection using unity

余生颓废 提交于 2019-12-13 01:18:01
问题 i am new in Dependency injection. i just got familiar how to implement dependency injection with Interface injection but we know that Dependency injection can be implemented with three way or may be more and those are :- Interface injection : The service provides an interface which consumers must implement. The interface exposes specific behaviors at run time. Setter injection : The dependent object exposes a “setter” method to inject the dependency. Constructor injection : Dependencies are