DllImport "avicap32.dll"            "capCreateCaptureWindow"static extern int  string                  int  int    int    ...
ManuallyYour Managed                   Traditional                Generated    Code                      Windows API      ...
using Windows.Media.Capture;var         new CameraCaptureUI                                         new Sizevar           ...
Metro style app                                                       Language Support                                    ...
Your Managed   Windows                         Windows 8 API    Code       Runtime
You already have the skills to build Metro style apps with C# and VB
• The relationship between .NET and the Windows  Runtime• Using Windows Runtime APIs from C# and Visual  Basic• Building W...
C# and Visual Basic influenced    the Windows Runtime
Using the Windows Runtime  feels natural and familiar from C# and Visual Basic
var         new CameraCaptureUI                                         new Sizevar           await                     Ca...
try{   var     new CameraCaptureUI                                 new Sizecatch (Exception e){   //Exception handling cod...
var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach...
var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach...
var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach...
FileOpenPicker picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");StorageFile file = await picker.PickSingleFile...
internal async void ProtectBytes(byte[] data, BinaryWriter output){   DataProtectionProvider dpp = new DataProtectionProvi...
You can write your ownWindows Runtime components    in C# or Visual Basic
You should build a Windows Runtimecomponent when you want your code to            be used from         JS, C++, C# and VB
ComVisible(true), Guid("06D7901C-9045-4241-B8A0-39A1AC0F8618")]public interface IWindowsApiSample{    string HelloWorld();...
public sealed class MyClassLibrary{    public string HelloWorld()    {         return "Hello, World!";    }}
By adhering to a few simple rules, you can                   builda managed Windows Runtime component   that projects into...
Only the public types and members in your managed Windows Runtimecomponent project need to follow the            simple ru...
public sealed class ManagedLibrary{    public List<int> GetNumbers()    {        List<int> numbers = new List<int>();     ...
public sealed class ManagedLibrary{    public IList<int> GetNumbers()    {        List<int> numbers = new List<int>();    ...
private async Task<string> GetTweetTaskAsync(){    string url = "http://api.twitter.com/1/statuses/" +                    ...
public IAsyncOperation<string> GetTweetAsync(){    return AsyncInfoFactory.Create(               () => this.GetTweetTaskAs...
Visual Studio has built-in support for               managedWindows Runtime component projects
You already have the skills to build Metro style apps with C# and VB
Influenced by C# and VBFeels natural and familiar from     C# and Visual Basic  Build your own managedWindows Runtime comp...
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
WinRT Holy COw
Upcoming SlideShare
Loading in …5
×

WinRT Holy COw

1,689 views
1,574 views

Published on

Based on build conference

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,689
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

WinRT Holy COw

  1. 1. DllImport "avicap32.dll" "capCreateCaptureWindow"static extern int string int int int int int int int DllImport "avicap32.dll"static extern bool int MarshalAs UnmanagedType ref string int MarshalAs UnmanagedType ref string int// more and more of the same
  2. 2. ManuallyYour Managed Traditional Generated Code Windows API Interop Code
  3. 3. using Windows.Media.Capture;var new CameraCaptureUI new Sizevar await CameraCaptureUIModeif var new BitmapImage await FileAccessMode
  4. 4. Metro style app Language Support (CLR, WinJS, CRT) Language Projection UI Pickers Controls Media Web Host (HTML, CSS, JavaScript)) Windows XAML Storage Network …Metadata &Namespace Windows Runtime Core Runtime Broker Windows Core
  5. 5. Your Managed Windows Windows 8 API Code Runtime
  6. 6. You already have the skills to build Metro style apps with C# and VB
  7. 7. • The relationship between .NET and the Windows Runtime• Using Windows Runtime APIs from C# and Visual Basic• Building Window Runtime Components in C# and Visual Basic
  8. 8. C# and Visual Basic influenced the Windows Runtime
  9. 9. Using the Windows Runtime feels natural and familiar from C# and Visual Basic
  10. 10. var new CameraCaptureUI new Sizevar await CameraCaptureUIModeif var new BitmapImage await FileAccessMode
  11. 11. try{ var new CameraCaptureUI new Sizecatch (Exception e){ //Exception handling code} ComException
  12. 12. var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach (var file in files){ lbFiles.Items.Add(file.FileName);} PickMultipleFilesOperation PickMultipleFilesAsync(); public sealed class PickMultipleFilesOperation : IAsyncOperation<IReadOnlyList<StorageFile>>, IAsyncInfo
  13. 13. var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach (StorageFile file in files){ lbFiles.Items.Add(file.FileName);} System.Collections.Generic.IReadOnlyList <Windows.Storage.StorageFile>
  14. 14. var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach (StorageFile file in files){ lbFiles.Items.Add(file.FileName);} System.Collections.Generic.IReadOnlyList Windows.Foundation.Collections.IVectorView <Windows.Storage.StorageFile> <Windows.Storage.StorageFile>
  15. 15. FileOpenPicker picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");StorageFile file = await picker.PickSingleFileAsync();Windows.Storage.Streams.IInputStream inputStream = await file.OpenForReadAsync();System.IO.Stream stream = inputStream.AsStream();System.IO.StreamReader reader = new StreamReader(stream);string contents = reader.ReadToEnd();
  16. 16. internal async void ProtectBytes(byte[] data, BinaryWriter output){ DataProtectionProvider dpp = new DataProtectionProvider(); IBuffer result = await dpp.ProtectAsync(data.AsBuffer()); byte[] protectedData; int start = 0; if (result.TryGetUnderlyingData(out protectedData, out start)) output.Write(protectedData); else throw new InvalidOperationException();}
  17. 17. You can write your ownWindows Runtime components in C# or Visual Basic
  18. 18. You should build a Windows Runtimecomponent when you want your code to be used from JS, C++, C# and VB
  19. 19. ComVisible(true), Guid("06D7901C-9045-4241-B8A0-39A1AC0F8618")]public interface IWindowsApiSample{ string HelloWorld();}[ComVisible(true), [ClassInterface(ClassInterfaceType.None)][ComDefaultInterface(typeof(IWindowsApiSample))]public class WindowsApiSample : IWindowsApiSample{ public string HelloWorld() { return "Hello, World!"; }}
  20. 20. public sealed class MyClassLibrary{ public string HelloWorld() { return "Hello, World!"; }}
  21. 21. By adhering to a few simple rules, you can builda managed Windows Runtime component that projects into C++ or JavaScript
  22. 22. Only the public types and members in your managed Windows Runtimecomponent project need to follow the simple rules
  23. 23. public sealed class ManagedLibrary{ public List<int> GetNumbers() { List<int> numbers = new List<int>(); numbers.AddRange(new int[] {0,1,1,2,3}); return numbers; }}
  24. 24. public sealed class ManagedLibrary{ public IList<int> GetNumbers() { List<int> numbers = new List<int>(); numbers.AddRange(new int[] {0,1,1,2,3}); return numbers; }}
  25. 25. private async Task<string> GetTweetTaskAsync(){ string url = "http://api.twitter.com/1/statuses/" + "user_timeline.xml?screen_name=bldwin"; var http = new HttpClient(); var resp = await http.GetAsync(url); var xml = XDocument.Load(resp.Content.ContentReadStream); var str = xml.Descendants("text") .Select(x => x.Value).First(); return str;}
  26. 26. public IAsyncOperation<string> GetTweetAsync(){ return AsyncInfoFactory.Create( () => this.GetTweetTaskAsync());}
  27. 27. Visual Studio has built-in support for managedWindows Runtime component projects
  28. 28. You already have the skills to build Metro style apps with C# and VB
  29. 29. Influenced by C# and VBFeels natural and familiar from C# and Visual Basic Build your own managedWindows Runtime components

×