12
REST in peace with Xamarin @fekberg

REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Embed Size (px)

Citation preview

Page 1: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

REST in peace with Xamarin

@fekberg

Page 2: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Contact [email protected] http://fekberg.com +61 (401) 157-608 @fekberg C# Smorgasbord

/ Copyright ©2014 by Readify Pty Ltd 2

Page 3: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

What is Xamarin?

/ Copyright ©2014 by Readify Pty Ltd 3

› Enables you to reach all major mobile platforms › Gives you: › Native user interface › Native Performance › An awesome development experience

Page 4: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Developing using Xamarin

/ Copyright ©2014 by Readify Pty Ltd 4

Xamarin Studio PC or Mac

Visual Studio Plugin

VS 2010/2012/2013

Page 5: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Can we reuse code?

/ Copyright ©2014 by Readify Pty Ltd 5

› Yes! We can use PCL (Portable Class Libraries) › Different approaches: ›  Inject implementations ›  Inject Action/Func

› Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo

Page 6: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

REST API?

/ Copyright ©2014 by Readify Pty Ltd 6

› Fancy way of saying API over HTTP › What REST API? iHackerNews! › http://api.ihackernews.com/

› HTTP GET -> /page returns a collection of entries public  class  Entry  {          public  int  Id  {  get;  set;  }          public  int  Points  {  get;  set;  }          public  string  PostedAgo  {  get;  set;  }          public  string  PostedBy  {  get;  set;  }          public  string  Title  {  get;  set;  }          public  string  Url  {  get;  set;  }  }

Page 7: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

How do you use REST from C#?

/ Copyright ©2014 by Readify Pty Ltd 7

Page 8: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Performing a GET request

/ Copyright ©2014 by Readify Pty Ltd 8

var  client  =  new  HttpClient();    var  result  =    

 await  client.GetStringAsync(HackerNewsApiUrls.Top);

Page 9: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

DEMO! Xamarin + C# + REST

/ Copyright ©2014 by Readify Pty Ltd 9

Page 10: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Summary

/ Copyright ©2014 by Readify Pty Ltd 10

›  Easy to have business logic in a shared library (PCL) ›  Consuming REST APIs are easy! ›  Xamarin makes it all enjoyable

Page 11: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Questions?

/ Copyright ©2014 by Readify Pty Ltd 11

Page 12: REST in peace with Xamarin - Filip Ekberg fileREST in peace with Xamarin @fekberg . Page ... › Create interface IFoo in PCL inject implementation iOS.Foo and Droid.Foo . Page

Page

Thank you! [email protected] http://fekberg.com +61 (401) 157-608 @fekberg C# Smorgasbord

/ Copyright ©2014 by Readify Pty Ltd 12