Windows 运行时类型的 .NET Framework 映射
下表列出了 .NET Framework 在 Windows 运行时类型与 .NET Framework 类型之间创建的映射。在用托管代码编写的 Windows 应用商店应用程序中,IntelliSense 显示 .NET Framework 类型而不是 Windows 运行时类型。例如,如果 Windows 运行时方法采用类型为 IVector<string> 的参数,IntelliSense 将显示类型为 IList<string> 的参数。同样,在用托管代码编写的 Windows 运行时组件中,将在成员签名中使用 .NET Framework 类型。当 Windows 运行时元数据导出工具 (Winmdexp.exe) 生成 Windows 运行时组件时,.NET Framework 类型会变为相应的 Windows 运行时类型。
在 Windows 运行时和 .NET Framework 中具有相同的命名空间名称和类型名称的大多数类型是结构(或与结构关联的类型,如枚举)。在 Windows 运行时中,结构没有字段外的成员,并且需要帮助器类型,.NET Framework 会隐藏该类型。这些结构的 .NET Framework 版本的属性和方法可提供隐藏的帮助器类型的功能。
有关 .NET Framework 如何使用 Windows 元数据简化 Windows 运行时编程的详细信息,请从 Windows 开发人员中心下载 CLR 和 Windows 运行时白皮书。
表 1:映射到具有不同名称和/或命名空间的 .NET Framework 类型的 Windows 运行时类型。
Windows 运行时类型/命名空间 |
.NET Framework 类型/命名空间 |
.NET Framework 程序集 |
---|---|---|
AttributeUsageAttribute (Windows.Foundation.Metadata) |
AttributeUsageAttribute (System) |
System.Runtime.dll |
AttributeTargets (Windows.Foundation.Metadata) |
AttributeTargets (System) |
System.Runtime.dll |
DateTime (Windows.Foundation) |
DateTimeOffset (System) |
System.Runtime.dll |
EventHandler<T> (Windows.Foundation) |
EventHandler<T> (System) |
System.Runtime.dll |
EventRegistrationToken (Windows.Foundation) |
EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime) |
System.Runtime.InteropServices.WindowsRuntime.dll |
HResult (Windows.Foundation) |
Exception (System) |
System.Runtime.dll |
IReference<T> (Windows.Foundation) |
Nullable<T> (System) |
System.Runtime.dll |
TimeSpan (Windows.Foundation) |
TimeSpan (System) |
System.Runtime.dll |
Uri (Windows.Foundation) |
Uri (System) |
System.Runtime.dll |
IClosable (Windows.Foundation) |
IDisposable (System) |
System.Runtime.dll |
IIterable<T> (Windows.Foundation.Collections) |
IEnumerable<T> (System.Collections.Generic) |
System.Runtime.dll |
IVector<T> (Windows.Foundation.Collections) |
IList<T> (System.Collections.Generic) |
System.Runtime.dll |
IVectorView<T> (Windows.Foundation.Collections) |
IReadOnlyList<T> (System.Collections.Generic) |
System.Runtime.dll |
IMap<K,V> (Windows.Foundation.Collections) |
IDictionary<TKey,TValue> (System.Collections.Generic) |
System.Runtime.dll |
IMapView<K,V> (Windows.Foundation.Collections) |
IReadOnlyDictionary<TKey,TValue> (System.Collections.Generic) |
System.Runtime.dll |
IKeyValuePair<K,V> (Windows.Foundation.Collections) |
KeyValuePair<TKey,TValue> (System.Collections.Generic) |
System.Runtime.dll |
IBindableIterable (Windows.UI.Xaml.Interop) |
IEnumerable (System.Collections) |
System.Runtime.dll |
IBindableVector (Windows.UI.Xaml.Interop) |
IList (System.Collections) |
System.Runtime.dll |
INotifyCollectionChanged (Windows.UI.Xaml.Interop) |
INotifyCollectionChanged (System.Collections.Specialized) |
System.ObjectModel.dll |
NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedEventHandler (System.Collections.Specialized) |
System.ObjectModel.dll |
NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedEventArgs (System.Collections.Specialized) |
System.ObjectModel.dll |
NotifyCollectionChangedAction (Windows.UI.Xaml.Interop) |
NotifyCollectionChangedAction (System.Collections.Specialized) |
System.ObjectModel.dll |
INotifyPropertyChanged (Windows.UI.Xaml.Data) |
INotifyPropertyChanged (System.ComponentModel) |
System.ObjectModel.dll |
PropertyChangedEventHandler (Windows.UI.Xaml.Data) |
PropertyChangedEventHandler (System.ComponentModel) |
System.ObjectModel.dll |
PropertyChangedEventArgs (Windows.UI.Xaml.Data) |
PropertyChangedEventArgs (System.ComponentModel) |
System.ObjectModel.dll |
TypeName (Windows.UI.Xaml.Interop) |
Type (System) |
System.Runtime.dll |
表 2:映射到具有相同名称和命名空间的 .NET Framework 类型的 Windows 运行时类型。
命名空间 |
类型 |
.NET Framework 程序集 |
---|---|---|
Windows.UI |
Color |
System.Runtime.WindowsRuntime.dll |
Windows.Foundation |
Point |
System.Runtime.WindowsRuntime.dll |
Windows.Foundation |
Rect |
System.Runtime.WindowsRuntime.dll |
Windows.Foundation |
Size |
System.Runtime.WindowsRuntime.dll |
Windows.UI.Xaml.Input |
ICommand |
System.ObjectModel.dll |
Windows.UI.Xaml |
CornerRadius |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml |
Duration |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml |
DurationType |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml |
GridLength |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml |
GridUnitType |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml |
Thickness |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Controls.Primitives |
GeneratorPosition |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Media |
Matrix |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Media.Animation |
KeyTime |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Media.Animation |
RepeatBehavior |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Media.Animation |
RepeatBehaviorType |
System.Runtime.WindowsRuntime.UI.Xaml.dll |
Windows.UI.Xaml.Media.Media3D |
Matrix3D |
System.Runtime.WindowsRuntime.UI.Xaml.dll |