Date post: | 24-May-2015 |
Category: |
Technology |
Upload: | karl-ots |
View: | 1,625 times |
Download: | 0 times |
Architecting applications for WinRT and WinPRT
#td2013fi @fincooper
About the the presenter
• Karl Ots, Technical Consultant at Symbio
• Windows Phone 8 and Windows 8 trainer
• Windows Azure Insider
• Co-founder of Young Developers Finland
• Microsoft Student Partner
#td2013fi @fincooper
What we’ll cover
• What shared core means and what it doesn’t
• UX differences
• Porting vs maximum reuse
• Best practices of common scenarios
• Demos
Shared core
#td2013fi @fincooper
Shared WinRT Core
Networking
Proximity
Sensors
Location
File System
Core app
model
Threading
#td2013fi @fincooper
Windows 8 Platform
#td2013fi @fincooper
• CLR – common language runtime
• BCL – base class library
• FCL – framework class library
Some definitions
#td2013fi @fincooper
Windows 8 app model
#td2013fi @fincooper
WP8 MANAGED app model
#td2013fi @fincooper
WP8 app model
Native app model Legacy app model
#td2013fi @fincooper
Windows Phone Runtime
Full WinRT (around
11,000 members)Subset adopted for
Windows Phone
Runtime (around
2,800 members)
New for Windows
Phone Runtime
(around 600
members)
•Phone-specific additions to Windows Runtime include
• Speech synthesis and recognition
•Windows.Phone.PersonalInformation
• LockScreen and LockScreenManager
•More…
Targeting maximum reuse
#td2013fi @fincooper
Strategies for targeting both platforms
• Use Model-View-ViewModel
• Share portable .NET code in Portable Class Library
• Use common Windows Runtime API (Add as Link)
• Use Windows Runtime Components for language interoperability
• Use #if conditionals for small code differences
• Use extension methods to bridge implementation differences
#td2013fi @fincooper
Cross-platform app architecture with PLC
Régis
LaurentDirector of Operations,
Global Knowledge
Competencies include:
Gold Learning
Silver System Management
DEMOPixPresenter
#td2013fi @fincooper
What’s portable in PixPresenter?
Platform-specific
Portable /shareable
Platform-specific
Windows Phone app Windows Store app
#td2013fi @fincooper
“Add as Link”
Régis
LaurentDirector of Operations,
Global Knowledge
Competencies include:
Gold Learning
Silver System Management
DEMOAdd as Link
#td2013fi @fincooper
Small code differences
Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>{
double _accelX = args.Reading.AccelerationX;double _accelY = args.Reading.AccelerationY;// Update ellipse location
});
Deployment.Current.Dispatcher.BeginInvoke(() =>{
double _accelX = args.Reading.AccelerationX;double _accelY = args.Reading.AccelerationY;//Update ellipse location
});
#td2013fi @fincooper
Threading
#if NETFX_COREDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {#elseDeployment.Current.Dispatcher.BeginInvoke(() => {#endif
double _accelX = args.Reading.AccelerationX;double _accelY = args.Reading.AccelerationY;
#if conditional blocks
#td2013fi @fincooper
HttpWebResponse and HttpWebRequest
var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
// retrieve data using StreamReader
#td2013fi @fincooper
HttpWebResponse and HttpWebRequest
var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);request.BeginGetResponse(new AsyncCallback(AutoCompleteCallback), request);}
private void AutoCompleteCallback(IAsyncResult callback){
HttpWebRequest request = (HttpWebRequest)callback.AsyncState;HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(callback);// retrieve data using StreamReader
}
#td2013fi @fincooper
Extension Methods
public static Task<HttpWebResponse> GetResponseAsync(this HttpWebRequest request){
var taskComplete = new TaskCompletionSource<HttpWebResponse>();request.BeginGetResponse(asyncResponse =>{
HttpWebRequest responseRequest = (HttpWebRequest)asyncResponse.AsyncState;
HttpWebResponse someResponse = (HttpWebResponse)responseRequest.EndGetResponse(asyncResponse);
taskComplete.TrySetResult(someResponse);}, request);
return taskComplete.Task;}
#td2013fi @fincooper
HttpWebResponse and HttpWebRequest
#if WINDOWS_PHONEusing MyExtensionClass#endif
var request = (HttpWebRequest)WebRequest.Create(autoCompleteUri);
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
// retrieve data using StreamReader
Use carefully – performance in ABYSMAL
Best practices
#td2013fi @fincooper
Most common reasons to fail certification
• Windows Phone: failure to check for (light) themes
• Windows 8: no privacy policy
Do NOT share XAML. Just don’t.
#td2013fi @fincooper
Different Form Factors Require Different UX
#td2013fi @fincooper
Translating UX
#td2013fi @fincooper
Translating UX – Details View
CaseMoomin video store
#td2013fi @fincooper
Case: Moomin video store
• Windows 8 client ported to Windows Phone 8
• Core Models and ViewModels unchanged
• Azure backend for distributing media (Win8) and keeping track of in-app purchases receipts
• Different Store, different in-app purchases
• WP: download limitations
• Different media players
#td2013fi @fincooper
Thank you!Time for QA and a quick raffle!