Click here to Skip to main content
15,915,702 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionabt state management Pin
sridevi1415-Mar-07 17:30
sridevi1415-Mar-07 17:30 
AnswerRe: abt state management Pin
N a v a n e e t h15-Mar-07 18:17
N a v a n e e t h15-Mar-07 18:17 
AnswerRe: abt state management Pin
badgrs16-Mar-07 0:36
badgrs16-Mar-07 0:36 
Questionerror run solution vs 20005 sp1 Pin
AnhTin15-Mar-07 17:15
AnhTin15-Mar-07 17:15 
AnswerRe: error run solution vs 20005 sp1 Pin
Harini N K15-Mar-07 18:26
Harini N K15-Mar-07 18:26 
QuestionThe ConnectionString property has not been initialized." Pin
sridevi1415-Mar-07 17:11
sridevi1415-Mar-07 17:11 
AnswerRe: The ConnectionString property has not been initialized." Pin
N a v a n e e t h15-Mar-07 18:19
N a v a n e e t h15-Mar-07 18:19 
QuestionRequire Generic Custom Collection code in C#.Net Pin
ravi88515-Mar-07 17:07
ravi88515-Mar-07 17:07 
Hi,
I alreadt have generic custom colection code developed in VB.Net couldany body pls. provide me the same code in C#.Net it is very urgent .....your help will be appreaciated.
I am copying the collection code in VB.Net below


Imports System
Imports System.Data.SqlClient
Imports System.Collections

'///
'/// A strongly-typed collection of <see cref="SqlParameter"> objects.
'///

<serializable()> _
Friend Class SqlParamCollection
Implements ICollection
Implements IList
Implements IEnumerable
Implements ICloneable

#Region "Interfaces"
'///
'/// Supports type-safe iteration over a <see cref="SqlParamCollection">.
'///

Public Interface ISqlParamCollectionEnumerator

'///
'/// Gets the current element in the collection.
'///

ReadOnly Property Current() As SqlParameter

'///
'/// Advances the enumerator to the next element in the collection.
'///

'/// <exception cref="InvalidOperationException">
'/// The collection was modified after the enumerator was created.
'///
'/// <returns>
'/// <c>true if the enumerator was successfully advanced to the next element
'/// <c>false if the enumerator has passed the end of the collection.
'///
Function MoveNext() As Boolean

'///
'/// Sets the enumerator to its initial position, before the first element in the collection.
'///

Sub Reset()
End Interface
#End Region

Private Const DEFAULT_CAPACITY As Integer = 15

#Region "Implementation (data)"
Private m_array() As SqlParameter
Private m_count As Integer = 0
<nonserialized()> _
Private m_version As Integer = 0
#End Region


#Region "Static Wrappers"
'///
'/// Creates a synchronized (thread-safe) wrapper for a
'/// <c>SqlParamCollection instance.
'///

'/// <returns>
'/// An <c>SqlParamCollection wrapper that is synchronized (thread-safe).
'///
Public Shared Function Synchronized(ByVal list As SqlParamCollection) As SqlParamCollection
If (list Is Nothing) Then
Throw New ArgumentNullException("list")
End If
Return New SyncSqlParamCollection(list)
End Function

'///
'/// Creates a read-only wrapper for a
'/// <c>SqlParamCollection instance.
'///

'/// <returns>
'/// An <c>SqlParamCollection wrapper that is read-only.
'///
Public Shared Function GetReadOnly(ByVal list As SqlParamCollection) As SqlParamCollection
If (list Is Nothing) Then
Throw New ArgumentNullException("list")
End If
Return New ReadOnlySqlParamCollection(list)
End Function
#End Region

#Region "Construction"
'///
'/// Initializes a new instance of the <c>SqlParamCollection class
'/// that is empty and has the default initial capacity.
'///

Public Sub New()
m_array = New SqlParameter(DEFAULT_CAPACITY) {}
End Sub

