⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constructors.cls

📁 VB 加密----------能够加密解密控件
💻 CLS
📖 第 1 页 / 共 5 页
字号:

' For internal use only.
Friend Function NewStreamAsyncResult(ByVal ObjectState As Variant) As StreamAsyncResult
    Set NewStreamAsyncResult = New StreamAsyncResult
    Call NewStreamAsyncResult.Init(ObjectState)
End Function

''
' Returns a new memoryStream object which uses a supplied byte array.
'
' @param Buffer The supplied byte array to act upon.
' @param Index The starting index in the array to begin usage.
' @param Count The total bytes that can be used by the stream.
' @param writable Whether or not to allow the stream to be written to.
' @return The newly created MemoryStream containing the supplied byte buffer.
' @remarks By using a user supplied buffer, the user can decide how much of the
' buffer is actually accessable. The buffer cannot be increased in size. The stream
' does not release the byte Buffer. The user still must maintain a reference to the
' array and keep it alive for the duration of the MemoryStream's life.
'
Public Function NewMemoryStream(ByRef Buffer() As Byte, Optional ByVal Index As Variant, Optional ByVal Count As Variant, Optional ByVal Writable As Boolean = True) As MemoryStream
    Set NewMemoryStream = New MemoryStream
    Call NewMemoryStream.Init(Buffer, Index, Count, Writable)
End Function

''
' Returns a new StringBuilder with user specified settings and starting string.
'
' @param s A string to be inititially placed in the builder. If this is specified, then
' Capacity will be set to no less than Count.
' @param StartIndex The starting index in s to begin placing into the buffer.
' @param Count The number of characters in s to place into the buffer.
' @param Capacity The capacity of the internal buffer. If this is less than Count, then
' Count will override this value.
' @return A new StringBuilder with s already placed in the buffer.
'
Public Function NewStringBuilder(Optional ByRef s As String, Optional ByRef StartIndex As Variant, Optional ByRef Count As Variant, Optional ByVal Capacity As Long = 512) As StringBuilder
    Set NewStringBuilder = New StringBuilder
    Call NewStringBuilder.Init(s, StartIndex, Count, Capacity)
End Function

''
' Returns a new FileStream to access an underyling file.
'
' @param Path The name of the file to manipulate.
' @param Mode The method used to create or open a file.
' @param Access The access allowed to the file for this FileStream.
' @param Share The access allowed to the file for other processes.
' @param BufferSize The number of bytes used to cache reads and writes from the physical file.
' @param UseAsync Flag used to open the file in asyncronous mode.
' @return The new FileStream opened to the specified file.
'
Public Function NewFileStream(ByVal Path As String, ByVal Mode As FileMode, Optional ByVal Access As FileAccess = -1, Optional ByVal Share As FileShare = FileShare.ReadShare, Optional ByVal BufferSize As Long = 4096, Optional ByVal UseAsync As Boolean = False) As FileStream
    Set NewFileStream = New FileStream
    Call NewFileStream.Init(Path, Mode, Access, Share, BufferSize, UseAsync)
End Function

''
' Returns a new FileStream to access a file other than that on disk, such as pipes.
'
' @param Handle The handle to the already opened filed.
' @param Access The access allowed to the file for this FileStream.
' @param OwnsHandle Determines if the FileStream object is responsible for closing the file passed in.
' @param BufferSize The number of bytes used to cache reads and writes from the physical file.
' @return The new FileStream opened to the specified file.
'
Public Function NewFileStreamFromHandle(ByVal Handle As Long, ByVal Access As FileAccess, Optional ByVal OwnsHandle As Boolean = True, Optional ByVal BufferSize As Long = 4096) As FileStream
    Set NewFileStreamFromHandle = New FileStream
    Call NewFileStreamFromHandle.InitFromHandle(Handle, Access, OwnsHandle, BufferSize)
End Function

''
' Returns a new UnicodeEncoding object with the specified settings.
'
' @param BigEndian Indicates if the byte order for a character should be high byte first (default is low byte first.)
' @param ByteOrderMark Indicates whether or not the encoding should emit the preamble bytes in the GetPreamble method.
' @return The new UnicodeEncoding object.
' @remarks If ByteOrderMark is True then the GetPreamble will emit one of the following byte arrays.
' <p>BigEnding = True: &HFE, &HFF<br>
' BigEnding = False: &HFF, &HFE</p>
'
Public Function NewUnicodeEncoding(ByVal BigEndian As Boolean, ByVal ByteOrderMark As Boolean) As UnicodeEncoding
    Set NewUnicodeEncoding = New UnicodeEncoding
    Call NewUnicodeEncoding.Init(BigEndian, ByteOrderMark)
End Function

