Resolve Types in Platform Code #2268
Unanswered
james1301
asked this question in
Xamarin.Forms
Replies: 2 comments 2 replies
-
Check out the docs on this topic: https://prismlibrary.com/docs/dependency-injection/platform-specific-services.html |
Beta Was this translation helpful? Give feedback.
2 replies
-
Better way introduce your own interface and implement that on your PlatformInitializer public interface IPlatformStartup
{
void Start(IContainerProvider container);
} Then in your App you can do something like: protected override void OnInitialized()
{
if(PlatformInitializer is IPlatformStartup ps)
{
ps.Start(Container);
}
} now you have an easy way to manage this from shared code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What would be the recommended approach to resolve types in platform specific code? The platform initializer allows you to register implementations from the platform. But how should you do it the other way round?
I am trying to using the PRISM container rather than the service container from this example: https://docs.microsoft.com/en-us/azure/developer/mobile-apps/notification-hubs-backend-service-xamarin-forms#create-a-cross-platform-xamarinforms-application.
So in this example the platform is trying to provide it's information when available and the shared code of using that information is implemented in the shared project.
Beta Was this translation helpful? Give feedback.
All reactions