'///
'/// Initializes a new instance of the <c>SqlParamCollection class
'/// that has the specified initial capacity.
'///

'/// <param name="capacity" />
'/// The number of elements that the new <c>SqlParamCollection is initially capable of storing.
'///
Public Sub New(ByVal capacity As Integer)
m_array = New SqlParameter(capacity) {}
End Sub

'///
'/// Initializes a new instance of the <c>SqlParamCollection class
'/// that contains elements copied from the specified <c>SqlParamCollection.
'///

'/// <param name="c" />The <c>SqlParamCollection whose elements are copied to the new collection.
Public Sub New(ByVal c As SqlParamCollection)
m_array = New SqlParameter(c.Count) {}
AddRange(c)
End Sub

'///
'/// Initializes a new instance of the <c>SqlParamCollection class
'/// that contains elements copied from the specified <see cref="SqlParameter"> array.
'///

'/// <param name="a" />The <see cref="SqlParameter"> array whose elements are copied to the new list.
Public Sub New(ByVal a() As SqlParameter)
m_array = New SqlParameter(a.Length) {}
AddRange(a)
End Sub
#End Region

#Region "Operations (type-safe ICollection)"
'///
'/// Gets the number of elements actually contained in the <c>SqlParamCollection.
'///

Public Overridable ReadOnly Property Count() As Integer Implements ICollection.Count
Get
Return m_count
End Get
End Property

'///
'/// Copies the entire <c>SqlParamCollection to a one-dimensional
'/// <see cref="SqlParameter"> array.
'///

'/// <param name="array" />The one-dimensional <see cref="SqlParameter"> array to copy to.
Public Overridable Sub CopyTo(ByVal array() As SqlParameter)
Me.CopyTo(array, 0)
End Sub

'///
'/// Copies the entire <c>SqlParamCollection to a one-dimensional
'/// <see cref="SqlParameter"> array, starting at the specified index of the target array.
'///

'/// <param name="array" />The one-dimensional <see cref="SqlParameter"> array to copy to.
'/// <param name="start" />The zero-based index in <paramref name="array"> at which copying begins.
Public Overridable Sub CopyTo(ByVal array() As SqlParameter, ByVal start As Integer)
If (m_count > (array.GetUpperBound(0) + 1 - start)) Then
Throw New System.ArgumentException("Destination array was not long enough.")
End If
array.Copy(m_array, 0, array, start, m_count)
End Sub

'///
'/// Gets a value indicating whether access to the collection is synchronized (thread-safe).
'///

'/// <returns>true if access to the ICollection is synchronized (thread-safe) otherwise, false.
Public Overridable ReadOnly Property IsSynchronized() As Boolean Implements ICollection.IsSynchronized
Get
Return m_array.IsSynchronized
End Get
End Property

'///
'/// Gets an object that can be used to synchronize access to the collection.
'///

Public Overridable ReadOnly Property SyncRoot() As Object Implements ICollection.SyncRoot
Get
Return m_array.SyncRoot
End Get
End Property
#End Region


#Region "Operations (type-safe IList)"
'///
'/// Gets or sets the <see cref="SqlParameter"> at the specified index.
'///

'/// <param name="index" />The zero-based index of the element to get or set.
'/// <exception cref="ArgumentOutOfRangeException">
'/// <para><paramref name="index"> is less than zero
'/// <para>-or-
'/// <para><paramref name="index"> is equal to or greater than <see cref="SqlParamCollection.Count">.
'///
Default Public Overridable Property Item(ByVal index As Integer) As SqlParameter
Get
ValidateIndex(index) '// throws
Return m_array(index)
End Get
Set(ByVal Value As SqlParameter)
ValidateIndex(index) '// throws
m_version += 1
m_array(index) = Value
End Set
End Property

'///
'/// Gets or sets the <see cref="SqlParameter"> with the specified key.
'///