''
' Returns a new StringWriter object.
'
' @param sb A supplied StringBuilder object that is written to. This allows the
' StringWriter to start with an already created string.
' @param provider An object that provided formatting information for numbers and dates.
' @return The new StringWriter object.
'
Public Function NewStringWriter(Optional ByVal sb As StringBuilder, Optional ByVal Provider As IFormatProvider) As StringWriter
    Set NewStringWriter = New StringWriter
    Call NewStringWriter.Init(sb, Provider)
End Function

''
' Returns a new StringReader object.
'
' @param s The string to be read from.
' @param IsOwner Tells StringReader to steal the string from the source.
' @return The new StringReader object.
' @remarks If <i>IsOwner</i> is True, then the variable passed into as <i>s</i>
' will become an empty string after the object is constructed.
'
Public Function NewStringReader(ByRef s As String, Optional ByVal IsOwner As Boolean) As StringReader
    Set NewStringReader = New StringReader
    Call NewStringReader.Init(s, IsOwner)
End Function

''
' Creates a new DirectoryInfo object that describes the specified path.
'
' @param Path The directory path this instance describes and manipulates.
' @return The new object used to manage a directory path.
' @remarks When a <b>DirectoryInfo</b> object is created, there is no
' attempt at verifying the <i>Path</i>. Only when an attempt to manipulate
' the actual directroy is the path validated.
'
Public Function NewDirectoryInfo(ByVal Path As String) As DirectoryInfo
    Set NewDirectoryInfo = New DirectoryInfo
    Call NewDirectoryInfo.Init(Path)
End Function

''
' Creates a new DirectoryNotFoundException object with the specified message and optional exception.
'
' @param Message A human-readable message describing the exception.
' @param InnerException The exception that caused this exception to be thrown.
' @return A new DirectoryNotFoundException object with the specified message and optional exception.
'
Public Function NewDirectoryNotFoundException(ByVal Message As String, Optional ByVal InnerException As Exception) As DirectoryNotFoundException
    Set NewDirectoryNotFoundException = New DirectoryNotFoundException
    Call NewDirectoryNotFoundException.Init(Message, InnerException)
End Function

''
' Creates a new StreamWriter with either a filename or other stream as a source to write to
' in the specified Encoding.
'
' @param Source Either a FileName or Stream object to write to.
' @param Encoding The encoding to be used when writing to the stream.
' @param BufferSize The minimum size of the internal buffer used to cache writes.
' @param Append Indicates if a file is to be appended to or overwritten.
' @return A new StreamWriter ready to write to an underlying stream in the specified Encoding.
' @remarks <p>If a FileName is passed in, then a FileStream is created internally Using either
' FileMode.Create or FileMode.Append depending on Append, FileAccess.WriteAccess, FileShare.ReadShare.</p>
' <p>If Encoding is not supplied, then an encoding of Cor.NewUTF8Encoding(False, True) is used.</p>
'
Public Function NewStreamWriter(ByVal Source As Variant, Optional ByVal Encoding As Encoding, Optional ByVal BufferSize As Long = 4096, Optional ByVal Append As Boolean = False) As StreamWriter
    Set NewStreamWriter = New StreamWriter
    Call NewStreamWriter.Init(Source, Encoding, BufferSize, Append)
End Function

''
' Creates a new StreamReader from either a FileName or an existing stream to read from.
'
' @param Source A FileName used to open an existing file as a FileStream, or an existing Stream object.
' @param Encoding The encoding to be used when decoding bytes from the stream.
' @param determineEncodingFromByteOrderMarks Requests that the reader attempt to determine what type of
' encoding is being used in the stream by reading the first few bytes.
' @param BufferSize The size of the internal cache used to improve performance.
' @return A newly initialized StreamReader object.
' @remarks <p>If a filename is specified, then an internal FileStream object is created using an
' initialization of Cor.NewFileStream(Source, FileMode.OpenExisting, FileAccess.ReadAccess, FileShare.ReadShare).</p>
' <p>If <i>determineEncodingFromByteOrderMarks</i> is True, then up to 3 bytes are read from the stream
' upon the first attempt to read any data from the stream. The bytes are used to determine if a specific
' encoding has been used. There are 3 encoding signatures that are looked for.<br>
' &HFE, &HFF - UnicodeEncoding with Little Endian byte ordering<br>
' &HFF, &HFE - UnicodeEncoding with Big Endian byte ordering<br>
' &HEF, &HBB, &HBF - UTF8Encoding<br>
' If no encoding is identified, then Encoding.UTF8 is used.
'
Public Function NewStreamReader(ByVal Source As Variant, Optional ByVal Encoding As Encoding, Optional ByVal determineEncodingFromByteOrderMarks As Boolean = True, Optional ByVal BufferSize As Long = 4096) As StreamReader
    Set NewStreamReader = New StreamReader
    Call NewStreamReader.Init(Source, Encoding, determineEncodingFromByteOrderMarks, BufferSize)
