移植的.​​NET类库Windows应用商店的应用程序类库 [英] Porting A .net Class Library To Windows Store Apps Class Library

查看:196
本文介绍了移植的.​​NET类库Windows应用商店的应用程序类库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类库,面向.NET 4,并通过单声道使用在不同的平台上。 现在我想将它移植到被Windows 8中使用我知道这个名字在不断变化,但目前这是所谓的类库(Windows应用商店的应用程序),在VS2012。
我最初开始尝试端口一切便携式类库,但这被证明过于困难,因为有些事情根本就没有一个会工作的针对性所有平台上通用的做法,并支持其他的事情根本没有提供给编译器。
所以,我创建了一个Windows应用商店的类库,并创建链接到我的标准类库,这样更新一次,将同时更新现有的文件。我打算用pre-处理指令,以使两个类库之间的更改 例如

I have a class library that targets .net 4 and is used across different platforms via Mono. I now want to port it to be used by Windows 8. I know the name keeps changing but this is currently called a "Class Library (Windows Store Apps)" in VS2012.
I initially started with trying to port everything to a "Portable Class Library" but this was proving too difficult as some things simply didn't have a generic approach that would work on all platforms targeted, and other things that were supported simply weren't available to the compiler.
So I've created a Windows Store Class Library and created links to the existing files of my standard Class Library so updating once will update both. I am planning on using pre-processing directives to make changes between the two class libraries E.G

#if NETFX_CORE
    Task.Delay(someTime);
#else
    new System.Threading.ManualResetEvent(false).WaitOne(sometime);
#endif

我的问题是,如果这种方法似乎是一个明智的做法?我有同样的默认命名空间和程序集名称。难道这曾经引起问题,我的编译器?的组件针对不同的平台上,以便永远不会被同时使用在相同的应用程序,但这样做既坐在Visual Studio同一溶液

My question is if this method seems a sensible approach? I have the same default namespace and assembly name. Could this ever cause issues to my compiler? The assemblies target different platforms so would never be used together in the same application but do both sit in the same solution in Visual Studio.

推荐答案

总体而言,是的,这应该工作。具体的情况是一个坏榜样,因为这两种实现的功能完全不同,说明你可能需要重新考虑你的设计的某些方面。对于有的的情况下是的一个类似的API交换(类似语义),我个人倾向于将后面的helper方法的差异,所以我的主code并不需要担心这 - 只是助手code。反思将是一个很好的例子(改变反射是烦人深)。

Overall, yes that should work. That specific case is a poor example, because the two implementations function very differently, illustrating that you may need to rethink some aspects of your design. For cases where there is a similar API swap (with similar semantics), I personally tend to move the difference behind a helper method, so my "main" code doesn't need to worry about this - just the helper code. Reflection would be a good example of this (the changes to reflection are annoyingly deep).

这两个项目具有不同的目标平台应该罚款。我偶尔打一个IDE毛刺的地方抱怨临时文件。我认为,这是由于项目之间共享文件。我记录它<一个href="https://connect.microsoft.com/VisualStudio/feedback/details/750047/warnings-generated-for-anomylous-files-during-load"相对=nofollow>在连接

The two projects with different target platforms should be fine. I occasionally hit an IDE glitch where it complains about temp files. I think this is due to sharing files between projects. I've logged it on connect

这篇关于移植的.​​NET类库Windows应用商店的应用程序类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