WalletItemStore.AddAsync(String, WalletItem) 方法

定义

注意

ApplicationModel.Wallet 命名空间不再受支持,不久将弃用。 建议开发人员避免使用此命名空间。

向电子钱包添加新的钱包项。

public:
 virtual IAsyncAction ^ AddAsync(Platform::String ^ id, WalletItem ^ item) = AddAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction AddAsync(winrt::hstring const& id, WalletItem const& item);
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Deprecated("IWalletItemStore is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
IAsyncAction AddAsync(winrt::hstring const& id, WalletItem const& item);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction AddAsync(string id, WalletItem item);
[Windows.Foundation.Metadata.RemoteAsync]
[Windows.Foundation.Metadata.Deprecated("IWalletItemStore is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
public IAsyncAction AddAsync(string id, WalletItem item);
function addAsync(id, item)
Public Function AddAsync (id As String, item As WalletItem) As IAsyncAction

参数

id
String

Platform::String

winrt::hstring

钱包项的标识符。 此值必须是唯一的。 这将设置初始 WalletItem.Id 值, (标识符是 WalletItemStore 存储区,并且不是 WalletItem 对象的初始化的一部分。

item
WalletItem

要添加到电子钱包的钱包项。

返回

异步操作。 如果使用 异步编程,则返回类型为 void

属性

注解

如果传递给此方法的 ID 值不唯一,或者项目已添加到电子钱包中,则会引发异常。 如何处理错误/异常因编程语言而异,尤其是在调用异步方法时。 请参阅 异步编程

请记住,调用此方法时,项目将添加到电子钱包项目存储区,该存储由设备拥有,而不是应用拥有。 在开发过程中,存储会跨应用会话保留,因此在运行另一个调试会话时尝试再次添加同一项可能会引发异常,因为该项已存在。 在尝试添加任何项之前,请考虑添加对 ClearAsync 的调用,并且至少在开发和测试代码时多次运行代码。

适用于

另请参阅