AnalyticsInfo.GetSystemPropertiesAsync(IIterable<String>) 方法

定義

以非同步方式擷取要求的系統屬性。

public:
 static IAsyncOperation<IMapView<Platform::String ^, Platform::String ^> ^> ^ GetSystemPropertiesAsync(IIterable<Platform::String ^> ^ attributeNames);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<IMapView<winrt::hstring, winrt::hstring const&>> GetSystemPropertiesAsync(IIterable<winrt::hstring> const& attributeNames);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<IReadOnlyDictionary<string,string>> GetSystemPropertiesAsync(IEnumerable<string> attributeNames);
function getSystemPropertiesAsync(attributeNames)
Public Shared Function GetSystemPropertiesAsync (attributeNames As IEnumerable(Of String)) As IAsyncOperation(Of IReadOnlyDictionary(Of String, String))

參數

attributeNames

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

包含要擷取之系統屬性的字串 IIterable 清單。

傳回

IAsyncOperation<IMapView<String,String>>

IAsyncOperation<IReadOnlyDictionary<String,String>>

IAsyncOperation<IMapView<Platform::String,Platform::String>>

IAsyncOperation<IMapView<winrt::hstring,winrt::hstring>>

會傳回 IAsyncOperation 物件,指出工作已完成,並且包含具有要求屬性的 IMapView 物件做為索引鍵/值組。

屬性

Windows 需求

裝置系列
Windows 10, version 1803 (已於 10.0.17134.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v6.0 引進)

範例

using Windows.System.Profile;

// ...

var attrNames = new List<string>({"DeviceFamily", "OSVersionFull", "FlightRing"});
var attrData = AnalyticsInfo.GetSystemPropertiesAsync(attrNames).AsTask().GetAwaiter().GetResult();

// The map can be serialized and sent to a backend service for analytics or targeting 
foreach (KeyValuePair<string, string> attr in attrData) 
{ 
    Console.WriteLine($"{attr.Key}={attr.Value}");
}

備註

attributeNames參數支援的值可能無限。 有許多提供者會連結,而且可以公開任意值。 有一些可能支援的已知屬性。 在大部分情況下,這些會區分大小寫:

  • 應用程式
  • AppVer
  • DeviceFamily
  • FlightRing
  • OSVersionFull

此方法的目的是只針對分析使用這項資訊,而不依賴用戶端上的特定值。 這些值的支援會隨著時間而變更。

適用於