dependency-injection

Angular sharing data to Components using service fails

谁说我不能喝 提交于 2020-01-05 05:54:10
问题 I'm having 2 services in my angular frontend, one for API calls and one for sharing data two different components. So the second service is using the API service. If I only use the API service and subscribe my Observables inside my component, everything works fine(view in xxx.component.html). So if I declare the two services as providers inside app.module and inject the API Service inside the sharing service, it won't work any more. Using debugger, I always get variable "tmp" not defined in

Castle Windsor Dependency Injection with Multiple Concrete Implementations

流过昼夜 提交于 2020-01-05 05:31:46
问题 Is there a method for Castle Windsor to inject multiple concrete implementations of a single interface into a constructor? I want to do something like this: class Some { public Some(IService[] services) { services.Each(s => s.DoSomething(this)); } } Note, at this level I do not have access to the IWindsorContainer and would like to keep it that way. 回答1: See http://hammett.castleproject.org/?p=257 来源: https://stackoverflow.com/questions/1473665/castle-windsor-dependency-injection-with

c# JsonConverter Attribute with DependencyInjection

雨燕双飞 提交于 2020-01-05 04:58:05
问题 I'm using JsonConverter to resolve Interfaces in asp core. Here is my JsonConverter-Impl. public class InterfaceJsonConverter<T> : Newtonsoft.Json.JsonConverter { public InterfaceJsonConverter(Type[] types, ITypeRepository typeRepository=null){ ... } } and this is how I call it [JsonConverter(typeof(InterfaceJsonConverter<ISomeInterface>), new object[] {new Type[]{ typeof(MyCustomType) }})] public interface ISomeInterface{ ... } Basically this works well when I remove my optional Parameter

A function I want to Spring-inject takes varargs. Should I provide an overload that takes a list instead?

不羁的心 提交于 2020-01-05 04:55:18
问题 I have a factory method to box up some order-dependent Things: import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; public class ThingBoxProcessor { public static ThingBox forInputThings(Thing... thingsToProcess) { ThingBox thingBox = new ThingBox(); for (Thing thing : Lists.reverse(ImmutableList.copyOf(thingsToProcess))) { thingBox.store(thing); } return thingBox; } } And I inject it like so: <bean name="Things" class="ThingBoxProcessor" factory-method=

registering DbContext with multiple parameters

蓝咒 提交于 2020-01-05 04:51:05
问题 I'm trying to inject TenantProvider into DbContext public class AppDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, long> { public int? _tenantId; public ITenantProvider _tenantProvider; public AppDbContext( DbContextOptions<AppDbContext> options, ITenantProvider tenantProvider ) : base(options) { _tenantProvider = tenantProvider; } but I don't understand how to register it correctly - if I put the breakpoint in the constructor - tenantProvider is null . The bit from Startup.cs

How to avoid binding FragmentX to Fragment

╄→尐↘猪︶ㄣ 提交于 2020-01-05 04:36:10
问题 How to avoid binding FragmentX to Fragment I am having several files where I just declare the binding of a FragmentX to a Fragment (or ActivityX to Activity ) in order to be able to inject the objects as base class dependencies. Those files look like this @Module abstract class FragmentXModule { @Binds @FragmentScoped internal abstract fun bindFragment(fragmentX: FragmentX): Fragment } This is repeating over and over again. Is it possible to avoid those file creation repeat and group all

Autofac registers components multiple times

坚强是说给别人听的谎言 提交于 2020-01-05 04:13:11
问题 In a previous question about got I visualize the graph of my dependencies I got the foundation for the code I now use to visualize my dependency graph as it is resolved by Autofac. Running the code I get a tree that results in code like the following. Usd.EA.Bogfoering.WebApi.Controllers.BogfoerController (3851,7 ms. / 0,0 ms.) Depth: 0 Usd.EA.Bogfoering.WebApi.Controllers.BogfoerController (3851,7 ms. / 0,4 ms.) Depth: 1 Usd.Utilities.WebApi.Controllers.UnikOwinContext (0,1 ms. / 0,0 ms.)

How does IoC container know which named instance to inject?

╄→尐↘猪︶ㄣ 提交于 2020-01-05 04:09:06
问题 When there are multiple named implementations for a given interface, how does the container (I am using Unity in a Prism application) know which one to inject unless I call the container.Resolve with the registered name? Here is a simple example: public interface IDependencyClass { void DoSomething(); } public class DependencyClassA : IDependencyClass { void DoSomething() { } } public class DependencyClassB : IDependencyClass { void DoSomething() { } } public interface IConsumer { void

Cyclic dependency , when ovveriding ExceptionHandler [duplicate]

守給你的承諾、 提交于 2020-01-05 04:04:12
问题 This question already has an answer here : DI with cyclic dependency with custom HTTP and ConfigService (1 answer) Closed 2 years ago . I have this code: import {Injectable, ExceptionHandler, SkipSelf, Host, Optional} from '@angular/core'; import {ToastNotification} from '../toast-messages/toastNotification.service'; export class UIError extends Error { constructor (private toastMessage: string) { super(); this.toastMessage = toastMessage; } } export class MyUIError extends UIError {} export

dagger2 GC overhead limit exceeded

血红的双手。 提交于 2020-01-05 04:04:10
问题 I'm following the Dagger2 sample of TODO app but encounted with OutOfMemoryError: GC overhead limit exceeded. Along with it are 600+ warning likes: warning: Ignoring InnerClasses attribute for an anonymous inner class (org.eclipse.osgi.internal.baseadaptor.BaseStorage$StateSaver$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class