简体   繁体   English

在项目之间共享对象和信息

[英]Share Objects and Information between projects

I am making a windows phone application, and have divided my solution up in 4 projects. 我正在制作Windows Phone应用程序,并将我的解决方案分为4个项目。

  • WebService 网络服务
  • MainProject MainProject
  • SecondaryProject SecondaryProject
  • PortableLibrary PortableLibrary

I share models between all projects using the Portable Library. 我使用可移植库在所有项目之间共享模型。 But how to share information, I know I can share variables and other elements using Uri Scheme: 但是如何共享信息,我知道我可以使用Uri Scheme共享变量和其他元素:

NavigationService.Navigate(new Uri("/Project;component/URI.xaml", UriKind.Relative));

But what if I want to parse Complex objects? 但是,如果我想解析复杂对象怎么办?

An Example with pseudo code and program flow: 一个带有伪代码和程序流的示例:

**STARTUP->MainProject**
UILoad();                     //Login UI shown
MobileService.Authenticate(); //Authentication stored in Isolated storage through CreditVault.
NavigateTo->MainMenu();       //

**MainMenu->SecondaryProject**
NavigationService.Navigate(new Uri("/SecondaryProject;component/URI.xaml", UriKind.Relative)); 
MobileService.AccessRestrictedInformation(); //How to still be authenticated here?
SavePictureAndInformation();  //How to make Information available to all projects in the solution?

The authentication I have on the startupPage, allows me to automatically re-authenticate users, which is why I store it encrypted. 我在startupPage上具有的身份验证使我能够自动重新身份验证用户,这就是为什么将其加密存储的原因。

Questions 问题

Can the other Project access the IsolatedStorage of the first project, if so how? 另一个项目可以访问第一个项目的IsolatedStorage吗?

If I authenticate the user upon startup, will a created mobileservice in another project within the solution also be authenticated? 如果我在启动时对用户进行身份验证,是否还将对在解决方案中另一个项目中创建的移动服务进行身份验证?

Am I missing somethine smart? 我想念一些聪明的东西吗?

External Information 外部信息

I need the setup of multiple projects with pages and cannot insert them in the same project. 我需要使用页面设置多个项目,并且无法将它们插入同一项目中。 So it is not a solution to have it in the same project. 因此,将其包含在同一项目中不是解决方案。

You can share information between projects using IsolatedStorage or use the application.current.resources, from this link http://mikaelkoskinen.net/windows-phone-pass-data-between-pages-application-resources/ 您可以使用IsolatedStorage在项目之间共享信息,也可以通过以下链接使用application.current.resources http://mikaelkoskinen.net/windows-phone-pass-data-between-pages-application-resources/

Hope somebody find it useful :) 希望有人觉得有用:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM