Cross Platform Mobile Development with.NET Greg Shackles Senior Software Engineer OLO Online...

Post on 11-Dec-2015

213 views 0 download

Transcript of Cross Platform Mobile Development with.NET Greg Shackles Senior Software Engineer OLO Online...

Cross Platform Mobile Development with .NET

Greg ShacklesSenior Software Engineer

OLO Online Orderinggreg@gregshackles.com

MARQUEE SPONSOR

PLATINUM SPONSOR

PLATINUM SPONSOR

GOLD SPONSOR

GOLD SPONSOR

GOLD SPONSOR

GOLD SPONSOR

GOLD SPONSOR

GOLD SPONSOR

SILVER SPONSORS

Who is this guy?

• Greg Shackles• greg@gregshackles.com• gregshackles.com• Twitter: @gshackles• Google+: plus.tl/gshackles• github.com/gshackles

C# To Go

• http://shackl.es/CSharpToGo

Market Share (US)

Platform Languages

Cross Platform Solutions

and many more…

Spoiler Alert

Different Platforms are…Different

!= !=

.NET to the Rescue!

What is Mono?

• Implementation of the .NET CLR• Open source• Cross platform• Supports most of .NET 4.0• mono-project.com

MonoTouch

• Bindings to CocoaTouch• .NET – LINQ, generics, etc (Moonlight)• AOT compilation• Linker• Memory management• Integrates with Interface Builder• ios.xamarin.com

Mono for Android

• Wraps Java/Android API• .NET – LINQ, generics, etc (Moonlight)• Linker• Visual Studio 2010 or MonoDevelop• android.xamarin.com• http://xamarin.com/androidbeta

Mono for Android Architecture

• Android/Managed Callable Wrappers• JNI bridges to talk between Android and Mono

Mono for Android API

• .NET events replace listener interfaces• Action replaces Runnable• Enumerations• Properties• Attributes and tooling generate configuration• Uses standard Android resource files

Why?

Sharing

Reusability Story

UI

C#

Runtime

Platform

Silverlight

Business Logic

.NET

WP7 iOS

Mono

Android

MonoTouch Mono for Android

Platform Comparison

• UI• Tooling– IDE– Designer– Emulator

• Multitasking / Lifecycle• Storage– File system– Database

• Shared Resources

Comparison: Views

WP7 iOS Android

Format XAML XIB XML

Screen PhoneApplicationPage UIViewController Activity

Layout StackPanel N/A (manual) LinearLayout

List ListBox UITableView ListView

List Item ListBox.ItemTemplate UITableViewCell View

Data Source Binding UITableViewSource BaseAdapter

Comparison: Navigation

Windows Phone 7

NavigationService.Navigate( new Uri("/NextPage.xaml?id=42", UriKind.Relative)));

iOS

NavigationController.PushViewController( new NextController(42), true);

Android

var intent = new Intent(); intent.SetClass(this, typeof (NextActivity)); intent.PutExtra(“id", 42);StartActivity(intent);

Code Sharing Techniques

• Link files• Preprocessor directives

#if MONOTOUCH

• Messaging (publish/subscribe)• Abstraction• Third party libraries– sqlite-net– TinyIoC / TinyMessenger– MonoMobile.Extensions

NYC Code Camp App

App Architecture

Entities DataAccess Libraries Messaging ViewModels

CC.Core.MonoTouch CC.Core.MonoAndroid CC.Core.WP7

CodeCamp.Core

App.MonoTouch App.MonoAndroid App.WP7

Questions?

15% Discount - Expires 10/31https://store.xamarin.com/?discount=NYC-Code-Camp-6