End Function

''
' Creates a new FileInfo object used to describe and manage a file.
'
' @param FileName The name of the file to manage (may need path information as well.)
' @return The FileInfo object to manage a file.
' @remarks When the FileInfo object is first created, it does not verify the existence.
' of the actual file. Once access to the file through the object is attempt, the file
' will be verified at that time. Portions of the object that doesn't directly interact
' with the file will not verify the existence of the file.
'
Public Function NewFileInfo(ByVal FileName As String) As FileInfo
    Set NewFileInfo = New FileInfo
    Call NewFileInfo.Init(FileName)
End Function

''
' Returns a new BinaryWriter used to write to a Stream object.
'
' @param Stream The stream to be written to by the writer.
' @param Encoding The encoding to be used when converting chars to bytes.
' @return The new BinaryWriter object.
' @remarks The Stream object must support writing.<br>
' <p>If no Encoding object is supplied, then an encoding of Cor.NewUTF8Encoding(False, True) is used.</p>
'
Public Function NewBinaryWriter(ByVal Stream As Stream, Optional ByVal Encoding As Encoding) As BinaryWriter
    Set NewBinaryWriter = New BinaryWriter
    Call NewBinaryWriter.Init(Stream, Encoding)
End Function

''
' Returns a new EndOfStreamException with the specified message and optional exception.
'
' @param Message A human-readable message that describes the cause of the exception.
' @param InnerException The exception that caused this exception.
' @return The new exception object.
' @remarks This exception can be thrown whenever an attempt to read passed the end of a stream
' is attempted. Such classes as BinaryReader may throw this exception if necessary.
'
Public Function NewEndOfStreamException(ByVal Message As String, Optional ByVal InnerException As Exception) As EndOfStreamException
    Set NewEndOfStreamException = New EndOfStreamException
    Call NewEndOfStreamException.Init(Message, InnerException)
End Function

''
' Returns a new BinaryReader that can read from the specified stream usind the specified Encoding.
'
' @param Stream The stream to read the data from.
' @param Encoding The encoding system to be used to decode the bytes from the stream.
' @return The new BinaryReader with the specified stream and encoding.
' @remarks If no Encoding is specified, then the reader uses an Encoding of New UTF8Encoding.
'
Public Function NewBinaryReader(ByVal Stream As Stream, Optional ByVal Encoding As Encoding) As BinaryReader
    Set NewBinaryReader = New BinaryReader
    Call NewBinaryReader.Init(Stream, Encoding)
End Function

''
' Returns a new OverflowException with the specified message and exception.
'
' @param Message A human-readable message describing the exception.
' @param InnerException The exception that caused this exception.
' @return The new OverflowException object.
' @return This exception is thrown when a value may not fit into an existing datatype.
'
Public Function NewOverflowException(ByVal Message As String, Optional ByVal InnerException As Exception) As OverflowException
    Set NewOverflowException = New OverflowException
    Call NewOverflowException.Init(Message, InnerException)
End Function

''
' Creates an enumerator used to iterate over the Unicode characters of a String.
'
' @param s The string to iterate each character of.
' @param CopyString Indicates if the enumerator should create a copy of the passed
' in string, or use the existing string in memory.
' @return A CharEnumerator used to iterate over each character of a String.
' @remarks By default <b>CharEnumerator</b> makes a copy of the passed in
' String. The original string can be changed as normal. If <i>CopyString</i> is set
' to False, then the original string must not change or go out of scope for the
' duration of the <b>CharEnumerator</b> object's existance. By telling <b>CharEnumerator</b>
' to not make a copy of the original string, memory is not allocated for the string,
' which can be helpful for large strings.
'
Public Function NewCharEnumerator(ByRef s As String, Optional ByVal CopyString As Boolean = True) As CharEnumerator
    Set NewCharEnumerator = New CharEnumerator
    Call NewCharEnumerator.Init(s, CopyString)
End Function

''
' Creates a new instance of the Gregorian calendar class.
'
' @param CalendarType The language type the calendar is set to.
' @return A new instance of a GregorianCalendar class.
'
Public Function NewGregorianCalendar(ByVal CalendarType As GregorianCalendarTypes) As GregorianCalendar
    Set NewGregorianCalendar = New GregorianCalendar
    Call NewGregorianCalendar.Init(CalendarType)
End Function

''
' Creates a new ApplicationException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created ApplicationException object.
'
' @see ApplicationException
'
Public Function NewApplicationException(ByVal Message As String, Optional ByVal InnerException As Exception) As ApplicationException
    Set NewApplicationException = New ApplicationException
    Call NewApplicationException.Init(Message, InnerException)
End Function

''
' Enumerates through the resources in a .RES file.
'
' @param Source The filename or stream to read from.
' @return A reader used to enumerate the resources.
'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -