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

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

Cross-Platform Mobile Development with C# (MonkeySpace 2012)

Greg Shackles

October 18, 2012
Tweet

More Decks by Greg Shackles

Other Decks in Programming

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
  2. Market Share (US): August 2012 Google Apple RIM Microsoft Symbian

    52.6% Android 34.3% Apple 8.3% RIM 3.6% Microsoft Source: comScore
  3. "The biggest mistake we made as a company was betting

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

    •Memory Management •Task Parallel Library •Dynamic •Skill Reuse
  5. xamarin Tools •Access to full platform SDKs •100% Native •Linker

    •Debugging •frequent releases •active community •Improved API
  6. 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);
  7. 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 };
  8. - - - - - - - - - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UI and Platform Code Shared Code
  9. 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 *
  10. sharing techniques •File Linking •Abstraction •Observer Pattern •Partial Classes and

    Methods •Conditional Compilation •portable class libraries