本文整理汇总了VB.NET中System.Net.ICredentials接口的典型用法代码示例。如果您正苦于以下问题:VB.NET ICredentials接口的具体用法?VB.NET ICredentials怎么用?VB.NET ICredentials使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
在下文中一共展示了ICredentials接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: CredentialInfo
Class CredentialInfo
Public uriObj As Uri
Public authenticationType As [String]
Public networkCredentialObj As NetworkCredential
Public Sub New(uriObj As Uri, authenticationType As [String], networkCredentialObj As NetworkCredential)
Me.uriObj = uriObj
Me.authenticationType = authenticationType
Me.networkCredentialObj = networkCredentialObj
End Sub
End Class
Private arrayListObj As ArrayList
Public Sub New()
arrayListObj = New ArrayList()
End Sub
Public Sub Add(uriObj As Uri, authenticationType As [String], credential As NetworkCredential)
' adds a 'CredentialInfo' object into a list
arrayListObj.Add(New CredentialInfo(uriObj, authenticationType, credential))
End Sub
' Remove the 'CredentialInfo' object from the list which matches to the given 'Uri' and 'AuthenticationType'
Public Sub Remove(uriObj As Uri, authenticationType As [String])
Dim index As Integer
For index = 0 To arrayListObj.Count - 1
Dim credentialInfo As CredentialInfo = CType(arrayListObj(index), CredentialInfo)
If uriObj.Equals(credentialInfo.uriObj) And authenticationType.Equals(credentialInfo.authenticationType) Then
arrayListObj.RemoveAt(index)
End If
Next index
End Sub
Public Function GetCredential(uriObj As Uri, authenticationType As [String]) As NetworkCredential Implements ICredentials.GetCredential
Dim index As Integer
For index = 0 To arrayListObj.Count - 1
Dim credentialInfoObj As CredentialInfo = CType(arrayListObj(index), CredentialInfo)
If uriObj.Equals(credentialInfoObj.uriObj) And authenticationType.Equals(credentialInfoObj.authenticationType) Then
Return credentialInfoObj.networkCredentialObj
End If
Next index
Return Nothing
End Function 'GetCredential
开发者ID:VB.NET开发者,项目名称:System.Net,代码行数:47,代码来源:ICredentials
注:本文中的System.Net.ICredentials接口示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论