'/// <param name="key" />The name of the element to get or set.
'/// <exception cref="ArgumentException">
'///
Default Public Overridable Property Item(ByVal key As String) As SqlParameter
Get
Dim index As Integer
index = FindItem(key) '// throws
Return m_array(index)

End Get
Set(ByVal Value As SqlParameter)
Dim index As Integer
index = FindItem(key) '// throws
m_version += 1
m_array(index) = Value
End Set
End Property

'///
'/// Adds a <see cref="SqlParameter"> to the end of the <c>SqlParamCollection.
'///

'/// <param name="item" />The <see cref="SqlParameter"> to be added to the end of the <c>SqlParamCollection.
'/// <returns>The index at which the value has been added.
Public Overridable Function Add(ByVal item As SqlParameter) As Integer
If (m_count = m_array.Length) Then
EnsureCapacity(m_count + 1)
End If

m_array(m_count) = item
m_version += 1
m_count += 1
Return (m_count - 1)
End Function

'///
'/// Removes all elements from the <c>SqlParamCollection.
'///

Public Overridable Sub Clear() Implements IList.Clear
m_version += 1
m_array = New SqlParameter(DEFAULT_CAPACITY) {}
m_count = 0
End Sub

'///
'/// Creates a shallow copy of the <see cref="SqlParamCollection">.
'///

Public Overridable Function Clone() As Object Implements ICloneable.Clone
Dim newColl As SqlParamCollection = New SqlParamCollection(m_count)
Array.Copy(m_array, 0, newColl.m_array, 0, m_count)
newColl.m_count = m_count
newColl.m_version = m_version

Return newColl
End Function

'///
'/// Determines whether a given <see cref="SqlParameter"> is in the <c>SqlParamCollection.
'///

'/// <param name="item" />The <see cref="SqlParameter"> to check for.
'/// <returns><c>true if <paramref name="item"> is found in the <c>SqlParamCollection otherwise, <c>false.
Public Overridable Function Contains(ByVal item As SqlParameter) As Boolean
Dim i As Integer
For i = 0 To (m_count - 1) Step 1
If (m_array(i).Equals(item)) Then
Return True
End If
Next
Return False
End Function

'///
'/// Returns the zero-based index of the first occurrence of a <see cref="SqlParameter">
'/// in the <c>SqlParamCollection.
'///

'/// <param name="item" />The <see cref="SqlParameter"> to locate in the <c>SqlParamCollection.
'/// <returns>
'/// The zero-based index of the first occurrence of <paramref name="item">
'/// in the entire <c>SqlParamCollection, if found otherwise, -1.
'///
Public Overridable Function IndexOf(ByVal item As SqlParameter) As Integer
Dim i As Integer
For i = 0 To (m_count - 1) Step 1
If (m_array(i).Equals(item)) Then
Return i
End If
Next
Return -1
End Function

'///
'/// Inserts an element into the <c>SqlParamCollection at the specified index.
'///

'/// <param name="index" />The zero-based index at which <paramref name="item"> should be inserted.
'/// <param name="item" />The <see cref="SqlParameter"> to insert.
'/// <exception cref="ArgumentOutOfRangeException">
'/// <para><paramref name="index"> is less than zero
'/// <para>-or-
'/// <para><paramref name="index"> is equal to or greater than <see cref="SqlParamCollection.Count">.
'///
Public Overridable Sub Insert(ByVal index As Integer, ByVal item As SqlParameter)
ValidateIndex(index, True) '// throws

If (m_count = m_array.Length) Then EnsureCapacity(m_count + 1)

If (index < m_count) Then
Array.Copy(m_array, index, m_array, index + 1, m_count - index)
End If

m_array(index) = item
m_count += 1
m_version += 1
End Sub

'///
'/// Removes the first occurrence of a specific <see cref="SqlParameter"> from the <c>SqlParamCollection.
'///

