alejandro campos magencio ms technical evangelist @alejacma extreme code sharing with c# y a xb

32
#dotNETSpain2015 Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A X B

Upload: aldous-nash

Post on 22-Dec-2015

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

Alejandro Campos MagencioMS Technical Evangelist@alejacma

Extreme Code Sharing with C#

Y

AX B

Page 2: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

Page 3: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

What? Why?

Page 4: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

The Siloed Approach

Objective C+ XIB

Java + XML C# + XAML

Native UI Native UI Native UI

Optional Remote Services(ASP.NET Web API or any server

technology)

Visual StudioEclipseXcode

Native UIJS + HTML

Page 5: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

The C# Unique Approach

C# + XIB C# + XML C# + XAML

Native UI Native UI Native UI

Optional Remote Services(ASP.NET Web API

or any server technology)

Shared client app C# logic

Page 6: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

How?

Page 7: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Platforms

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

Page 8: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

C#

Type Inference

Language-levelAsync

GenericsCollections

Lambda ExpressionsLINQ

Page 9: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Portable Class Libraries (PCLs)

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

App Logic

Page 10: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Portable for Universal Apps

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

UIApp Logic API Calls

Page 11: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Xamarin.Forms Portable

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

Platform specific

UI

WinRTXAML

Platform specific

UI

Platform specific UI

Universal Apps

UIApp Logic

Page 12: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Inheritance using base classes

public abstract class MyBaseClass {     public void CommonMethod()     {         // Common code     }

    public abstract void PlatformSpecificMethod(); }

public class MyPlatformClass : MyBaseClass {     public override void PlatformSpecificMethod()     {         // Platform specific code     } }

PCL

Platform Project

Page 13: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Polymorphism using interfaces

public interface IPlatformCode {     void PlatformSpecificMethod(); }

public class MyClass {     private IPlatformCode platformCode;

    public MyClass(IPlatformCode platformCode)     {         this.platformCode = platformCode;     }

    public void CommonMethod()     {         // Common code     }

    public void PlatformSpecificMethod()     {         platformCode.PlatformSpecificMethod();     }}

public class MyPlatformClass : IPlatformCode {     public void PlatformSpecificMethod()     {         // Platform specific code     } }

MyClass myClass =  new MyClass(new MyPlatformClass());

PCL Platform Project

Page 14: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

File Linking

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

UIApp

Logic API Calls

UIApp

Logic API Calls

UIApp

Logic API Calls

UIApp

Logic API Calls

UIApp

Logic API Calls

Page 15: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Universal Shared Projects

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

UIApp Logic API Calls

Page 16: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Xamarin.Forms Shared Projects

Win 8.1 WP8.1 WP8

Xamarin (~.NET 4.5, C# 5.0)

WinRTAPI

WinPRT / .NET API for WP

Android API

iOSAPI

.NET 4.5.1C# 5.0

.NET 4.5C# 5.0

WPSilverlig

htXAML

WinRTXAML XML XIB /

Storyboard

Universal Apps

UIApp Logic API Calls

Page 17: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Conditional Compilation

#if WINDOWS_PHONE     // Windows Phone specific code #elif __IOS__     // iOS specific code #else     // Android specific code #endif

Shared Project / Linked File

Page 18: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

Partial Classes

public partial class MyClass {     public void CommonMethod()     {         // Common code     } }

public partial class MyClass {     public void PlatformSpecificMethod()     {         // Platform specific code     } }

Shared Project / Linked File

Platform Project

Page 19: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

The Key to Success

Page 20: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

MVVM

View ViewModel Model

Notifications

Data Bindings

Commands

Presentation Logic Business Logicand Data

UI Logic(Code Behind)

UI

Page 21: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

Demo Time

Page 22: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

MarvelApp

Windows 8.1

Page 23: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015#dotNETSpain2015

MarvelApp

Windows Phone 8.1 AndroidWindows Phone 8.0

Page 24: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

Windows 8.1 WP8.1 WP8

Page 25: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

View-Model

Windows 8.1 WP8.1 WP8

Page 26: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

View-Model

Windows 8.1 WP8.1 WP8

XAMLCode Behind

XAMLCode Behind

Code Behind

Custom Renderers Custom RenderersControls

XAML + Code Behind

App App

Service Locator Service Locator

Page 27: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

View-Model

Windows 8.1 WP8.1 WP8

Service Abstractions

Navigation Service Navigation Service

Service Locator Service Locator

App App

XAMLCode Behind

XAMLCode Behind

Code Behind

Custom Renderers Custom RenderersControls

XAML + Code Behind

Page 28: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

Windows 8.1 WP8.1 WP8

Service Abstractions

Navigation Service Navigation Service

Service Locator Service Locator

App App

Entities

Repositories

Factories

Data Context Abstractions

API Clients

Data Contexts

Configuration

Data Contexts Data Contexts

View-Model

XAMLCode Behind

XAMLCode Behind

Code Behind

Custom Renderers Custom RenderersControls

XAML + Code Behind

Page 29: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

Windows 8.1 WP8.1 WP8

Service Abstractions

Navigation Service Navigation Service

Service Locator Service Locator

App App

Entities

Repositories

Factories

Data Context Abstractions

API Clients

Data Contexts

Configuration

Data Contexts Data Contexts

Azure Mobile Services

Push PushPush

View-Model

XAMLCode Behind

XAMLCode Behind

Code Behind

Custom Renderers Custom RenderersControls

XAML + Code Behind

Page 30: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

View-Model

Windows 8.1 WP8.1 WP8

Azure Mobile Services

Entities

Repositories

Factories

Data Context Abstractions

API Clients

Data Contexts Data Contexts

Push

Data Contexts

Push

Configuration

Push

Service Abstractions

Navigation Service Navigation Service

Service Locator Service Locator

App App

XAMLCode Behind

XAMLCode Behind

Code Behind

Custom Renderers Custom RenderersControls

XAML + Code Behind

Page 31: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

View-Model

Windows 8.1 WP8.1 WP8

Azure Mobile Services

View View

Model

View

Model

Push

View View

Model

PushPush

Services

Services Services

Service Locator Service Locator

App App

Model

View

Page 32: Alejandro Campos Magencio MS Technical Evangelist @alejacma Extreme Code Sharing with C# Y A XB

#dotNETSpain2015

Alejandro Campos MagencioMS Technical Evangelist@alejacma

¡¡¡Si te ha gustado no olvides rellenar la encuesta!!!Thanks

Y

AX B