Slide 1

Slide 1 text

Gr S Cross-platform mobile development with c#

Slide 2

Slide 2 text

About Me Greg Shackles Senior Software Engineer OLO Online Ordering email [email protected] twitter @gshackles github github.com/gshackles blog gregshackles.com Slides speakerdeck.com/u/gshackles

Slide 3

Slide 3 text

the Book oreil.ly/Lp5smR Discount Code: AUTHD Print Book: 40% Off E-Book: 50% Off

Slide 4

Slide 4 text

Market Share (US): April 2012 Google Apple RIM Microsoft Symbian 50.8% Android 31.4% Apple 11.8% RIM 4.0% Microsoft Source: comScore

Slide 5

Slide 5 text

native platform Languages Objective-C Java C#

Slide 6

Slide 6 text

Write once, run anywhere

Slide 7

Slide 7 text

platform differences != !=

Slide 8

Slide 8 text

c# Everywhere MonoTouch Mono for Android Native

Slide 9

Slide 9 text

The Power of C#

Slide 10

Slide 10 text

The Power of C# •Base Class Library

Slide 11

Slide 11 text

The Power of C# •Base Class Library •LINQ

Slide 12

Slide 12 text

The Power of C# •Base Class Library •LINQ •Parallel LINQ

Slide 13

Slide 13 text

The Power of C# •Base Class Library •LINQ •Parallel LINQ •Memory Management

Slide 14

Slide 14 text

The Power of C# •Base Class Library •LINQ •Parallel LINQ •Memory Management •Task Parallel Library

Slide 15

Slide 15 text

The Power of C# •Base Class Library •LINQ •Parallel LINQ •Memory Management •Task Parallel Library •Dynamic

Slide 16

Slide 16 text

xamarin Tools xamarin.com

Slide 17

Slide 17 text

xamarin Tools xamarin.com •Access to full platform SDKs

Slide 18

Slide 18 text

xamarin Tools xamarin.com •Access to full platform SDKs •100% Native

Slide 19

Slide 19 text

xamarin Tools xamarin.com •Access to full platform SDKs •100% Native •Linker

Slide 20

Slide 20 text

xamarin Tools xamarin.com •Access to full platform SDKs •100% Native •Linker •frequent releases

Slide 21

Slide 21 text

xamarin Tools xamarin.com •Access to full platform SDKs •100% Native •Linker •frequent releases •active community

Slide 22

Slide 22 text

xamarin Tools xamarin.com •Access to full platform SDKs •100% Native •Linker •frequent releases •active community •Improved API

Slide 23

Slide 23 text

CFStringRef  keys[]  =  {        kCTFontAttributeName,        kCTForegroundColorAttributeName };   CFTypeRef  bval[]  =  {        cfListLineCTFontRef,        CGColorGetConstantColor(kCGColorBlack) };   attr  =  CFDictionaryCreate  (        kCFAllocatorDefault,        (const  void  **)  &keys,  (const  void  **)  &bval,        sizeof(keys)  /  sizeof(keys[0]),  &kCFTypeDictionaryKeyCallBacks,        &kCFTypeDictionaryValueCallBacks);   astr  =  CFAttributedStringCreate( kCFAllocatorDefault,  CFSTR("Hello  World"),  attr); obj-c

Slide 24

Slide 24 text

C# CFStringRef  keys[]  =  {        kCTFontAttributeName,        kCTForegroundColorAttributeName };   CFTypeRef  bval[]  =  {        cfListLineCTFontRef,        CGColorGetConstantColor(kCGColorBlack) };   attr  =  CFDictionaryCreate  (        kCFAllocatorDefault,        (const  void  **)  &keys,  (const  void  **)  &bval,        sizeof(keys)  /  sizeof(keys[0]),  &kCFTypeDictionaryKeyCallBacks,        &kCFTypeDictionaryValueCallBacks);   astr  =  CFAttributedStringCreate( kCFAllocatorDefault,  CFSTR("Hello  World"),  attr); obj-c var  attrs  =  new  CFStringAttributes  {        Font  =  listLineCTFont,        ForegroundColor  =  UIColor.Black.CGColor };   var  astr  =  new  NSAttributedString  ("Hello  World",  attrs);

