#Region "Header"
' Licensed to the Apache Software Foundation (ASF) under one
' or more contributor license agreements. See the NOTICE file
' distributed with this work for additional information
' regarding copyright ownership. The ASF licenses this file
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
' KIND, either express or implied. See the License for the
' specific language governing permissions and limitations
' under the License.
#End Region ' Header
'
Imports System.IO
'''
''' Load XML resources from local file
'''
''' -
Friend NotInheritable Class FileLoader : Implements ILoader
'
Private Property resLength As Long = -1
Private Property resReader As IO.StreamReader = Nothing
Private Property resUrl As String = String.Empty
'
#Region "Properties"
'''
''' Resource path
'''
''' String
''' -
Public ReadOnly Property Path As String Implements ILoader.Path
Get
Return resUrl
End Get
End Property
'''
''' Returns the resource file length
'''
''' Long
''' file length
Public ReadOnly Property ResponseLength As Long Implements ILoader.ResponseLength
Get
Return resLength
End Get
End Property
'''
''' Reader
'''
''' StreamReader
''' -
Public ReadOnly Property Reader() As IO.StreamReader Implements ILoader.Reader
Get
Return resReader
End Get
End Property
#End Region ' Properties
#Region "Constructor"
'''
''' Load resource for path string
'''
''' path and file name of resource file
''' thrown when file does not exist
''' -
Public Sub New(filePath As String)
resUrl = filePath.Trim
If IO.File.Exists(resUrl) Then
resLength = New IO.FileInfo(filePath).Length
resReader = New IO.StreamReader(resUrl)
Else
Throw New ArgumentException(String.Format(Constants.FILE_ERROR_FORMAT, resUrl))
End If
End Sub
#End Region ' Constructor
End Class