我可以向 PasswordCredential.Properties 添加自定义属性吗?

Can I add custom properties to PasswordCredential.Properties?(我可以向 PasswordCredential.Properties 添加自定义属性吗?)
本文介绍了我可以向 PasswordCredential.Properties 添加自定义属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WinRT API 中有 Windows.Security.Credentials 命名空间,其中包含 PasswordCredential 类.使用它,我们可以加密敏感数据,如用户名和密码,但该类本身有一个名为Properties"的属性,在我看来,它就像一个方便的容器,用于存放与存储的凭据相关的其他自定义属性,但我无法让它工作.文档中有属性"的只读"访问类型,但我认为这仅意味着我无法更改对它指向的容器的引用.我的问题是:

In WinRT API there is Windows.Security.Credentials namespace which contains the PasswordCredential class. Using it we can encrypt sensitive data like user names and passwords but the class itself has a property named "Properties" which looks to me like a handy container for other custom properties somehow related to the stored credential but I can't get it to work. There is a "Read-only" access type for the "Properties" in the documentation but I thought that meant only that I can't change the reference to the container it points to. My question is:

是 PasswordCredential 对程序员有用吗?

Is the "Properties" property of PasswordCredential useable for programmers?

抱歉文字有任何错误,您也可以在答案中纠正我的英文,它不是我的母语;)

Sorry for any errors in text, you can also correct my english in the answers, it is not my native language ;)

这可能有用:

以下代码中的Add"方法抛出ArgumentException:

The "Add" method in the following code throws ArgumentException:

PasswordVault v = new PasswordVault();
PasswordCredential c = new PasswordCredential("TEST", "TEST", "TEST");
c.Properties.Add("Name", "testName");
v.Add(c);

推荐答案

不幸的是,PasswordCredentials.Properties 是 PasswordCredentialPropertyStore 该文档将每种方法描述为......保留供内部使用,不打算在您的代码中使用".

Unfortunately, the PasswordCredentials.Properties is an instance of PasswordCredentialPropertyStore which documentation describes every method as "...reserved for internal use and not intended to be used in your code".

这就是为什么它不适合程序员.

That's why it is not useable for programmers.

这篇关于我可以向 PasswordCredential.Properties 添加自定义属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)