Cross-platform mobile development with c#

friendlybathΚινητά – Ασύρματες Τεχνολογίες

12 Νοε 2013 (πριν από 3 χρόνια και 4 μήνες)

85 εμφανίσεις

Greg Shackles
-

June 12, 2012

Cross
-
platform
mobile

development
with

c#

About
Me

Greg
Shackles

Senior Software Engineer

OLO Online Ordering

email

greg@gregshackles.com

twitter

@gshackles

github

github.com/gshackles

blog

gregshackles.com


Slides

speakerdeck.com/u/gshackles

the
Book

oreil.ly/Lp5smR


Discount Code: AUTHD

Print Book: 40% Off

E
-
Book: 50% Off



Market Share (US):
April 2012

50
.
8
%

Android

31
.
4
%

Apple

11
.
8
%

RIM


4
.
0
%

Microsoft

Source: comScore

native
platform
Languages

Objective
-
C

Java

C#

Write once,

run
anywhere

platform

differences

!=

!=

c#
Everywhere

MonoTouch

Mono for Android

Native

The Power of
C#


Base Class Library


LINQ


Parallel LINQ


Memory Management


Task Parallel Library


Dynamic

xamarin
Tools

xamarin.com


Access to full platform SDKs


100% Native


Linker


frequent releases


active community


Improved API

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


C#

<
activity android:name=".SampleActivity



††
慮摲潩携污扥氽≀獴物湧⽡灰彮慭攢a


㱩湴敮<
-
晩汴敲f



㱡捴楯渠慮摲潩携湡浥㴢慮摲潩搮楮瑥湴⹡捴楯渮䵁䥎∠⼾

†††††††††††††


㱣慴敧潲礠慮摲潩携湡浥㴢慮摲潩搮楮瑥湴⹣慴敧潲礮䱁啎䍈䕒∠⼾


㰯楮瑥湴
-
晩汴敲f

㰯慣瑩癩瑹<



晩湤噩敷䉹䥤⡒⹩搮扵瑴潮⤮獥瑏湃汩捫䱩獴敮敲f

††
湥眠噩敷⹏湃汩捫䱩獴敮敲⠩

††
{

††††
䁏癥牲楤@

††††
灵扬楣⁶潩搠潮䍬楣欨噩敷⁶p

††††
{


†††
⼯⁨慮摬攠捬楣/


}

††
}



Ja
va

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




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

{


// handle click

};

Environment:
i
OS

Mac OS X

MonoDevelop

Xcode
Integration

Environment:
android

Mac OS X

Windows

MonoDevelop

Visual Studio

UI Designer: MonoDevelop and Visual Studio

Environment:
android

Environment:
windows phone

Windows

Visual Studio

Some
Apps

...
and many more!

icircuit

rdio

gmusic

c# to go

infinite flight

mwc 2012


Powerful and mature language


Skill reuse


Native apps


Code reuse across platforms

Benefits

even non
-
mobile platforms!

app

Architecture

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 *

sharing

techniques

* currently in development


File Linking


Abstraction


Observer Pattern


Partial Classes and Methods


Conditional Compilation


portable class libraries *

library:

xamarin.mobile

Supports iOS, Android and Windows Phone

xamarin.com/mobileapi

Demo
Time

Questions?