共用方式為


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

電子包專案的識別碼。 此值必須是唯一的。 這會設定識別碼 (為 WalletItemStore存放區的初始WalletItem.Id值,而且不是WalletItem物件的初始化的一部分。

item
WalletItem

要新增至電子錢包的電子錢包專案。

傳回

非同步動作。 如果您使用 非同步程式設計,則傳回類型為 void

屬性

備註

如果傳入這個方法的 識別碼 值不是唯一的,或專案已經新增至電子包,則會擲回例外狀況。 如何處理錯誤/例外狀況會因程式設計語言而異,特別是在呼叫非同步方法時。 請參閱 非同步程式設計

請記住,當您呼叫此方法時,專案會新增至電子錢包專案存放區,該存放區是由裝置所擁有,而不是應用程式。 當您仍在開發時,存放區會在應用程式會話之間保存,因此在執行另一個偵錯會話時嘗試再次新增相同的專案可能會擲回例外狀況,因為專案已經存在。 建議您先新增 ClearAsync 的呼叫,再嘗試新增任何專案,而且您至少在執行程式碼一次以上,至少在您仍在開發及測試程式碼時。

適用於

另請參閱