dependency-injection

Implement dependency injection in background services in Xamarin Forms using Prism

会有一股神秘感。 提交于 2019-12-24 02:45:23
问题 I am making use of Prism in my xamarin forms project.I was able to use dependency injection(constructor injection) in my View Model without any problems.I am also making use of background services to push long running tasks in the background.How do I inject dependency in my Background services?When I try to pass the interface object as a paramater to the constructor(SyncingBackgroundingCode) ,the object(SqliteService) is null.I have registered and resolved the objects in the dependency

Get UrlHelper in middleware asp.net mvc core 2.0

北慕城南 提交于 2019-12-24 02:38:08
问题 How can I get UrlHelper in middleware. I try as below but actionContextAccessor.ActionContext return null. public void ConfigureServices(IServiceCollection services) { services.AddSession(); services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(); services.AddMvc(); services.AddSingleton<IActionContextAccessor, ActionContextAccessor>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure

How to implement a factory class using PHP - Dependancy injection

非 Y 不嫁゛ 提交于 2019-12-24 01:57:37
问题 Take the following code as an example of what i want: class SomethingController extends Factory { private $somethingRepository; public function __Construct( ISomethingRepository $repo ) { $this->somethingRepository = $repo; } } class Factory { public function __Construct() { // The following call to AddBinding would push into SomethingController the new instance of the class denoted in my AddBinding second parameter. $this->AddBinding( ISomethingRepository, MySQLSomethingRepository); // So in

Spring dependency injection null when running a test case

ⅰ亾dé卋堺 提交于 2019-12-24 01:55:08
问题 I'm working with Spring 3.0 and jUnit 4.8 and I'm trying to develop some unit test . In fact, I'm only trying to set a property (a file) of a bean using dependency injection in a test case definined in the XML loaded in the application context used by the jUnit. I'm using an XML file configuration loaded using the annotation for jUnit 4 aproach. This is the main BaseTest that all test classes used: @ContextConfiguration("/test-context.xml") @RunWith(SpringJUnit4ClassRunner.class) @Ignore

Dependency Injection - Choose DLL and class implementation at runtime through configuration file

牧云@^-^@ 提交于 2019-12-24 01:53:44
问题 I've an API DLL ( API.dll , for example) which, in addition to many other thinks, makes available an abstract class ( AbstractClass ). Now making use of that AbstractClass I've implemented it on two different dlls: First.API.Implementation.dll with ConcreteImplementation1 Second.API.Implementation.dll with ConcreteImplementation2 Both ConcreteImplementation1 and ConcreteImplementation2 are implementation of the same abstract class. What I want is an application where I can choose which of

Angular: Not able to access variables in controller using service

亡梦爱人 提交于 2019-12-24 01:20:10
问题 I am trying to share a variable between a controller and a function. But i get an error from the controller, saying this: TypeError: Cannot read property 'getSet' of undefined I have gone through numerous tutorials, but don't know where am I going wrong. My service code is like this: app.service('shareData', function() { var selected = ["plz", "print", "something"]; var putSet = function(set) { selected = set; }; var getSet = function() { return selected; }; return { putSet: putSet, getSet:

Castle Windsor IoC inject Property into Constructor

孤人 提交于 2019-12-24 01:19:41
问题 I have a session manager class that has a session property. I need to pass that into another class as a constructor parameter. How should I configure the installer for castle windsor? e.g. public interface ISessionManager { ISession CurrentSession { get; set; } } public class SessionManager : ISessionManager { private ISession _session; public ISession CurrentSession { get { return _session ?? (_session = NHibernateHelper.OpenSession()); } set { _session = value; } } } public interface

Cannot consume scoped service xxx from singleton yyy

坚强是说给别人听的谎言 提交于 2019-12-24 01:05:38
问题 I followed a blog post for 'Building Your First Web API with ASP.NET Core and Visual Studio Code'. http://www.codingflow.net/building-your-first-web-api-with-asp-net-core-and-visual-studio-code/ In this scenario, data are not saved in database but rather in memory like this: services.AddDbContext<TodoContext>(options => options.UseInMemoryDatabase()); services.AddSingleton<ITodoRepository, TodoRepository>(); You will notice: (1) UseInMemoryDatabase on DbContext (2) AddSingleton on

Configuring Ninject

亡梦爱人 提交于 2019-12-24 00:59:47
问题 Following a discussion with Remo Gloor (main dev) about our Ninject configuration, .NET memory profiling / risks for leaks / Ninject / Direct delegate roots, I'd like to get some clarity on configuring it properly for an ASP.NET webforms application. We have a requirement currently where we are doing the following: Bind<ISearchService>() .ToMethod(ctx => new BaseSearchService(ctx.Kernel.GetDefault<IDataRetrievalService>())) .InSingletonScope() .Named("BaseSearchService"); Bind<ISearchService>

Spring Boot @Autowired creating instances on a runtime

浪尽此生 提交于 2019-12-24 00:52:57
问题 As most of Spring Boot new users I have a problem with @Autowired :D I've readed a big amount of topics about this annotation here But still can't find proper solution for my problem. Let's suppose that we have this Spring Boot hierarchy: @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } Class, that we wanna instantiate every time it's called: @Service public class TestWire { public TestWire()