'/// <param name="item" />The <see cref="SqlParameter"> to remove from the <c>SqlParamCollection.
'/// <exception cref="ArgumentException">
'/// The specified <see cref="SqlParameter"> was not found in the <c>SqlParamCollection.
'///
Public Overridable Sub Remove(ByVal item As SqlParameter)
Dim i As Integer = IndexOf(item)
If (i < 0) Then
Throw New System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.")
End If

m_version += 1
RemoveAt(i)
End Sub

'///
'/// Removes the element at the specified index of the <c>SqlParamCollection.
'///

'/// <param name="index" />The zero-based index of the element to remove.
'/// <exception cref="ArgumentOutOfRangeException">
'/// <para><paramref name="index"> is less than zero
'/// <para>-or-
'/// <para><paramref name="index"> is equal to or greater than <see cref="SqlParamCollection.Count">.
'///
Public Overridable Sub RemoveAt(ByVal index As Integer) Implements IList.RemoveAt

ValidateIndex(index) '// throws

m_count -= 1

If (index < m_count) Then
Array.Copy(m_array, index + 1, m_array, index, m_count - index)
End If

'// We can't set the deleted entry equal to null, because it might be a value type.
'// Instead, we'll create an empty single-element array of the right type and copy it
'// over the entry we want to erase.
Dim temp(0) As SqlParameter
temp(0) = New SqlParameter
Array.Copy(temp, 0, m_array, m_count, 1)
m_version += 1
End Sub

'///
'/// Gets a value indicating whether the collection has a fixed size.
'///

'/// <value>true if the collection has a fixed size otherwise, false. The default is false
Public Overridable ReadOnly Property IsFixedSize() As Boolean Implements IList.IsFixedSize
Get
Return False
End Get
End Property

'///
'/// gets a value indicating whether the IList is read-only.
'///

'/// <value>true if the collection is read-only otherwise, false. The default is false
Public Overridable ReadOnly Property IsReadOnly() As Boolean Implements IList.IsReadOnly
Get
Return False
End Get
End Property
#End Region


#Region "Operations (type-safe IEnumerable)"

'///
'/// Returns an enumerator that can iterate through the <c>SqlParamCollection.
'///

'/// <returns>An <see cref="Enumerator"> for the entire <c>SqlParamCollection.
Public Overridable Function GetEnumerator() As ISqlParamCollectionEnumerator
Return New Enumerator(Me)
End Function
#End Region


#Region "Public helpers (just to mimic some nice features of ArrayList)"

'///
'/// Gets or sets the number of elements the <c>SqlParamCollection can contain.
'///

Public Overridable Property Capacity() As Integer
Get
Return m_array.Length
End Get

Set(ByVal Value As Integer)
If (Value < m_count) Then Value = m_count

If Not (Value = m_array.Length) Then
If (Value > 0) Then
' C# implementation
'Dim temp() As SqlParameter = New SqlParameter(Value-1) {}
'Array.Copy(m_array, temp, m_count)
'm_array = temp
' VB implementation
ReDim Preserve m_array(Value)
Else
m_array = New SqlParameter(DEFAULT_CAPACITY) {}
End If
End If
End Set
End Property

'///
'/// Adds the elements of another <c>SqlParamCollection to the current <c>SqlParamCollection.
'///

'/// <param name="x" />The <c>SqlParamCollection whose elements should be added to the end of the current <c>SqlParamCollection.
'/// <returns>The new <see cref="SqlParamCollection.Count"> of the <c>SqlParamCollection.
Public Overridable Function AddRange(ByVal x As SqlParamCollection) As Integer

If (m_count + x.Count >= m_array.Length) Then EnsureCapacity(m_count + x.Count)

Array.Copy(x.m_array, 0, m_array, m_count, x.Count)
m_count += x.Count
m_version += 1

Return m_count
End Function

'///
'/// Adds the elements of a <see cref="SqlParameter"> array to the current <c>SqlParamCollection.
'///

