简体   繁体   English

Web应用程序和Xamarin.Android应用程序与服务/ API通信

[英]A web application and Xamarin.Android app communicating to a Service/API

I'm working on an .Net application in which a user can either use a Xamarin Android app or a web application to use the system. 我正在开发.Net应用程序,用户可以在其中使用Xamarin Android应用程序或Web应用程序来使用系统。 I would like to put all the business logic at one place and both the applications shall use it. 我想将所有业务逻辑放在一个地方,并且两个应用程序都应使用它。

Considering that I have "NO" experience in Web APIs or Services, how shall I design my application? 考虑到我在Web API或服务方面没有“经验”,应如何设计我的应用程序?

However, I'm ready to learn both (Web APIs or Services) if required for the implementation. 但是,如果实现需要,我准备学习两者(Web API或服务)。

Considering that I have "NO" experience in Web APIs or Services, how shall I design my application? 考虑到我在Web API或服务方面没有“经验”,应如何设计我的应用程序?

The question should rather be, do you need to call some external services, or can you do everything locally on the phones? 问题应该是,您需要致电某些外部服务,还是可以在电话上本地完成所有操作? If some external services are required, you need web API call from your different platforms. 如果需要某些外部服务,则需要从不同平台进行Web API调用。 The business logic goes in your API. 业务逻辑包含在您的API中。

If everything can be done locally, you can just share your client side code. 如果一切都可以在本地完成,则可以共享客户端代码。

As you probably know, Xamarin app's usually follow a MVVM architecture. 您可能知道,Xamarin应用程序通常遵循MVVM体系结构。 It does not mean the business logic must be in the sharing ViewModels (I actually wrote a blog post about that if it you want more information). 这并不意味着业务逻辑必须存在于共享ViewModels中(如果您需要更多信息,我实际上写了一篇博客文章 )。

The business logic must be in the domain models, and possibly some services. 业务逻辑必须在域模型中,并且可能必须在某些服务中。

Thus, in the end you can share the c# code of your domain models and business services between your xamarin app and your web application. 因此,最终您可以在xamarin应用程序和Web应用程序之间共享域模型和业务服务的c#代码。

Hope it helps. 希望能帮助到你。

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

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