构建一个适用于 WP7、Iphone 和 WP7 的应用程序安卓

发布于 2024-10-25 16:35:52 字数 418 浏览 2 评论 0原文

我即将开始构建一个可在所有平台上使用的应用程序。我将使用 monotouch 和 monodriod,这样我就可以将东西保留在 .net 中。

我有点懒,所以我希望能够重用尽可能多的代码。

假设我想创建一个存储联系信息的应用程序。例如姓名和电话号码

我的应用程序需要能够从 Web 服务检索数据并在本地存储数据。

MVVM 模式看起来像是可行的方法,但我不确定下面的方法是否 100% 正确,

这是正确的吗?

  1. 包含我的模型的项目
  2. 包含我的视图、本地存储方法以及我将视图绑定到的视图模型的项目。在这种情况下,将有 3 个基于 3 个操作系统的不同项目
  3. 用于绑定到服务和本地数据存储的数据访问层项目

任何建议都会很棒。

感谢您抽出时间

I am about to start building an app that will be used across all platforms. I will using monotouch and monodriod so I can keep things in .net

I'm a little lazy so I want to be able to reuse as much code as possible.

Lets say I want to create an application that stores contact information. e.g. Name & Phone number

My application needs to be able to retrieve data from a web service and also store data locally.

The MVVM pattern looks like the way to go but im not sure my approach below is 100% correct

Is this correct?

  1. A project that contains my models
  2. A project that contains my views,local storage methods and also view models which I bind my views to. In this case there would be 3 different projects based on the 3 os's
  3. A data access layer project that is used for binding to services and local data storage

Any suggestions would be great.

Thanks for your time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

似狗非友 2024-11-01 16:35:52

没有具体回答你的问题,但这里有一些懒惰的指针......

  • 你绝对可以在所有 3 个平台(加上 MonoWebOS?!)上重用大量代码,
  • 重用代码非常容易,但你需要维护单独的项目文件对于每个平台上的每个库(这可能是一件苦差事),
  • MVVM 当然适用于 WP7。 MonoTouch 和 MonoDroid 并没有很好地满足
  • 您需要为每个设备单独编码的一些主要领域:
    • UI 抽象 - 每个平台都有自己的“选项卡”、“列表”、“toasts”等概念
    • 网络操作 - System.Net 功能略有不同
    • 文件IO
    • 多任务处理能力
    • 设备交互(例如位置、拨打电话等)
  • 接口抽象和 IoC(Ninject?)可以帮助解决所有这些
  • 相同的单元测试应该能够运行所有 3 个平台?

更新 - 我不敢相信我只是偶然发现了自己的答案...:) 除了这个答案之外,您可能还想看看 MonoCross 和 MvvmCross - 毫无疑问还有很多其他混合平台:

Not specifically answering your question, but here are some lazy pointers...

  • you can definitely reuse a lot of code across all 3 platforms (plus MonoWebOS?!)
  • reusing the code is pretty easy, but you'll need to maintain separate project files for every library on each platform (this can be a chore)
  • MVVM certainly works for WP7. It's not quite as well catered for in MonoTouch and MonoDroid
  • some of the main areas you'll need to code separately for each device are:
    • UI abstractions - each platform has their own idea of "tabs", "lists", "toasts", etc
    • network operations - the System.Net capabilities are slightly different on each
    • file IO
    • multitasking capabilities
    • device interaction (e.g. location, making calls etc)
  • interface abstraction and IoC (Ninject?) could help with all of these
  • The same unit tests should be able to run all 3 platforms?

Update - I can't believe I just stumbled across my own answer... :) In addition to this answer, you might want to look at MonoCross and MvvmCross - and no doubt plenty of other hybrid platforms on the way:

旧梦荧光笔 2024-11-01 16:35:52

Jonas Follesoe 的跨平台开发演讲:成为目前最全面的资源。他谈论了如何最好地共享代码和资源,抽象出大部分 UI 和 UX 差异,展示了跨平台可行的 MVVM 可重用用法,以及用于组合几乎自动化构建的出色技术。 (是的,这包括一种在 Visual Studio 上编译单点触控内容的方法)

最重要的是,他拥有成品的可用源代码以及单独放置在自己的研讨会项目中的许多主要组件的源代码,以及详细说明执行步骤的 50 多页 pdf。github 上的 FlightsNorway

IMO 唯一缺少的是如何最好地处理跨所有平台的本地数据存储。在这种情况下,我会引导您访问 Vici Cool Storage 一个可以与 WP7 一起使用的 ORM, MonoTouch 和(虽然没有官方支持)MonoDroid。

*免责声明* 站点文档不是最新的,但源代码可用。 (因为文档对于许多程序员来说就是 Kriptonite)

Jonas Follesoe's cross platform development talk: Has to be the most comprehensive resource out there at the moment. He talks about how best to share code and resources, abstract out much of the UI and UX differences, shows viable reusable usage of MVVM across platforms and nice techniques for putting together an almost automated build. (yes, that includes a way for you to compile you monotouch stuff on Visual Studio)

Best of all he has a available source code for the finished product and for a number of the major component individually placed in its own workshop project and a 50 + page pdf detailing the steps to do so.FlightsNorway on github

IMO the only thing missing is how best to handle local data storage across all platforms. In which case I would direct you to Vici Cool Storage an ORM that can work with WP7, MonoTouch and (while not officially supported) MonoDroid.

*Disclaimer* The site documentation isn't the most updated but the source code is available. (Because documentation is Kriptonite to many a programmer)

你另情深 2024-11-01 16:35:52

我认为编写一次代码并使其在所有三个平台上运行的最简单方法可能是基于 Web 的应用程序。例如,请查看 Untappd

I think the easiest way to write the code once and have it work on all three platforms will probably be a web-based application. Check out Untappd for example.

相思碎 2024-11-01 16:35:52

您可以首先查看 Robert Kozak 的 MonoTouch MVVM 框架。但这只是一个开始。

MonoTouch MVVM

You can start by looking at Robert Kozak's MonoTouch MVVM framework. It's just a start though.

MonoTouch MVVM

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文