'/// <param name="x" />The <see cref="SqlParameter"> array whose elements should be added to the end of the <c>SqlParamCollection.
'/// <returns>The new <see cref="SqlParamCollection.Count"> of the <c>SqlParamCollection.
Public Overridable Function AddRange(ByVal x() As SqlParameter) As Integer

If (m_count + x.Length >= m_array.Length) Then EnsureCapacity(m_count + x.Length)

Array.Copy(x, 0, m_array, m_count, x.Length)
m_count += x.Length
m_version += 1

Return m_count
End Function

'///
'/// Sets the capacity to the actual number of elements.
'///

Public Overridable Sub TrimToSize()
Me.Capacity = m_count
End Sub

#End Region

#Region "Implementation (helpers)"

'/// <exception cref="ArgumentOutOfRangeException">
'/// <para><paramref name="index"> is less than zero
'/// <para>-or-
'/// <para><paramref name="index"> is equal to or greater than <see cref="SqlParamCollection.Count">.
'///
Private Sub ValidateIndex(ByVal i As Integer)
ValidateIndex(i, False)
End Sub

'/// <exception cref="ArgumentOutOfRangeException">
'/// <para><paramref name="index"> is less than zero
'/// <para>-or-
'/// <para><paramref name="index"> is equal to or greater than <see cref="SqlParamCollection.Count">.
'///
Private Sub ValidateIndex(ByVal i As Integer, ByVal allowEqualEnd As Boolean)
Dim max As Integer

If allowEqualEnd Then
max = m_count
Else
max = m_count - 1
End If

If (i < 0 Or i > max) Then
Throw New System.ArgumentOutOfRangeException("Index was out of range. Must be non-negative and less than the size of the collection.", CType(1, Object), "Specified argument was out of the range of valid values.")
End If
End Sub

'/// <exception cref="ArgumentException">
'/// <para><paramref name="key"> was not found.
'///
Private Function FindItem(ByVal key As String) As Integer
Dim index As Integer

For index = 0 To m_array.Length - 1
If m_array(index).ParameterName = key Then
Return index
End If
Next

Throw New System.ArgumentException("The specified key was not found.")
End Function

Private Sub EnsureCapacity(ByVal min As Integer)

Dim newCapacity As Integer
If m_array.Length = 0 Then
newCapacity = DEFAULT_CAPACITY
Else
newCapacity = m_array.Length * 2
End If

If (newCapacity < min) Then newCapacity = min

Me.Capacity = newCapacity
End Sub

#End Region

#Region "Implementation (ICollection)"

Sub CopyTo(ByVal array As Array, ByVal start As Integer) Implements ICollection.CopyTo
Array.Copy(m_array, 0, array, start, m_count)
End Sub

#End Region

#Region "Implementation (IList)"
' Default removed
Property IList_Item(ByVal i As Integer) As Object Implements IList.Item
Get
Return CType(Me(i), Object)
End Get

Set(ByVal Value As Object)
Me(i) = CType(Value, SqlParameter)
End Set
End Property

Function Add(ByVal x As Object) As Integer Implements IList.Add
Return Me.Add(CType(x, SqlParameter))
End Function

Function Contains(ByVal x As Object) As Boolean Implements IList.Contains
Return Me.Contains(CType(x, SqlParameter))
End Function

Function IndexOf(ByVal x As Object) As Integer Implements IList.IndexOf
Return Me.IndexOf(CType(x, SqlParameter))
End Function

Sub Insert(ByVal pos As Integer, ByVal x As Object) Implements IList.Insert
Me.Insert(pos, CType(x, SqlParameter))
End Sub

Sub Remove(ByVal x As Object) Implements IList.Remove
Me.Remove(CType(x, SqlParameter))
End Sub

'Sub RemoveAt(ByVal pos As Integer) Implements IList.RemoveAt
' Me.RemoveAt(pos)
'End Sub

