我可以向 PasswordCredential.Properties 添加自定义属性吗? [英] Can I add custom properties to PasswordCredential.Properties?

查看:18
本文介绍了我可以向 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 添加自定义属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