Universal App – Sviluppo di
App per realtà Enterprise
Gianluca Bertelli
[email protected]
Extended LOB
Modern App
Desktop App
Extended LOB
Modern <-> Desktop integration
Enable Network Loopback
+ No new code to write
-- need to expose data via HTTP/TCP
Brokered WinRT Component
+ Allows More complex scenarios
-- New code to write
Network Loopback
Network
endpoint
http://localhost
Modern App
Local Service
Checknetisolation.exe
Brokered WinRT Component (BWC)
WIN32
\
Modern App
WINRT
Desktop App
BWC - Architecture
Legacy DLL
DAL
Logic
WinRT APIs
ADO.NET/EF
dllhost.exe
COM - P/Invoke
Desktop .NET framework 4.5.1
BWC - Architecture
M
V
VM
BWC - Architecture
Views
ViewModels
Models
DAL
Logic
BWC – Visual Studio Template
http://visualstudiogallery.msdn.microsoft.com/527286e4-b06a-4234adde-d313c9c3c23e
*.winmd
*.dll (DCOM proxy)
BWC - Implementation
[ComVisible(true)]
public interface IMyBrokeredComponent
{
//interface must follow WinRT rules
string MethodName();
}
[ComVisible(true)]
public sealed class MyComp : IMyBrokeredComponent
{
//everything possible with .NET 4.5
public string MethodName(){...}
}
C# Class Library
BWC – WinRT Side
The DTO must follow these rules:
• The class must be sealed
• The class cannot inherit
• Can use only WinRT types
• Enum is not supported
• Consider custom JSON or XML serialization
DTO
Mapping Complex .NET - WinRT Types
http://msdn.microsoft.com/en-us/library/br230301.aspx
IEnumerable<T>
IList<T>
IReadOnlyList<T>
IDictionary<TKey, TValue>
IReadOnlyDictionary<TKey, TValue>
KeyValuePair<TKey, TValue>
IEnumerable
IList
System.ComponentModel.INotifyPropertyChanged
System.ComponentModel.PropertyChangedEventHandler
System.ComponentModel.PropertyChangedEventArgs
BWC – Desktop Side
Full access to .NET Framework 4.5.1:
• C#, 32 bit
• For 64-bit you need IPC
• Single AppDomain
• Multi-threading apartment model
• Support Async/Await
BWC – Modern App
• Side-Loaded only (with custom setup)
• Abstraction and Transparency  new ExcelReader();
• C#/XAML, HTML/JS, C++
• The BWC is hard-coded into the manifest
BWC – Store App
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>clrhost.dll</Path>
<ActivatableClass ActivatableClassId= "Class.Name" ThreadingModel="both">
<ActivatableClassAttribute Name=" DesktopApplicationPath" Type="string"
Value="c:\My_Deploy_Folder" />
</ActivatableClass>
</InProcessServer>
</Extension>
Reusing legacy code
Reusing Legacy code
DEMO VB6
Reusing Legacy code
VB6
ACTIVEX
DLL
Modern App
CLASSIC ADO
RECORDSET
Some advanced scenarios
BWC – Performance
• Do not block the UI thread
• Every single call has an overhead (Marshalling)
• Optimize the # of calls
• Caching
• Avoid chatty interfaces
• Bulk data transfer
• Best with Struct and Array[] (don’t use List<T>)
Test with Profiler!
struct PersonStruct {
String Name;
String Surname;
}
Offline Sql Server
ADO.NET
Modern App
Offline Sql Server
DEMO SQL
Q&A
Gianluca Bertelli
[email protected]
@bertelli
Riferimenti
• Network Loopback– http://msdn.microsoft.com/enus/library/windows/apps/dn640582.aspx
• Brokered WinRT Component http://msdn.microsoft.com/enus/library/windows/apps/dn630195.aspx
• Visual Studio Template–
http://visualstudiogallery.msdn.microsoft.com/527286e4-b06a-4234adde-d313c9c3c23e
• POS for .NET http://blogs.msdn.com/b/apulliam/archive/2014/11/01/introducingbrokeredpointofservice-brokered-windows-runtime-componentwrapper-library-for-pos-for-net-1-14.aspx
Scarica

Universal App * Sviluppo di App per realtà Enterprise