Just so long as no one uses a damned "Wrapper" div on the global level - ill be happy. If you are trying to center content... style the HTML and BODY elements. kthx
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: MyndFyre[vL] on November 16, 2006, 12:37 AMTrue, but not as simple, nor as quick. The inability to (de)serialize DateTime objects is the killer - and you have to hack in a timespan and convert it
However, I disagree on the use of the serialization framework. XML is probably not so much an evildoer in this instance, but for sure the binary formatter does not emit version-flexible output. Doing custom serialization as far as custom output or even writing custom XML files is FAR more flexible than trusting it to the serialization framework.
Namespace Management
<Serializable()> Public Class User
Public Name As String
Public Password As String
<XmlIgnore()> Public hash As New System.Security.Cryptography.HMACSHA1(System.Text.ASCIIEncoding.ASCII.GetBytes("mykey"))
Public Sub New()
End Sub
Public Sub New(ByVal _Name As String, ByVal _Password As String)
Name = _Name
Password = _Password
End Sub
Public Function Validate(ByVal ClearTextPW As String) As Boolean
Return GetPasswordHash(ClearTextPW).Equals(Password)
End Function
Public Function SetPassword(ByVal CleartextOldPW As String, ByVal CleartextNewPW As String) As Boolean
If Validate(CleartextOldPW) Then
Password = GetPasswordHash(CleartextNewPW)
Return True
End If
Return False
End Function
Private Function GetPasswordHash(ByVal ClearTextPW As String) As String
Return BitConverter.ToString(hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(ClearTextPW)))
End Function
End Class
<Serializable()> Public Class UserCollection
Inherits CollectionBase
Private _Serializer As XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(UserCollection))
Default Public Property Items(ByVal index As Integer) As User
Get
If index >= 0 And index < list.Count Then Return DirectCast(List(index), User)
End Get
Set(ByVal Value As User)
If index >= 0 And index < list.Count Then list(index) = Value
End Set
End Property
Default Public Property Items(ByVal Name As String) As User
Get
Dim index As Integer = Me.IndexOf(Name)
If Not index < 0 Then Return DirectCast(List(index), User)
End Get
Set(ByVal Value As User)
Dim index As Integer = Me.IndexOf(Name)
If Not index < 0 Then list(index) = Value
End Set
End Property
Public Overloads Function Equals(ByVal Users As UserCollection) As Boolean
If Not Users.Count = list.Count Then Return False
For index As Integer = 0 To List.Count - 1
If Not Users(index).Equals(Me(index)) Then Return False
Next
Return True
End Function
Public Function Add(ByVal Item As User) As Integer
If Not Me.Contains(Item) Then Return list.Add(Item)
End Function
Public Function Contains(ByVal Item As User) As Boolean
Return list.Contains(Item)
End Function
Public Sub CopyTo(ByVal Array As User(), ByVal index As Integer)
list.CopyTo(Array, index)
End Sub
Public Sub CopyTo(ByVal Array As IList, ByVal index As Integer)
For Each item As User In Me.List
Array.Add(item)
Next
End Sub
Public Function IndexOf(ByVal Item As User) As Integer
Return list.IndexOf(Item)
End Function
Public Function IndexOf(ByVal Name As String) As Integer
For index As Integer = 0 To list.Count - 1
If Name.ToLower.Equals(Me(index).Name.ToLower) Then
Return index
End If
Next
Return -1
End Function
Public Sub Insert(ByVal Index As Integer, ByVal Item As User)
list.Insert(Index, Item)
End Sub
Public Sub Remove(ByVal Item As User)
list.Remove(Item)
End Sub
Public Sub Remove(ByVal Name As String)
For index As Integer = 0 To list.Count - 1
If Me(index).Name.Equals(Name) Then
list.RemoveAt(index)
Exit For
End If
Next
End Sub
Public Function Save(ByVal Path As String) As Boolean
Dim fs As IO.FileStream
Try
IO.File.Copy(Path, Path & ".bak")
fs = IO.File.Open(Path, IO.FileMode.Truncate, IO.FileAccess.Write)
_Serializer.Serialize(fs, Me)
IO.File.Delete(Path & ".bak")
fs.Close()
Catch
fs.Close()
IO.File.Delete(Path)
IO.File.Move(Path & ".bak", Path)
End Try
Return True
End Function
Public Sub New(ByVal Path As String)
Dim fs As IO.FileStream
Try
fs = IO.File.Open(Path, IO.FileMode.Open, IO.FileAccess.Read)
Dim lc As UserCollection = _Serializer.Deserialize(fs)
lc.CopyTo(Me.List, 0)
Finally
fs.Close()
End Try
End Sub
Public Sub New()
End Sub
End Class
End Namespace
Quote from: MyndFyre on January 17, 2006, 01:03 PM
See:Quote from: MSDNRemarks
The Flush method implements the Stream.Flush method; however, because NetworkStream is not buffered, it has no affect on network streams. Calling the Flush method will not throw an exception.
Indulgence, I suggest you take a look at that last sentence before you try to look cool.
Quote from: MSDNNetworkStream.Flush Method
Flushes data from the stream. This method is reserved for future use.
Remarks
The Flush method implements the Stream.Flush method; however, because NetworkStream is not buffered, it has no affect on network streams. Calling the Flush method will not throw an exception.
Function Receive() As String
Dim Bytes(wSock.ReceiveBufferSize) As Byte
Dim objSR As New System.IO.StreamReader(Stream, Encoding.ASCII)
Receive = (objSR.ReadToEnd())
End Function
Quote from: [Unknown] on June 15, 2005, 11:54 AM
READ THE DATES!!!!!!!!!!!!!!!!!
Page created in 0.058 seconds with 16 queries.