Pemetaan .NET jenis Windows Runtime di aplikasi UWP

Artikel ini mencantumkan pemetaan yang dibuat .NET antara jenis Windows Runtime (WinRT) dan jenis .NET di aplikasi Platform Windows Universal (UWP) yang ditulis dengan kode terkelola. Dalam aplikasi ini, Visual Studio IntelliSense menampilkan jenis .NET alih-alih jenis WinRT. Misalnya, jika metode WinRT mengambil parameter jenis string> IVector<, maka IntelliSense menunjukkan parameter jenis string> IList<. Demikian pula, dalam komponen Windows Runtime yang ditulis dengan kode terkelola, Anda menggunakan jenis .NET dalam tanda tangan anggota. Ketika Windows Runtime Metadata Export Tool (Winmdexp.exe) menghasilkan komponen Windows Runtime Anda, jenis .NET diterjemahkan ke dalam jenis WinRT yang sesuai.

Sebagian besar jenis yang memiliki nama namespace layanan dan nama jenis yang sama di WinRT dan .NET adalah struktur (atau jenis yang terkait dengan struktur, seperti enumerasi). Di WinRT, struktur tidak memiliki anggota selain bidang, dan memerlukan jenis pembantu, yang disembunyikan .NET. Versi .NET dari struktur ini memiliki properti dan metode yang menyediakan fungsionalitas jenis pembantu tersembunyi.

Catatan

Untuk daftar pemetaan antara jenis WinRT dan .NET dalam konteks aplikasi desktop yang menargetkan .NET dan menggunakan C#/WinRT, lihat pemetaan .NET jenis WinRT di C#/WinRT.

Jenis WinRT yang memetakan ke jenis .NET dengan nama dan namespace yang sama

Dalam System.ObjectModel.dll rakitan .NET

Ruang nama Jenis
Windows.UI.Xaml.Input ICommand

Dalam System.Runtime.WindowsRuntime.dll rakitan .NET

Ruang nama Jenis
Windows.Foundation Titik
Windows.Foundation Rect
Windows.Foundation Ukuran
Windows.UI Warna

Dalam System.Runtime.WindowsRuntime.UI.Xaml.dll rakitan .NET

Ruang nama Jenis
Windows.UI.Xaml SudutRadius
Windows.UI.Xaml Durasi
Windows.UI.Xaml DurationType
Windows.UI.Xaml GridLength
Windows.UI.Xaml GridUnitType
Windows.UI.Xaml Ketebalan
Windows.UI.Xaml.Controls.Primitives GeneratorPosition
Windows.UI.Xaml.Media Matrix
Windows.UI.Xaml.Media.Animation KeyTime
Windows.UI.Xaml.Media.Animation RepeatBehavior
Windows.UI.Xaml.Media.Animation RepeatBehaviorType
Windows.UI.Xaml.Media.Media3D Matriks3D

Jenis WinRT yang memetakan ke jenis .NET dengan nama dan/atau namespace yang berbeda

Dalam System.ObjectModel.dll rakitan .NET

Jenis/namespace WinRT Jenis .NET/namespace
INotifyCollectionChanged (Windows.UI.Xaml.Interop) INotifyCollectionChanged (System.Collections.Specialized)
NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventHandler (System.Collections.Specialized)
NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventArgs (System.Collections.Specialized)
NotifyCollectionChangedAction (Windows.UI.Xaml.Interop) NotifyCollectionChangedAction (System.Collections.Specialized)
INotifyPropertyChanged (Windows.UI.Xaml.Data) INotifyPropertyChanged (System.ComponentModel)
PropertyChangedEventHandler (Windows.UI.Xaml.Data) PropertyChangedEventHandler (System.ComponentModel)
PropertyChangedEventArgs (Windows.UI.Xaml.Data) PropertyChangedEventArgs (System.ComponentModel)

Dalam System.Runtime.dll rakitan .NET

Jenis/namespace WinRT Jenis .NET/namespace
AttributeUsageAttribute (Windows.Foundation.Metadata) AttributeUsageAttribute (Sistem)
AttributeTargets (Windows.Foundation.Metadata) AttributeTargets (Sistem)
DateTime (Windows.Foundation) DateTimeOffset (Sistem)
EventHandler<T> (Windows.Foundation) EventHandler<T> (Sistem)
HResult (Windows.Foundation) Pengecualian (Sistem)
IReference<T> (Windows.Foundation) T> (Sistem) yang dapat diubah ke<null
TimeSpan (Windows.Foundation) TimeSpan (Sistem)
Uri (Windows.Foundation) Uri (Sistem)
IClosable (Windows.Foundation) IDisposable (Sistem)
IIterable<T> (Windows.Foundation.Collections) IEnumerable<T> (System.Collections.Generic)
IVector<T> (Windows.Foundation.Collections) IList<T> (System.Collections.Generic)
IVectorView<T> (Windows.Foundation.Collections) IReadOnlyList<T> (System.Collections.Generic)
IMap<K,V> (Windows.Foundation.Collections) IDictionary<TKey,TValue> (System.Collections.Generic)
IMapView<K,V> (Windows.Foundation.Collections) IReadOnlyDictionary<TKey,TValue> (System.Collections.Generic)
IKeyValuePair<K,V> (Windows.Foundation.Collections) KeyValuePair<TKey,TValue> (System.Collections.Generic)
IBindableIterable (Windows.UI.Xaml.Interop) IEnumerable (System.Collections)
IBindableVector (Windows.UI.Xaml.Interop) IList (System.Collections)
TypeName (Windows.UI.Xaml.Interop) Jenis (Sistem)

Dalam System.Runtime.InteropServices.WindowsRuntime.dll rakitan .NET

Jenis/namespace WinRT Jenis .NET/namespace
EventRegistrationToken (Windows.Foundation) EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime)