Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cross-Platform Mobile Development with C# (2012...

Avatar for Greg Shackles Greg Shackles
September 17, 2012

Cross-Platform Mobile Development with C# (2012-09-17)

Avatar for Greg Shackles

Greg Shackles

September 17, 2012
Tweet

More Decks by Greg Shackles

Other Decks in Technology

Transcript

  1. 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 Sunday, September 16, 12
  2. Market Share (US): July 2012 Google Apple RIM Microsoft Symbian

    52.2% Android 33.4% Apple 9.5% RIM 3.6% Microsoft Source: comScore Sunday, September 16, 12
  3. "The biggest mistake we made as a company was betting

    too much on HTML5 instead of native." - Mark Zuckerberg Sunday, September 16, 12
  4. The Power of C# •Base Class Library •LINQ •Parallel LINQ

    •Memory Management Sunday, September 16, 12
  5. The Power of C# •Base Class Library •LINQ •Parallel LINQ

    •Memory Management •Task Parallel Library Sunday, September 16, 12
  6. The Power of C# •Base Class Library •LINQ •Parallel LINQ

    •Memory Management •Task Parallel Library •Dynamic Sunday, September 16, 12
  7. xamarin Tools xamarin.com •Access to full platform SDKs •100% Native

    •Linker •frequent releases Sunday, September 16, 12
  8. xamarin Tools xamarin.com •Access to full platform SDKs •100% Native

    •Linker •frequent releases •active community Sunday, September 16, 12
  9. xamarin Tools xamarin.com •Access to full platform SDKs •100% Native

    •Linker •frequent releases •active community •Improved API Sunday, September 16, 12
  10. 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 Sunday, September 16, 12
  11. 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  attr  =  new  CFStringAttributes  {        Font  =  listLineCTFont,        ForegroundColor  =  UIColor.Black.CGColor };   var  astr  =  new  NSAttributedString  ("Hello  World",  attrs); Sunday, September 16, 12
  12. <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 Sunday, September 16, 12
  13. 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 }; Sunday, September 16, 12
  14. •Powerful and mature language •Skill reuse •Native apps •Code reuse

    across platforms Benefits even non-mobile platforms! Sunday, September 16, 12
  15. app Architecture UI# C## Run)me# Pla/orm# Silverlight# Business#Logic# .NET# WP7#

    iOS# Mono# Android# MonoTouch# Mono#for# Android# Sunday, September 16, 12
  16. What code can be shared? •Most non-UI or platform code

    •Core application logic Sunday, September 16, 12
  17. What code can be shared? •Most non-UI or platform code

    •Core application logic •Entities Sunday, September 16, 12
  18. What code can be shared? •Most non-UI or platform code

    •Core application logic •Entities •LINQ (objects, XML) Sunday, September 16, 12
  19. What code can be shared? •Most non-UI or platform code

    •Core application logic •Entities •LINQ (objects, XML) •Network access Sunday, September 16, 12
  20. 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 * Sunday, September 16, 12
  21. sharing techniques •File Linking •Abstraction •Observer Pattern •Partial Classes and

    Methods •Conditional Compilation Sunday, September 16, 12
  22. sharing techniques * currently in development •File Linking •Abstraction •Observer

    Pattern •Partial Classes and Methods •Conditional Compilation •portable class libraries * Sunday, September 16, 12