#End Region

#Region "Implementation (IEnumerable)"

Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Return CType(Me.GetEnumerator(), IEnumerator)
End Function

#End Region

#Region "Nested enumerator class"
'///
'/// Supports simple iteration over a <see cref="SqlParamCollection">.
'///

Private Class Enumerator
Implements IEnumerator, ISqlParamCollectionEnumerator

#Region "Implementation (data)"

Private m_collection As SqlParamCollection
Private m_index As Integer
Private m_version As Integer

#End Region

#Region "Construction"

'///
'/// Initializes a new instance of the <c>Enumerator class.
'///

'/// <param name="tc" />
Friend Sub New(ByVal tc As SqlParamCollection)
m_collection = tc
m_index = -1
m_version = tc.m_version
End Sub

#End Region

#Region "Operations (type-safe IEnumerator)"

'///
'/// Gets the current element in the collection.
'///

Public ReadOnly Property Current() As SqlParameter Implements ISqlParamCollectionEnumerator.Current
Get
Return m_collection(m_index)
End Get
End Property

'///
'/// Advances the enumerator to the next element in the collection.
'///

'/// <exception cref="InvalidOperationException">
'/// The collection was modified after the enumerator was created.
'///
'/// <returns>
'/// <c>true if the enumerator was successfully advanced to the next element
'/// <c>false if the enumerator has passed the end of the collection.
'///
Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext, ISqlParamCollectionEnumerator.MoveNext
If Not (m_version = m_collection.m_version) Then
Throw New System.InvalidOperationException("Collection was modified enumeration operation may not execute.")
End If

m_index += 1

If m_index < m_collection.Count Then
Return True
Else
Return False
End If
End Function

'///
'/// Sets the enumerator to its initial position, before the first element in the collection.
'///

Public Sub Reset() Implements IEnumerator.Reset, ISqlParamCollectionEnumerator.Reset
m_index = -1
End Sub
#End Region

#Region "Implementation (IEnumerator)"

ReadOnly Property IEnumerator_Current() As Object Implements IEnumerator.Current
Get
Return CType(Me.Current, Object)
End Get
End Property

#End Region
End Class
#End Region

#Region "Nested Syncronized Wrapper class"
Private Class SyncSqlParamCollection
Inherits SqlParamCollection

#Region "Implementation (data)"
Private m_collection As SqlParamCollection
Private m_root As Object
#End Region

#Region "Construction"
Friend Sub New(ByVal list As SqlParamCollection)
m_root = list.SyncRoot
m_collection = list
End Sub
#End Region

#Region "Type-safe ICollection"

Public Overloads Overrides Sub CopyTo(ByVal array() As SqlParameter)
SyncLock Me.m_root
m_collection.CopyTo(array)
End SyncLock
End Sub

Public Overloads Overrides Sub CopyTo(ByVal array() As SqlParameter, ByVal start As Integer)
SyncLock Me.m_root
m_collection.CopyTo(array, start)
End SyncLock
End Sub

Public Overrides ReadOnly Property Count() As Integer
Get
SyncLock Me.m_root
Return m_collection.Count
End SyncLock
End Get
End Property

Public Overrides ReadOnly Property IsSynchronized() As Boolean
Get
Return True
End Get
End Property

Public Overrides ReadOnly Property SyncRoot() As Object
Get
Return Me.m_root
End Get
End Property
#End Region

#Region "Type-safe IList"
Default Public Overloads Overrides Property Item(ByVal i As Integer) As SqlParameter
Get
SyncLock Me.m_root
Return m_collection(i)
End SyncLock
End Get
Set(ByVal Value As SqlParameter)
SyncLock Me.m_root
m_collection(i) = Value
End SyncLock
End Set
End Property

Public Overloads Overrides Function Add(ByVal x As SqlParameter) As Integer
SyncLock Me.m_root
Return m_collection.Add(x)
End SyncLock
End Function

