{"action":"created","issue":{"url":"https://api.github.com/repos/PrismLibrary/Prism/issues/618","repository_url":"https://api.github.com/repos/PrismLibrary/Prism","labels_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/618/labels{/name}","comments_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/618/comments","events_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/618/events","html_url":"https://github.com/PrismLibrary/Prism/issues/618","id":158084488,"number":618,"title":"Unable to register multiple platform specific types or platform specific singletons","user":{"login":"jtourlamain","id":4492271,"avatar_url":"https://avatars.githubusercontent.com/u/4492271?v=3","gravatar_id":"","url":"https://api.github.com/users/jtourlamain","html_url":"https://github.com/jtourlamain","followers_url":"https://api.github.com/users/jtourlamain/followers","following_url":"https://api.github.com/users/jtourlamain/following{/other_user}","gists_url":"https://api.github.com/users/jtourlamain/gists{/gist_id}","starred_url":"https://api.github.com/users/jtourlamain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtourlamain/subscriptions","organizations_url":"https://api.github.com/users/jtourlamain/orgs","repos_url":"https://api.github.com/users/jtourlamain/repos","events_url":"https://api.github.com/users/jtourlamain/events{/privacy}","received_events_url":"https://api.github.com/users/jtourlamain/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PrismLibrary/Prism/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/PrismLibrary/Prism/labels/XF","name":"XF","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/PrismLibrary/Prism/milestones/7","html_url":"https://github.com/PrismLibrary/Prism/milestones/Prism%20for%20Xamarin%20Forms%206.2","labels_url":"https://api.github.com/repos/PrismLibrary/Prism/milestones/7/labels","id":1763264,"number":7,"title":"Prism for Xamarin Forms 6.2","description":"RTM Release of Prism for Xamarin Forms 6.2","creator":{"login":"brianlagunas","id":835562,"avatar_url":"https://avatars.githubusercontent.com/u/835562?v=3","gravatar_id":"","url":"https://api.github.com/users/brianlagunas","html_url":"https://github.com/brianlagunas","followers_url":"https://api.github.com/users/brianlagunas/followers","following_url":"https://api.github.com/users/brianlagunas/following{/other_user}","gists_url":"https://api.github.com/users/brianlagunas/gists{/gist_id}","starred_url":"https://api.github.com/users/brianlagunas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianlagunas/subscriptions","organizations_url":"https://api.github.com/users/brianlagunas/orgs","repos_url":"https://api.github.com/users/brianlagunas/repos","events_url":"https://api.github.com/users/brianlagunas/events{/privacy}","received_events_url":"https://api.github.com/users/brianlagunas/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":6,"state":"open","created_at":"2016-05-12T20:41:32Z","updated_at":"2016-06-02T14:19:57Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2016-06-02T08:22:23Z","updated_at":"2016-06-04T17:04:49Z","closed_at":null,"body":"### Package info\r\n\r\n- Platform: Xamarin Forms\r\n- Prism version: 6.1.0\r\n- Xamarin version (if applicable): 6.1.0-pre5\r\n- Other version info: Prism.Unity.Forms 6.2.0-pre5\r\n\r\n### Repro steps\r\n\r\nI want to register some services that are platform specific, so I can’t use the RegisterTypes method in the PCL. I know I can register my types via the Xamarin DependencyService (using the assembly attribute) and that Prism can auto inject them in my ViewModels.\r\nWhere can I register types directly on the container (so I can make them a singleton or register multiple types of IService)? If I register types after new App()  then the OnInitialized method is called which starts navigating before I can call appinstance.Container.\r\n\r\n```C#\r\n// AppDelegate.cs\r\npublic override bool FinishedLaunching(UIApplication app, NSDictionary options)\r\n{\r\n  global::Xamarin.Forms.Forms.Init();\r\n  var formsApp = new App();\r\n  // From here the OnInitialized is called in the formsApp that executes:\r\n  // NavigationService.NavigateAsync(\"MainPage\");\r\n  // but I still need to register my platform specific services\r\n  formsApp.Container.RegisterType<IService, HockeyAppLogger>(new ContainerControlledLifetimeManager());\r\n  formsApp.Container.RegisterType<IService, AnotherService>();\r\n  LoadApplication(formsApp);\r\n  //...\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/PrismLibrary/Prism/issues/comments/223766531","html_url":"https://github.com/PrismLibrary/Prism/issues/618#issuecomment-223766531","issue_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/618","id":223766531,"user":{"login":"brianlagunas","id":835562,"avatar_url":"https://avatars.githubusercontent.com/u/835562?v=3","gravatar_id":"","url":"https://api.github.com/users/brianlagunas","html_url":"https://github.com/brianlagunas","followers_url":"https://api.github.com/users/brianlagunas/followers","following_url":"https://api.github.com/users/brianlagunas/following{/other_user}","gists_url":"https://api.github.com/users/brianlagunas/gists{/gist_id}","starred_url":"https://api.github.com/users/brianlagunas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianlagunas/subscriptions","organizations_url":"https://api.github.com/users/brianlagunas/orgs","repos_url":"https://api.github.com/users/brianlagunas/repos","events_url":"https://api.github.com/users/brianlagunas/events{/privacy}","received_events_url":"https://api.github.com/users/brianlagunas/received_events","type":"User","site_admin":false},"created_at":"2016-06-04T17:04:49Z","updated_at":"2016-06-04T17:04:49Z","body":"I like the idea of passing an interface rather than an abstract class, since there will be no implementation provided.  Having said that, since each container project has it's own container type (IUnityContainer, IKernel, IContainer, etc) there is no standard interface I can use for registering types.\r\n\r\n@totht91 how is it an anti pattern?  You might be thinking of calling virtual methods from within an abstract ctor, which is not happening here.\r\n\r\nEither way, in order to support this, I am going to have to move the `InitializeInternal` method out of the base ctor in order for any platform specific methods to be respected during the initialization process."}}
{"actor":{"display_login":"brianlagunas"}}