Can I add custom properties to PasswordCredential.Properties?

余生长醉 提交于 2019-11-28 11:08:57

问题


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:

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 ;)

EDIT: This may be useful:

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);

回答1:


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.




回答2:


No it is a read only property, so you can't set it. It's designed so you can enumerate the properties of the object (not that the c# class properties, but the individual properties of a properties collection). The naming makes this confusing.



来源:https://stackoverflow.com/questions/15978958/can-i-add-custom-properties-to-passwordcredential-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!