当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET XmlUrlResolver类代码示例

本文整理汇总了VB.NET中System.Xml.XmlUrlResolver的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlUrlResolver类的具体用法?VB.NET XmlUrlResolver怎么用?VB.NET XmlUrlResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XmlUrlResolver类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: XmlUrlResolver

' Create an XmlUrlResolver with default credentials.
Dim resolver As New XmlUrlResolver()
resolver.Credentials = CredentialCache.DefaultCredentials

' Create the reader.
Dim settings As New XmlReaderSettings()
settings.XmlResolver = resolver
Dim reader As XmlReader = _
   XmlReader.Create("http://serverName/data/books.xml", settings)
开发者ID:VB.NET开发者,项目名称:System.Xml,代码行数:9,代码来源:XmlUrlResolver

示例2: XmlCachingResolver

Class XmlCachingResolver
    Inherits XmlUrlResolver
    Dim enableHttpCaching As Boolean
    Public Shadows Credentials As ICredentials

    'resolve resources from cache (if possible) when enableHttpCaching is set to true
    'resolve resources from source when enableHttpcaching is set to false
    Public Sub New(ByVal enableHttpCaching As Boolean)
        Me.enableHttpCaching = enableHttpCaching
    End Sub

    Public Shadows Function GetEntity(ByVal absoluteUri As Uri, ByVal role As String, ByVal returnType As Type) As Object
        If absoluteUri = Nothing Then
            Throw New ArgumentNullException("absoluteUri")
        End If

        'resolve resources from cache (if possible)
        If absoluteUri.Scheme = "http" And enableHttpCaching And (returnType Is GetType(Nullable) Or returnType Is GetType(Stream)) Then
            Dim webReq As WebRequest = WebRequest.Create(absoluteUri)
            webReq.CachePolicy = New HttpRequestCachePolicy(HttpRequestCacheLevel.Default)
            If Not (Credentials Is Nothing) Then
                webReq.Credentials = Credentials
            End If
            Dim resp As WebResponse = webReq.GetResponse()
            Return resp.GetResponseStream()
            'otherwise use the default behavior of the XmlUrlResolver class (resolve resources from source)
        Else
            Return MyBase.GetEntity(absoluteUri, role, returnType)
        End If

    End Function
End Class
开发者ID:VB.NET开发者,项目名称:System.Xml,代码行数:32,代码来源:XmlUrlResolver


注:本文中的System.Xml.XmlUrlResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。