[英]How to migrate a Windows Universal App to Portable Library Project?
I have previously developed a Windows Universal App. 我以前已经开发了Windows Universal App。 I would like to migrate all the non-platform specific code to place in a portable class library project for further development.How to achieve this?
我想将所有非平台特定的代码迁移到可移植类库项目中,以进行进一步的开发。如何实现此目标?
In the Windows Universal App there are some backend C# code controlling UI contents and manipulate the data as well. 在Windows Universal App中,有一些后端C#代码可控制UI内容并处理数据。 I may not able to seperate the non-platform specific code nicely.
我可能无法很好地分隔非平台特定的代码。 Can I still migrate to PCL project in this case?
在这种情况下,我仍然可以迁移到PCL项目吗?
I searched on the portable class library documentation as the link below: https://msdn.microsoft.com/library/gg597391.aspx 我在便携式类库文档中搜索了以下链接: https : //msdn.microsoft.com/library/gg597391.aspx
The description looks confusing. 该描述令人困惑。 Does it mean that I just include my previous app package in the PCL project and then everything works?
这是否意味着我只将以前的应用程序包包含在PCL项目中,然后一切正常?
You will need to extract the platform specific code. 您将需要提取平台特定的代码。 The docs you quote go in the other direction: the PCL is included in the appx package, not the app package in the PCL.
您引用的文档朝另一个方向:PCL包含在appx包中,而不是PCL中的应用包。
Depending on how entrenched the platform specific code is you may be able to separate it out via inversion of control: define an interface the PCL can use to call back into the host to acquire platform specific data which the PCL can then manipulate. 取决于特定于平台的代码的牢固程度,您可以通过控制反转将其分离:定义PCL可用于回调到主机的接口,以获取PCL随后可以操作的平台特定数据。
For example, if the current code has platform specific code to open a file and get its contents, the PCL could call a funtion in the host which opens a file and returns a stream to the contents. 例如,如果当前代码具有特定于平台的代码来打开文件并获取其内容,则PCL可以在主机中调用一个函数,该函数打开文件并向内容返回流。
How to Migrate 如何迁移
Unless you changed your question title to "how can I move platform independent portion of my code to PCL", I believe no others can easily understand your meaning. 除非您将问题标题更改为“如何将代码的平台无关部分移至PCL”,否则我相信没有其他人可以轻易理解您的意思。
I assume that you already have a Windows Universal app project in Visual Studio. 我假设您已经在Visual Studio中拥有Windows Universal应用程序项目。 Then to move code to PCL,
然后将代码移至PCL,
If you don't know what is a PCL profile, read MSDN related materials. 如果您不知道什么是PCL配置文件,请阅读MSDN相关材料。 If you don't know which source files should go to PCL, and which should remain in app project, do experiments or check out other guys' sample project.
如果您不知道哪些源文件应该转到PCL,哪些源文件应该保留在应用程序项目中,请进行实验或查看其他人的示例项目。
About The Confusion You Got 关于您的困惑
I can only say to understand what you highlighted, you should read carefully what is not highlighted in the same sentence, and the subtitle. 我只能说要了解您突出显示的内容,您应该仔细阅读同一句子中未突出显示的内容以及副标题。
Clearly when you have a PCL project, and a Windows Store/Phone app project that references the PCL, when you generate the deployment package (.appx) in Visual Studio, the final package will include every needed assemblies. 显然,当您拥有PCL项目以及引用PCL的Windows应用商店/电话应用程序项目时,在Visual Studio中生成部署程序包(.appx)时,最终程序包将包括每个所需的程序集。
It obviously isn't what you described. 显然不是您所描述的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.