dependency-injection

Autofac pick nested implementation based on parent dependency

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:13:45
问题 Given the example dependency tree below I would like to select the bottom level Config instance based on the top level dependency being resolved from the container e.g. TopLevelMessageConsumer would resolve the same IMessageService & IMessageQueue implementations as TopLevelMessageDispatcher but each would have their own Config instance. - TopLevelMessageConsumer - IMessageService - IMessageQueue - Config - TopLevelMessageDispatcher - IMessageService - IMessageQueue - Config I know this is

WELD-001408: Unsatisfied dependencies for type in GlassFish + Jersey 2

六月ゝ 毕业季﹏ 提交于 2019-12-13 04:13:12
问题 I am trying to inject a class into my Jersey JAX-RS application using HK2, running on GlassFish. But when I try to run my application I get this error: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied

@Autowired Spring service not injected in a managed bean

隐身守侯 提交于 2019-12-13 04:09:52
问题 I'm developping simple application with Spring using Spring Annotation, and I use Interface Repository for DAO Layer with @Repository and @Service for service layer. But the service class is not injected in the presentation layer and remains null. this is the Repository interface : @Repository public interface DemandeRepository extends JpaRepository<Demande, Integer> { } this is the service layer: public interface DemandeService { public void addDemande(Demande demande) ; } @Service public

How to access toolbar items from ViewModel Xamarin forms

老子叫甜甜 提交于 2019-12-13 04:01:27
问题 I tried to set padge in toolbar item from viewmodel I have interface called IToolbarItemBadgeService public interface IToolbarItemBadgeService { void SetBadge(Page page, ToolbarItem item, string value, Color backgroundColor, Color textColor); } I want to set badge in toolbar item i used this code after i Register the interface but it throw exception private IToolbarItemBadgeService _toolbarItemBadge; and in the constructor public MainTabPageViewModel(IToolbarItemBadgeService toolbarItemBadge)

Prism Xamarin Forms Navigation service, DependencyService

 ̄綄美尐妖づ 提交于 2019-12-13 03:57:58
问题 As Prism said, To obtain the INavigationService in your ViewModels simply ask for it as a constructor parameter https://prismlibrary.github.io/docs/xamarin-forms/Navigation-Service.html#getting-the-navigation-service like this: public SpeakPageViewModel(INavigationService navigationService) : base(navigationService) { _navigationService = navigationService; } and I want to use ITextToSpeech interface as Prism sample : public MainPageViewModel(ITextToSpeech textToSpeech) { _textToSpeech =

Read Claims from Automapper Value Resolver on NET Core

天大地大妈咪最大 提交于 2019-12-13 03:57:41
问题 I have a Automapper Mapping Profile like this: CreateMap<MyViewModel, MyDto>() .ForMember(s => s.MyProperty, opt => opt.ResolveUsing<CustomResolver>()); And this is my CustomResolver class (that aims to solve a value through the Claims): public class CustomResolver : IValueResolver<object, object, string> { private readonly HttpContext _context; public CompanyResolver(IHttpContextAccessor httpContextAccessor) { _context = httpContextAccessor.HttpContext; } public string Resolve(object source,

Aurelia - Navmenu not updating based on @computed value

狂风中的少年 提交于 2019-12-13 03:52:26
问题 I received and answer from THIS question which I think is correct however I do not get a value propagating back to the view. I have added in a number of console.logs and they are not being hit. Here is my navMenu - I wanted "loggedIn" to be true if it has a value in localstorage... <template bindable="router"> <require from="./navmenu.css"></require> <div class="main-nav"> <div class="navbar navbar-inverse"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle=

Autofac scope configuration for multi-project solution

血红的双手。 提交于 2019-12-13 03:46:10
问题 I have an ASP.NET web application which until now has been using an Autofac configuration class which has specified an InstancePerRequest() for services in the application. Since then, I have created a new console application in the same solution which will be responsible for running automated job processes. Since I can't use the InstancePerRequest configuration for my console application, then I need to make a change to my configuration. Ideally, I don't want to copy and paste all the

External Controllers and Castle

橙三吉。 提交于 2019-12-13 03:45:28
问题 FIXED: I'm leaving this in case some other Joe Schmo needs it. In the controller factory you need to register the controller so that it can be found when called. container.Kernel.AddComponent("ExternalResources", typeof(InteSoft.Web.ExternalResourceLoader.ExternalResourceController), LifestyleType.Transient); Do it like so: // Instantiate a container, taking configuration from web.config container = new WindsorContainer( new XmlInterpreter(new ConfigResource("castle")) ); // Also register all

How to inject the creation of a BroadcastReceiver object in Fragment using Dagger2?

霸气de小男生 提交于 2019-12-13 03:39:39
问题 I need to inject the creation of NetReceiver object into my Fragment but I get the following error: error: [Dagger/MissingBinding] com.example.myapp.NetReceiver.OnNetCallback cannot be provided without an @Provides-annotated method. Let me show you what I have tried. This is my NetReceiver class: public class NetReceiver extends BroadcastReceiver { private OnNetCallback onNetCallback; @Inject public NetReceiver(OnNetCallback onNetCallback) { this.onNetCallback = onNetCallback; } @Override