Public Overrides Sub Clear()
SyncLock Me.m_root
m_collection.Clear()
End SyncLock
End Sub

Public Overloads Overrides Function Contains(ByVal x As SqlParameter) As Boolean
SyncLock Me.m_root
Return m_collection.Contains(x)
End SyncLock
End Function

Public Overloads Overrides Function IndexOf(ByVal x As SqlParameter) As Integer
SyncLock Me.m_root
Return m_collection.IndexOf(x)
End SyncLock
End Function

Public Overloads Overrides Sub Insert(ByVal pos As Integer, ByVal x As SqlParameter)
SyncLock Me.m_root
m_collection.Insert(pos, x)
End SyncLock
End Sub

Public Overloads Overrides Sub Remove(ByVal x As SqlParameter)
SyncLock Me.m_root
m_collection.Remove(x)
End SyncLock
End Sub

Public Overrides Sub RemoveAt(ByVal pos As Integer)
SyncLock Me.m_root
m_collection.RemoveAt(pos)
End SyncLock
End Sub

Public Overrides ReadOnly Property IsFixedSize() As Boolean
Get
Return m_collection.IsFixedSize
End Get
End Property

Public Overrides ReadOnly Property IsReadOnly() As Boolean
Get
Return m_collection.IsReadOnly
End Get
End Property
#End Region

#Region "Type-safe IEnumerable"
Public Overrides Function GetEnumerator() As ISqlParamCollectionEnumerator
SyncLock Me.m_root
Return m_collection.GetEnumerator()
End SyncLock
End Function
#End Region

#Region "Public Helpers"
'// (just to mimic some nice features of ArrayList)
Public Overrides Property Capacity() As Integer
Get
SyncLock Me.m_root
Return m_collection.Capacity
End SyncLock
End Get

Set(ByVal Value As Integer)
SyncLock Me.m_root
m_collection.Capacity = Value
End SyncLock
End Set
End Property

Public Overloads Overrides Function AddRange(ByVal x As SqlParamCollection) As Integer
SyncLock Me.m_root
Return m_collection.AddRange(x)
End SyncLock
End Function

Public Overloads Overrides Function AddRange(ByVal x() As SqlParameter) As Integer
SyncLock Me.m_root
Return m_collection.AddRange(x)
End SyncLock
End Function
#End Region
End Class
#End Region

#Region "Nested Read Only Wrapper class"
Private Class ReadOnlySqlParamCollection
Inherits SqlParamCollection

#Region "Implementation (data)"
Private m_collection As SqlParamCollection
#End Region

#Region "Construction"
Friend Sub New(ByVal list As SqlParamCollection)
m_collection = list
End Sub
#End Region

#Region "Type-safe ICollection"

Public Overloads Overrides Sub CopyTo(ByVal array() As SqlParameter)
m_collection.CopyTo(array)
End Sub

Public Overloads Overrides Sub CopyTo(ByVal array() As SqlParameter, ByVal start As Integer)
m_collection.CopyTo(array, start)
End Sub

Public Overrides ReadOnly Property Count() As Integer
Get
Return m_collection.Count
End Get
End Property

Public Overrides ReadOnly Property IsSynchronized() As Boolean
Get
Return m_collection.IsSynchronized
End Get
End Property

Public Overrides ReadOnly Property SyncRoot() As Object
Get
Return Me.m_collection.SyncRoot
End Get
End Property
#End Region

#Region "Type-safe IList"
Default Public Overloads Overrides Property Item(ByVal i As Integer) As SqlParameter
Get
Return m_collection(i)
End Get

Set(ByVal Value As SqlParameter)
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Set
End Property

Public Overloads Overrides Function Add(ByVal x As SqlParameter) As Integer
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Function

Public Overrides Sub Clear()
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Sub

