没有合适的资源?快使用搜索试试~ 我知道了~
首页Xamarin.Forms:打造跨平台C#应用覆盖iOS、Android与Windows Phone
"《跨平台C#编程:iOS、Android与Windows Phone》是一本由CHARLESPETZOLD撰写的书籍,专为想要开发移动应用的开发者提供指南。本书针对的是使用Xamarin.Forms技术进行的跨平台开发,旨在帮助读者利用C#语言在iOS、Android和Windows Phone三大主流移动操作系统上构建一致且高效的移动应用程序。 该书预览版揭示了仍在开发过程中的内容,可能包含未经最终审阅的章节。Microsoft Press出版,作为微软公司的一部分,强调了版权信息,要求未经许可不得复制或传播书中的任何内容。本书的ISBN号为978-0-7356-9723-2,全球范围内的书店和分销商都有供应。作者鼓励读者在完成阅读后通过http://aka.ms/tellpress提供反馈,以便对书籍质量进行评估。 《跨平台C#编程》不仅仅是一本技术指南,它还包含了作者对于如何利用C#进行跨平台开发的独特见解。书中不仅会深入讲解C#语言在不同平台上的应用,还会涵盖Xamarin.Forms框架的核心概念、API调用、界面设计、性能优化以及如何处理兼容性问题。此外,读者还将了解到如何处理实时更新、测试策略以及如何利用Xamarin生态系统中的其他工具来提升开发效率。 尽管这本书提供了宝贵的信息,但读者需明白,其中的内容可能会随着时间和技术的发展而变化,使用时需自行承担风险。《跨平台C#编程:iOS、Android与Windows Phone》是一本理想的资源,为那些希望扩大技术栈并进入多个移动市场领域的开发者提供了坚实的基础。"
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/9119065/bg10.jpg)
Chapter 1 How does Xamarin.Forms fit in? 3
Problem 2: Different development environments
Programmers today are accustomed to working in a sophisticated integrated development environ-
ment (IDE). Such IDEs exist for all three platforms, but of course they are different:
For iOS development, Xcode on the Mac.
For Android development, Android Studio on a variety of platforms.
For Windows Phone development, Visual Studio on the PC.
Problem 3: Different programming interfaces
All three of these platforms are based on different operating systems with different APIs. In many cases,
the three platforms all implement similar types of user-interface objects but with different names.
For example, all three platforms have something that lets the user toggle a Boolean value:
On the iPhone, it’s a “view” called UISwitch.
On Android devices, it’s a “widget” called Switch.
On Windows Phone, one possibility is a “control” called ToggleSwitchButton from the
Windows Phone Toolkit NuGet package.
Of course, the differences go far beyond the names into the programming interfaces themselves.
Problem 4: Different programming languages
Developers have some flexibility in choosing a programming language for each of these three plat-
forms, but, in general, each platform is very closely associated with a particular programming lan-
guage:
Objective-C for the iPhone
Java for Android devices
C# for Windows Phone
These three languages are cousins because they are all object-oriented descendants of C, but they
have become rather distant cousins.
For these reasons, a company that wants to target multiple platforms might very well employ three
different programmer teams, each team skilled and specialized in a particular language and API.
This language problem is particularly nasty, but it’s the problem that is the most tempting to solve:
If you could use the same programming language for these three platforms, you could at least share
some code between the platforms. This shared code likely wouldn’t be involved with the user interface
because each platform has different APIs, but there might well be application code that doesn’t touch
![](https://csdnimg.cn/release/download_crawler_static/9119065/bg11.jpg)
Chapter 1 How does Xamarin.Forms fit in? 4
the user interface at all.
A single language for these three platforms would certainly be convenient. But what language
would that be?
The C# and .NET solution
A roomful of programmers would come up with a variety of answers to the question just posed, but a
good argument can be made in favor of C#. Unveiled by Microsoft in the year 2000, C# is a fairly new
programming language, at least when compared with Objective-C and Java. At first, C# seemed to be a
rather straightforward, strongly typed, imperative object-oriented language, certainly influenced by
C++ (and Java as well), but with a much cleaner syntax than C++ and none of the historical baggage.
In addition, the first version of C# had language-level support for properties and events, which turn out
to be member types that are particularly suited for programming graphical user interfaces.
But C# has continued to grow and get better over the years. The support of generics, lambda func-
tions, LINQ, and asynchronous operations has successfully elevated C# to be classified as a multipara-
digm programming language. C# code can be traditionally imperative or flavored with declarative or
functional programming paradigms.
Also exciting is the future of C#: on April 3, 2014, C# creator Anders Hejlsberg stood on a stage at
the Microsoft Build 2014 conference and clicked a button that published an open-source version of the
C# compiler, called the .NET Compiler Platform (formerly known by its code name “Roslyn”).
Since its inception, C# has been closely associated with the Microsoft .NET Framework. At the lowest
level, .NET provides an infrastructure for the C# basic data types (int, double, string, and so forth).
But the extensive .NET Framework class library provides support for many common chores encoun-
tered in many different types of programming. These include:
Math
Debugging
Reflection
Collections
Globalization
File I/O
Networking
Security
Threading
![](https://csdnimg.cn/release/download_crawler_static/9119065/bg12.jpg)
Chapter 1 How does Xamarin.Forms fit in? 5
Web services
Data handling
XML and JSON reading and writing
Here’s another big reason for C# and .NET to be regarded as a compelling cross-platform solution:
It’s not just hypothetical. It’s a reality.
Soon after Microsoft’s announcement of .NET way back in June 2000, the company Ximian (founded
by Miguel de Icaza and Nat Friedman) initiated an open-source project called Mono to create an alter-
native implementation of the C# compiler and the .NET Framework that could run on Linux.
A decade later, in 2011, the founders of Ximian (which had been acquired by Novell) founded
Xamarin, which still contributes to the open-source version of Mono but which has also adapted Mono
to form the basis of cross-platform mobile solutions.
Shortly after the open-source version of C# was published, Scott Guthrie of Microsoft announced
the formation of the .NET Foundation, which serves as a steward for open-source .NET technologies, in
which Xamarin plays a major part.
A single language for all platforms
For the first three years of its existence, Xamarin focused mainly on compiler technologies and three
basic sets of .NET libraries:
Xamarin.Mac, which has evolved from the MonoMac project.
Xamarin.iOS, which evolved from MonoTouch.
Xamarin.Android, which evolved from Mono for Android or (more informally) MonoDroid.
Collectively, these libraries are known as the Xamarin platform. The libraries consist of .NET versions
of the native Mac, IOS, and Android APIs. Programmers using these libraries can write applications in
C# to target the native APIs of these three platforms, but also (as a bonus) with access to the .NET
Framework class library.
Xamarin also makes available Xamarin Studio, an integrated development environment that runs on
both the Mac and PC and lets you develop iPhone and Android applications on the Mac and Android
applications on the PC.
It is also possible to use Visual Studio with the Xamarin libraries to develop Mac, iPhone, and An-
droid applications. (However, Mac and iPhone development also requires a Mac with Xcode and
Xamarin Studio installed and connected through a local network with the PC.)
Of course, if you’re using Visual Studio, you can also target Windows Phone and other Microsoft
platforms.
![](https://csdnimg.cn/release/download_crawler_static/9119065/bg13.jpg)
Chapter 1 How does Xamarin.Forms fit in? 6
Sharing code
The advantage of targeting multiple platforms with a single programming language comes from the
ability to share code among the applications.
Before code can be shared, an application must be structured for that purpose. Particularly since the
widespread use of graphical user interfaces, programmers have understood the importance of separat-
ing application code into functional layers. Perhaps the most useful division is between user-interface
code and the underlying data models and algorithms. The popular MVC (Model-View-Controller) ap-
plication architecture formalizes this code separation into a Model (the underlying data), the View (the
visual representation of the data), and the Controller (which handles input from the user).
MVC originated in the 1980s. More recently, the MVVM (Model-View-ViewModel) architecture has
effectively modernized MVC based on modern GUIs. MVVM separates code into the Model (the under-
lying data), the View (the user interface, including visuals and input), and the ViewModel (which man-
ages data passing between the Model and the View).
When a programmer develops an application that targets multiple mobile platforms, the MVVM
architecture helps guide the developer into separating code into the platform-specific View—the code
that requires interacting with the platform APIs—and the platform-independent Model and View-
Model.
Often this platform-independent code needs to access files or the network or use collections or
threading. Normally these jobs would be considered part of an operating system API, but they are also
jobs that can make use of the .NET Framework class library, and if the class library is available on each
platform, it is effectively platform independent.
The part of the application that is platform independent can then be isolated and—in the context of
Visual Studio or Xamarin Studio—put into a separate project. This can be either a Shared Asset Project
(SAP)—which simply consists of code and other asset files accessible from other projects—or a Portable
Class Library (PCL), which encloses all the common code in a dynamic-link library (DLL) that can then
be referenced from other projects.
Whichever method is used, this common code has access to the .NET Framework class library, so it
can perform file I/O, handle globalization, access web services, decompose XML, and so forth.
This means that you can create a single Visual Studio solution that contains four C# projects to tar-
get the three major mobile platforms (all with access to a common SAP or PCL project), or you can use
Xamarin Studio to target iPhone and Android devices.
The following diagram illustrates the interrelationships between the Visual Studio or Xamarin Studio
projects, the Xamarin libraries, and the platform APIs:
![](https://csdnimg.cn/release/download_crawler_static/9119065/bg14.jpg)
Chapter 1 How does Xamarin.Forms fit in? 7
The boxes in the second row are the actual platform-specific applications. These apps make calls
into the common project and also (with the iPhone and Android) the Xamarin libraries that implement
the native platform APIs.
But the diagram is not quite complete: it doesn’t show the SAP or PCL making calls to the .NET
Framework class library. The PCL has access to its own version of .NET, while the SAP uses the version
of .NET incorporated into each particular platform.
In this diagram, the Xamarin.iOS and Xamarin.Android libraries seem to be substantial, and while
they are certainly important, they’re mostly just language bindings and do not significantly add any
overhead to API calls.
When the iPhone app is built, the Xamarin C# compiler generates C# Intermediate Language (IL) as
usual, but it then makes use of the Apple compiler on the Mac to generate native iPhone machine
code just like the Objective-C compiler. The calls from the app to the iPhone APIs are the same as
though the application were written in Objective-C.
For the Android app, the Xamarin C# compiler generates IL, which runs on a version of Mono on
the device alongside the Java engine, but the API calls from the app are pretty much the same as
though the app were written in Java.
For mobile applications that have very platform-specific needs, but also a potentially shareable
chunk of platform-independent code, Xamarin.iOS and Xamarin.Android provide excellent solutions.
You have access to the entire platform API, with all the power (and responsibility) that implies.
But for applications that might not need quite so much platform specificity, there is now an alterna-
tive that will simplify your life even more.
剩余452页未读,继续阅读
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/50c7a98590194ddc9f77807461238f4f_robertyuzj.jpg!1)
robertyuzj
- 粉丝: 23
- 资源: 75
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 多模态联合稀疏表示在视频目标跟踪中的应用
- Kubernetes资源管控与Gardener开源软件实践解析
- MPI集群监控与负载平衡策略
- 自动化PHP安全漏洞检测:静态代码分析与数据流方法
- 青苔数据CEO程永:技术生态与阿里云开放创新
- 制造业转型: HyperX引领企业上云策略
- 赵维五分享:航空工业电子采购上云实战与运维策略
- 单片机控制的LED点阵显示屏设计及其实现
- 驻云科技李俊涛:AI驱动的云上服务新趋势与挑战
- 6LoWPAN物联网边界路由器:设计与实现
- 猩便利工程师仲小玉:Terraform云资源管理最佳实践与团队协作
- 类差分度改进的互信息特征选择提升文本分类性能
- VERITAS与阿里云合作的混合云转型与数据保护方案
- 云制造中的生产线仿真模型设计与虚拟化研究
- 汪洋在PostgresChina2018分享:高可用 PostgreSQL 工具与架构设计
- 2018 PostgresChina大会:阿里云时空引擎Ganos在PostgreSQL中的创新应用与多模型存储
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)