alejandro campos magencio ms technical evangelist @alejacma extreme code sharing with c# y a xb
TRANSCRIPT
#dotNETSpain2015
Alejandro Campos MagencioMS Technical Evangelist@alejacma
Extreme Code Sharing with C#
Y
AX B
#dotNETSpain2015
#dotNETSpain2015
What? Why?
#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
#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
#dotNETSpain2015
How?
#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
#dotNETSpain2015#dotNETSpain2015
C#
Type Inference
Language-levelAsync
GenericsCollections
Lambda ExpressionsLINQ
#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
#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
#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
#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
#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
#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
#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
#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
#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
#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
#dotNETSpain2015
The Key to Success
#dotNETSpain2015#dotNETSpain2015
MVVM
View ViewModel Model
Notifications
Data Bindings
Commands
Presentation Logic Business Logicand Data
UI Logic(Code Behind)
UI
#dotNETSpain2015
Demo Time
#dotNETSpain2015#dotNETSpain2015
MarvelApp
Windows 8.1
#dotNETSpain2015#dotNETSpain2015
MarvelApp
Windows Phone 8.1 AndroidWindows Phone 8.0
Windows 8.1 WP8.1 WP8
View-Model
Windows 8.1 WP8.1 WP8
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
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
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
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
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
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
#dotNETSpain2015
Alejandro Campos MagencioMS Technical Evangelist@alejacma
¡¡¡Si te ha gustado no olvides rellenar la encuesta!!!Thanks
Y
AX B