{"action":"opened","issue":{"url":"https://api.github.com/repos/PrismLibrary/Prism/issues/752","repository_url":"https://api.github.com/repos/PrismLibrary/Prism","labels_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/752/labels{/name}","comments_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/752/comments","events_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/752/events","html_url":"https://github.com/PrismLibrary/Prism/issues/752","id":173973329,"number":752,"title":"Unity multiple instances ","user":{"login":"JamesPetras","id":16455026,"avatar_url":"https://avatars.githubusercontent.com/u/16455026?v=3","gravatar_id":"","url":"https://api.github.com/users/JamesPetras","html_url":"https://github.com/JamesPetras","followers_url":"https://api.github.com/users/JamesPetras/followers","following_url":"https://api.github.com/users/JamesPetras/following{/other_user}","gists_url":"https://api.github.com/users/JamesPetras/gists{/gist_id}","starred_url":"https://api.github.com/users/JamesPetras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamesPetras/subscriptions","organizations_url":"https://api.github.com/users/JamesPetras/orgs","repos_url":"https://api.github.com/users/JamesPetras/repos","events_url":"https://api.github.com/users/JamesPetras/events{/privacy}","received_events_url":"https://api.github.com/users/JamesPetras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-30T09:37:43Z","updated_at":"2016-08-30T09:37:43Z","closed_at":null,"body":"Hi Guys,\r\n\r\nnot sure is this issue 100% related to Prism or to Microsoft Unity but I came across a very strange issue. \r\n\r\nMy Service methods have been instanced in every single ViewModel instead to be a singleton.\r\n\r\nOn the following link you can find an example : [https://www.dropbox.com/s/yofe9wzqekz6y6m/Prism-master%202.zip?dl=0](url)\r\n\r\nIt is HelloWorld project with added ITestService interface and TestService class.\r\n\r\nThe interface is registered \r\n\r\n```\r\nprotected override void RegisterTypes()\r\n\t\t{\r\n\r\n\t\t\tContainer.RegisterTypeForNavigation<MainPage, SomeOtherViewModel>(); //override viewmodel convention\r\n\t\t\tContainer.RegisterTypeForNavigation<MyNavigationPage>();\r\n\t\t\tContainer.RegisterTypeForNavigation<MyMasterDetail>();\r\n\t\t\tContainer.RegisterType<ITestService, TestService>();\r\n\t\t}\r\n```\r\n\r\nand Injected to \r\n\r\n```\r\npublic MyMasterDetailViewModel(INavigationService navigationService, ITestService testService)\r\n\t\t{\r\n\t\t\t_navigationService = navigationService;\r\n\t\t\tNavigateCommand = new DelegateCommand<string>(Navigate);\r\n\t\t\t_testService = testService;\r\n```\r\n\r\nand \r\n```\r\n\tpublic SomeOtherViewModel(IPageDialogService dialogService, ITestService testService)\r\n\t\t{\r\n\t\t\t_dialogService = dialogService;\r\n\t\t\tLoadModuleACommand = new DelegateCommand(ShowDialog);\r\n\t\t\t_testService = testService;\r\n```\r\n\r\nIf you put a breakpoint in TestService Constructor \r\n\r\n```\r\npublic class TestService : ITestService\r\n\t{\r\n\t\tpublic int Calls { get; set; }\r\n\t\t\r\n\t\tpublic TestService()\r\n\t\t{\r\n\t\t\tCalls = 0;\r\n\t\t}\r\n```\r\n\r\nAnd run the app you will see TestService constructor will be called twice instead of just once\r\n\r\nI assume I'm doing something wrong here or?"}}
{"actor":{"display_login":"JamesPetras"}}