greg shackles - june 12, 2012

24
Greg Shackles - June 12, 2012 Cross-platform mobile development with c#

Upload: skip

Post on 11-Jan-2016

41 views

Category:

Documents


1 download

DESCRIPTION

Cross-platform mobile development with c#. Greg Shackles - June 12, 2012. 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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Greg Shackles - June 12, 2012

Greg Shackles - June 12, 2012

Cross-platform mobile

development with c#

Page 2: Greg Shackles - June 12, 2012

About MeGreg

ShacklesSenior Software Engineer

OLO Online Ordering

[email protected]

twitter@gshackles

githubgithub.com/gshackles

bloggregshackles.com

Slidesspeakerdeck.com/u/gshackles

Page 3: Greg Shackles - June 12, 2012

the Bookoreil.ly/Lp5smR

Discount Code: AUTHDPrint Book: 40% OffE-Book: 50% Off

Page 4: Greg Shackles - June 12, 2012

Market Share (US): April 2012

50.8% Android31.4% Apple11.8% RIM 4.0% Microsoft

Source: comScore

Page 5: Greg Shackles - June 12, 2012

native platform Languages

Objective-C

Java

C#

Page 6: Greg Shackles - June 12, 2012

Write once, run anywhere

Page 7: Greg Shackles - June 12, 2012

platform differences

!= !=

Page 8: Greg Shackles - June 12, 2012

c# Everywhere

MonoTouch

Mono for Android

Native

Page 9: Greg Shackles - June 12, 2012

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

Page 10: Greg Shackles - June 12, 2012

xamarin Tools

xamarin.com

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

Page 11: Greg Shackles - June 12, 2012

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);

Page 12: Greg Shackles - June 12, 2012

C#

<activity android:name=".SampleActivity“ android:label="@string/app_name"><intent-filter>

<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />

</intent-filter></activity>

findViewById(R.id.button).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) {

// handle click}

});

Java

[Activity(Label="@string/AppName", MainLauncher=true)]

FindViewById<Button>(Resource.Id.Button).Click += delegate {

// handle click};

Page 13: Greg Shackles - June 12, 2012

Environment: iOS

Mac OS X MonoDevelopXcode

Integration

Page 14: Greg Shackles - June 12, 2012

Environment: android

Mac OS X

Windows

MonoDevelop

Visual Studio

Page 15: Greg Shackles - June 12, 2012

UI Designer: MonoDevelop and Visual Studio

Environment: android

Page 16: Greg Shackles - June 12, 2012

Environment: windows phone

Windows Visual Studio

Page 17: Greg Shackles - June 12, 2012

Some Apps

...and many more!

icircuit rdio gmusic c# to go

infinite flight mwc 2012

Page 18: Greg Shackles - June 12, 2012

•Powerful and mature language•Skill reuse•Native apps•Code reuse across platforms

Benefits

even non-mobile platforms!

Page 19: Greg Shackles - June 12, 2012

app Architecture

Page 20: Greg Shackles - June 12, 2012

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 *

Page 21: Greg Shackles - June 12, 2012

sharing techniques

* currently in development

•File Linking•Abstraction•Observer Pattern•Partial Classes and Methods•Conditional Compilation•portable class libraries *

Page 22: Greg Shackles - June 12, 2012

library: xamarin.mobile

Supports iOS, Android and Windows Phone

xamarin.com/mobileapi

Page 23: Greg Shackles - June 12, 2012

Demo Time

Page 24: Greg Shackles - June 12, 2012

Questions?