Dependency injection for .net maui converters declared in xaml - xamarin

Is it possible to use dependency injection for .net maui converters?
I've found Prism can do that: How to resolve a dependency in IValueConverter in Xamarin.Forms using Prism/DryIoC
but how about regular Microsoft.Extensions.DependencyInjection? is something similar doable? I want to reference to IOptions<ApiSettings> apiSettings inside it
I got No constructor for type 'MyConverter' has 0 parameters error if I try to use converter with 1-param constructor in xaml.

Related

How do I use custom Dependency Injection in Xamarin.Forms Shell?

Is there a way to hook into the instantiation of a DataTemplate in a ShellContent in Xamarin.Forms Shell?
I want to use an instance of a type derived from Page that is obtained through custom Dependency Injection. In order to inject ViewModel.

constructor injection for Dependency Injection

When we call an api with browser, it reaches to a correspondent controller and resolve all dependency having on constructor.
My question is who invoke unitycontainer resolve method?
I am using Microsoft.Practice.unity for implementation.

How to manually instantiate objects using Ninject for MVC 3

How is it possible to use Ninject inside ASP.NET MVC 3 to instantiate objects manually? Something as
"NinjectObject".Resolve<IMyService>();
Thank you & regards
It is better to inject dependencies instead of resolving them. Service Locator is an anti-pattern. You could for example use the following:
IMyService myService = DependencyResolver.Current.GetService<IMyService>();
But please do not use it. That's an anti-pattern.
Dependency injection is the preferred way. You should have the constructor of the class that needs this dependency take an IMyService instead of having the class fetch this dependency.

WAS 6.1 JDK & Spring Autowiring

By default, autowiring happens by propertyname. It seems if I compile my application with the WAS 6.1 JDK, spring cannot autowire my dependencies by name and then instead reverts to type which is causing an issue because of some ambiguous Validator references in my controllers. The controller properties are all of type Validator and there are 9 validators defined in the context file so spring complains that it finds too many matches. I know one way around this would be to use the actual implementation class as the type for the validator instances in my controller classes, but I want to know if anyone else has encountered this problem with autowiring by name failing when compiled with the WAS 6.1 jdk.

Where and when do Ninject Create a Controller in MVC 3

I am using the NuGet add the Ninject and Ninject.Web.Mvc reference to my project.
but i don't add register code for the controller(with a parameter constructor) binding. but it seems the controller was created correctly, i wonder how Ninject create the controller with dependency parameter withou register the controller to the ninject.
in the Ninject.Web.Mvc, and i found the following sentense in the author (ninject) 's blog,
The controller itself will be found by Ninject even without adding a binding. Of course, you can still add a binding for the controller in case you need to specify more information for the binding (e.g. an additional constructor argument).
i found a similar questions,
How does Ninject create controller in ASP.NET MVC?
the answer saids:
Ninject finds constructor for this type, injects parameters, returns controller instance
my question is : if we don't register the controller how did the NinjectResolver resolve the controller?
non-abstract classes (such as controllers) are resolved by ninject by default as Bind<TheType>().ToSelf() if there is no binding.

Resources