ioc-container

SimpleIoC - Type not found in cache: Windows.UI.Xaml.Controls.Frame

安稳与你 提交于 2019-12-22 12:17:10
问题 I am running into the below error the first time my ViewModel is being instantiated by the SimpleIoC. I believe I have setup the container as it should be, but for some reason, I am still getting the below error. Any ideas or assistance would be very much appreciated. Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code HResult=-2146233088 Message=Type not found in cache: Windows.UI.Xaml.Controls.Frame. Source=GalaSoft.MvvmLight.Extras StackTrace: at GalaSoft

StructureMap singleton

吃可爱长大的小学妹 提交于 2019-12-22 09:29:27
问题 Are these two equivalent? 1) var store = new DocumentStore(); For<IDocumentStore>().Use(store); 2) var store = new DocumentStore(); For<IDocumentStore>().Singleton().Use(store); or For< IDocumentStore>().AlwaysUnique().Use(store); Will both of these return singleton instance of documentstore with no duplicate instances? 回答1: You will always get singleton behavior when you provide an instance instead of just a type. 回答2: AlwaysUnique() does the opposite and always creates a unique(new)

Property Inject an Array with Spring.Net

不羁的心 提交于 2019-12-22 08:23:40
问题 I've been using the Spring.Net IoC container and can use it to inject properties that are of type IList and even IList<T> but I'm a bit stumped as to how to inject a property thats of type string[] . There doesn't seem to be an <array> element defined in the XSD's and using <list> <value> </list> doesn't work either. If anyone could post the xml I need to inject using an array for a property it'd be much appreciated 回答1: As mentioned here in the documentation you can inject a string array as

Register string value for concrete name of parameter

为君一笑 提交于 2019-12-22 08:19:01
问题 I am using Autofac and I have several classes which ask for parameter of type string and name lang. Is there a way to register a string value to all parameters named "lang", so it resolves automatically? I do not want to edit any of the constructors, since it is not my code (I know accepting e.g. CultureInfo would make registration easy..) Something resulting in short syntax like builder.Register(lang => "en-US").As().Named("lang") would be ideal. Thank you. 回答1: A fairly simple way to solve

Avoiding Service Locator with AutoFac 2

血红的双手。 提交于 2019-12-22 07:44:20
问题 I'm building an application which uses AutoFac 2 for DI. I've been reading that using a static IoCHelper (Service Locator) should be avoided. IoCHelper.cs public static class IoCHelper { private static AutofacDependencyResolver _resolver; public static void InitializeWith(AutofacDependencyResolver resolver) { _resolver = resolver; } public static T Resolve<T>() { return _resolver.Resolve<T>(); } } From answers to a previous question, I found a way to help reduce the need for using my

Why use IKernel over IWindsorContainer?

旧巷老猫 提交于 2019-12-22 03:22:45
问题 I have seen in several code examples where people have used IKernel rather than use IWindsorContainer . Why is this? Here is one example: http://docs.castleproject.org/(S(kwaa14uzdj55gv55dzgf0vui))/Windsor.Windsor-tutorial-part-two-plugging-Windsor-in.ashx In the above example it came to bite me because I added a subresolver Container.Kernel.Resolver.AddSubResolver( new CollectionResolver(Container.Kernel, true)); that will allow me to inject collections... but yet it wasnt working. I figured

Can IoC and the Managed AddIn Framework (System.AddIn) work together with isolated AppDomains?

孤街浪徒 提交于 2019-12-21 20:59:09
问题 If I use Managed AddIn Framework (System.AddIn) and set it up to use separate AppDomains, can I use a centralized IoC container that is in the primary/default AppDomain? Can the IoC container resolve across the AppDomains? 回答1: I'm going to approach this answer by ignoring the MAF part of the equation, and concentrating on the AppDomain issue. An IoC container could theoretically do what you describe, assuming that the IoC entry point inherits from MarshalByRefObject or is wrapped by a class

How to do dependency injection inside ASP.NET MVC's RegisterGlobalFilters method

蹲街弑〆低调 提交于 2019-12-21 17:43:20
问题 I am still a bit new to using IOC containers and I'm struggling a bit. I am using ASP.NET MVC 5.2 with Ninject.MVC3. I have an exception filter that basically hands off to a log service: public class ExceptionLoggerFilter : IExceptionFilter { private readonly ILogService _logService; public ExceptionLoggerFilter(ILogService logService) { _logService = logService; } public void OnException(ExceptionContext filterContext) { _logService.LogError(filterContext.Exception); } } I would like to use

Laravel ioc automatic resolution - works from controller but not from custom class

穿精又带淫゛_ 提交于 2019-12-21 17:05:05
问题 Namespaces omitted for brevity... I have written the following service provider and registered in config/app.php: class OfferServiceProvider extends ServiceProvider { public function register() { $this->registerLossControlManager(); } protected function registerLossControlManager() { $this->app->bind('LossControlInterface', 'LossControl'); } } Here is my LossControlInterface interface LossControlInterface { /** * @param int $demandId * @param float $offerTotal * @param float $productTotal *

Laravel Dependency Injection in Middleware

巧了我就是萌 提交于 2019-12-21 12:04:17
问题 I am using Laravel-5.0's default Authentication Middleware, but I changed the signature of the handle function to have: public function handle($request, Closure $next, AuthClientInterface $authClient) I also registered AuthClientInterface in a Service Provider with: public function register() { $this->app->bind('App\Services\Contracts\AuthClientInterface', function() { return new AuthClient( env('AUTH_SERVER_URL'), env('AUTH_SESSION_URL'), env('AUTH_CLIENT_ID') ); }); } However, despite this,