inversion-of-control

What are “High-level modules” and “low-level modules” (in the context of Dependency inversion principle)?

我只是一个虾纸丫 提交于 2019-12-21 10:16:16
问题 I was reading Wikipedia's definition of Dependency inversion principle, and it uses two terms High-level modules and low-level modules , which I wasn't able to figure out. What are they and what does Dependency inversion principle have to do with them? 回答1: The definition of those are given in the introductory sentence: high level: policy setting low level: dependency modules. In laymen's terms: high level modules depend on low level modules, but shouldn't depend on their implementation. This

Smalltalk and IoC

大憨熊 提交于 2019-12-21 09:19:15
问题 I see a lot of IoC frameworks for .Net and Java. Does anyone know why there are no equivalent frameworks for Smalltalk. This is more a philosophy question than anything else. I'm wondering if there is something in the Smalltalk way of doing things that precludes the necessity of having an IoC framework. 回答1: MVC was invented on Smalltalk and is arguably the original Inversion of Control framework. While somewhat more lightweight than its java counterparts, it has the basic concepts of a model

Castle Windsor/DelegatingHandler/IPrincipal Dependency Injection (DI)/Inversion of Control (IoC) in ASP.NET Web API

99封情书 提交于 2019-12-21 05:23:16
问题 I decided to clean this post up and I posted a sample project at ge.tt/3EwoZEd/v/0?c Spent around 30 hours on this already and still can't figure it out... help would be really appreciated! I have an ASP.NET Web API solution that uses this code: http://www.piotrwalat.net/basic-http-authentication-in-asp-net-web-api-using-message-handlers/ to implement "Basic HTTP authentication in ASP.NET Web API using Message Handlers". I'm new to IoC/DI and I'm trying to get this to work with Castle Windsor

Where and how to use interceptors in web application?

血红的双手。 提交于 2019-12-21 04:27:29
问题 I am interested in interceptor concept in recent times. I know that this concept is used in many libraries like NHibernate, Entity Framework and others. But i am interested in how to use this concept in ASP.NET MVC web application. Where it is usefull to use it in Mvc Web application? Is there any open source Asp.Net Mvc project which use interceptors ? Asp.net Mvc already support a kind of interceptor for controller with filters. It is better to use filters instead of interceptors ? 回答1:

Ninject.MVC3, Pass DependencyResolver to service-layer?

懵懂的女人 提交于 2019-12-21 03:56:41
问题 In a MVC3-application with Ninject.MVC 2.2.0.3 (after merge), instead of injecting repostories directly into controllers I'm trying to make a service-layer that contain the businesslogic and inject the repostories there. I pass the ninject-DependencyResolver to the service-layer as a dynamic object (since I don't want to reference mvc nor ninject there). Then I call GetService on it to get repositories with the bindings and lifetimes I specify in NinjectHttpApplicationModule. EDIT: In short,

Appropriate Repository LifeCycle Scope w/ Ninject in MVC

风流意气都作罢 提交于 2019-12-21 02:35:22
问题 What is the appropriate LifeCycle Scope for a repository and the EF context when using Entity Framework 4 with Ninject in an MVC 3 application? I've been using the default of InTransientScope, but questioning whether it should be InRequestScope. public class MyController: Controller { private readonly IMyRepo _repo; public MyController(IMyRepo repo) { _repo = repo; } public ActionResult Index() { var results = _repo.GetStuff(); return View(results); } } Ninject Module: public class MyServices

Using an existing IoC Container in SignalR 2.0

眉间皱痕 提交于 2019-12-21 02:22:12
问题 How can I use an existing IoC with SignalR 2.0? From the tutorial, it seems I need to setup a class to be called from OWIN via an attribute: using Microsoft.Owin; using Owin; [assembly: OwinStartup(typeof(SignalRChat.Startup))] namespace SignalRChat { public class Startup { public void Configuration(IAppBuilder app /*HOW AM I GONNA GET UNITY CONTAINER HERE?*/) { var hubConfig = new HubConfiguration() { EnableJSONP = true, EnableDetailedErrors = true, EnableJavaScriptProxies = true, Resolver =

Is Spring's @Autowired a huge performance issue?

▼魔方 西西 提交于 2019-12-21 02:01:07
问题 I have a project that has... I dunno... 200-300 daos/services/controllers and I use @Autowired to wire everything together rather than specify everything in the applicationContext.xml . My question is, how much of a performance impact does this have on my startup times? Would it be worth it to remove all of the @Autowired annotations and actually wire this application up manually via the applicationContext.xml ? From an architectural point of view, I like @Autowired . I don't want to add

Compress UIImage to certain size in megabytes [duplicate]

你。 提交于 2019-12-21 01:26:30
问题 This question already has answers here : image compression by size - iPhone SDK (7 answers) Closed 4 years ago . In obj-с how does one get the size of a certain UIImage stored in a custom NSMutableArray ? That's the first thing I want to do. And the second is, knowing that the image is bigger in file size (say it's 15 MB) than my own file size limit (say it's 5 MB) how does one compress the image to be the closest to the file size limit, say 4.99 MB? 回答1: i have seen this on another question

JavaScript DI/IoC equivalents to standard DI patterns for statically typed languages

假装没事ソ 提交于 2019-12-20 10:46:58
问题 .NET and Java both have a slew of DI/IoC containers available to them and each have a number of patterns that I've found very useful at various points in working with them. I'm now at a point where I would like to do equivalent things in JavaScript. As JavaScript is a dynamic language, I don't expect DI/IoC containers to have direct equivalents to all the functionality provided by the containers found in statically typed languages so alternatives to these patterns are welcome. I also expect