Public Overloads Overrides Function Contains(ByVal x As SqlParameter) As Boolean
Return m_collection.Contains(x)
End Function

Public Overloads Overrides Function IndexOf(ByVal x As SqlParameter) As Integer
Return m_collection.IndexOf(x)
End Function

Public Overloads Overrides Sub Insert(ByVal pos As Integer, ByVal x As SqlParameter)
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Sub

Public Overloads Overrides Sub Remove(ByVal x As SqlParameter)
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Sub

Public Overrides Sub RemoveAt(ByVal pos As Integer)
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Sub

Public Overrides ReadOnly Property IsFixedSize() As Boolean
Get
Return True
End Get
End Property

Public Overrides ReadOnly Property IsReadOnly() As Boolean
Get
Return True
End Get
End Property
#End Region

#Region "Type-safe IEnumerable"
Public Overrides Function GetEnumerator() As ISqlParamCollectionEnumerator
Return m_collection.GetEnumerator()
End Function
#End Region

#Region "Public Helpers"
'// (just to mimic some nice features of ArrayList)
Public Overrides Property Capacity() As Integer
Get
Return m_collection.Capacity
End Get

Set(ByVal Value As Integer)
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Set
End Property

Public Overloads Overrides Function AddRange(ByVal x As SqlParamCollection) As Integer
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Function

Public Overloads Overrides Function AddRange(ByVal x() As SqlParameter) As Integer
Throw New NotSupportedException("This is a Read Only Collection and can not be modified")
End Function
#End Region
End Class
#End Region

End Class



Ravi

AnswerRe: Require Generic Custom Collection code in C#.Net Pin
Dave Doknjas16-Mar-07 12:51
Dave Doknjas16-Mar-07 12:51 
QuestionProfile Pin
shapper15-Mar-07 13:53
shapper15-Mar-07 13:53 
QuestionSessionID keep changing its value Pin
vietpointer15-Mar-07 13:42
vietpointer15-Mar-07 13:42 
AnswerRe: SessionID keep changing its value Pin
Venkatesh Mookkan15-Mar-07 16:17
Venkatesh Mookkan15-Mar-07 16:17 
QuestionBlogs. Pin
deepaks315-Mar-07 11:22
deepaks315-Mar-07 11:22 
QuestionActive directory and aspx/asp Pin
henlow198415-Mar-07 9:56
henlow198415-Mar-07 9:56 
AnswerRe: Active directory and aspx/asp Pin
Venkatesh Mookkan15-Mar-07 16:22
Venkatesh Mookkan15-Mar-07 16:22 
QuestionWeb Method In a User Control Pin
Sam Heller15-Mar-07 6:48
Sam Heller15-Mar-07 6:48 
AnswerRe: Web Method In a User Control Pin
Marcus J. Smith15-Mar-07 9:51
professionalMarcus J. Smith15-Mar-07 9:51 
GeneralRe: Web Method In a User Control Pin
Sam Heller15-Mar-07 12:56
Sam Heller15-Mar-07 12:56 
GeneralRe: Web Method In a User Control Pin
harshini21510-Dec-09 7:56
harshini21510-Dec-09 7:56 
Questionhow can install dotnetnuke without IIS ? Pin
B.A15-Mar-07 6:17
B.A15-Mar-07 6:17 
QuestionLanguage Preference Pin
Rahithi15-Mar-07 5:58
Rahithi15-Mar-07 5:58 
AnswerRe: Language Preference Pin
enjoycrack15-Mar-07 6:09
enjoycrack15-Mar-07 6:09 
QuestionClient side validation using database values Pin
snir_ya15-Mar-07 5:58
snir_ya15-Mar-07 5:58 
AnswerRe: Client side validation using database values Pin
enjoycrack15-Mar-07 6:02
enjoycrack15-Mar-07 6:02 
QuestionRe: Client side validation using database values Pin
snir_ya15-Mar-07 6:06
snir_ya15-Mar-07 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.