Slide 25

Slide 25 text

            findViewById(R.id.button).setOnClickListener( new  View.OnClickListener()          {                @Override      public  void  onClick(View  v)      {              //  handle  click      }        } ); Java

Slide 26

Slide 26 text

C#             findViewById(R.id.button).setOnClickListener( new  View.OnClickListener()          {                @Override      public  void  onClick(View  v)      {              //  handle  click      }        } ); Java [Activity(Label="@string/AppName",  MainLauncher=true)] FindViewById(Resource.Id.Button).Click  +=  delegate   {   //  handle  click };

Slide 27

Slide 27 text

Environment: iOS Mac OS X MonoDevelop Xcode Integration

Slide 28

Slide 28 text

Environment: android Mac OS X Windows MonoDevelop Visual Studio

Slide 29

Slide 29 text

UI Designer: MonoDevelop and Visual Studio Environment: android

Slide 30

Slide 30 text

Environment: windows phone Windows Visual Studio

Slide 31

Slide 31 text

Some Apps ...and many more! icircuit rdio gmusic c# to go infinite flight mwc 2012

Slide 32

Slide 32 text

Benefits

Slide 33

Slide 33 text

•Powerful and mature language Benefits

Slide 34

Slide 34 text

•Powerful and mature language •Skill reuse Benefits

Slide 35

Slide 35 text

•Powerful and mature language •Skill reuse •Native apps Benefits

Slide 36

Slide 36 text

•Powerful and mature language •Skill reuse •Native apps •Code reuse across platforms Benefits even non-mobile platforms!

Slide 37

Slide 37 text

app Architecture UI# C## Run)me# Pla/orm# Silverlight# Business#Logic# .NET# WP7# iOS# Mono# Android# MonoTouch# Mono#for# Android#

Slide 38

Slide 38 text

What code can be shared?

Slide 39

Slide 39 text

What code can be shared? •Most non-UI or platform code

Slide 40

Slide 40 text

What code can be shared? •Most non-UI or platform code •Core application logic

Slide 41

Slide 41 text

What code can be shared? •Most non-UI or platform code •Core application logic •Entities

Slide 42

Slide 42 text

What code can be shared? •Most non-UI or platform code •Core application logic •Entities •LINQ (objects, XML)

Slide 43

Slide 43 text

What code can be shared? •Most non-UI or platform code •Core application logic •Entities •LINQ (objects, XML) •Network access

Slide 44

Slide 44 text

What code can be shared? * with some limitations •Most non-UI or platform code •Core application logic •Entities •LINQ (objects, XML) •Network access •File / Database Access *

Slide 45

Slide 45 text

sharing techniques

Slide 46

Slide 46 text

sharing techniques •File Linking

Slide 47

Slide 47 text

sharing techniques •File Linking •Abstraction

Slide 48

Slide 48 text

sharing techniques •File Linking •Abstraction •Observer Pattern

Slide 49

Slide 49 text

sharing techniques •File Linking •Abstraction •Observer Pattern •Partial Classes and Methods

Slide 50

Slide 50 text

sharing techniques •File Linking •Abstraction •Observer Pattern •Partial Classes and Methods •Conditional Compilation

Slide 51

Slide 51 text

sharing techniques * currently in development •File Linking •Abstraction •Observer Pattern •Partial Classes and Methods •Conditional Compilation •portable class libraries *

Slide 52

Slide 52 text

library: xamarin.mobile Supports iOS, Android and Windows Phone xamarin.com/mobileapi

Slide 53

Slide 53 text

Demo Time

Slide 54

Slide 54 text

Questions?