Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<Compile Include="..\..\src\Microsoft\Data\Common\ActivityCorrelator.cs">
<Link>Microsoft\Data\Common\ActivityCorrelator.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionStringCommon.cs">
<Link>Microsoft\Data\Common\DbConnectionStringCommon.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionPoolKey.cs">
<Link>Microsoft\Data\Common\DbConnectionPoolKey.cs</Link>
</Compile>
Expand Down Expand Up @@ -434,7 +437,6 @@
<Compile Include="$(CommonPath)\Microsoft\Data\Common\DbConnectionOptions.Common.cs">
<Link>Microsoft\Data\Common\DbConnectionOptions.Common.cs</Link>
</Compile>
<Compile Include="Microsoft\Data\Common\DbConnectionStringCommon.cs" />
<Compile Include="$(CommonPath)\Microsoft\Data\ProviderBase\DbConnectionInternal.cs">
<Link>Common\Microsoft\Data\ProviderBase\DbConnectionInternal.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
<Compile Include="..\..\src\Microsoft\Data\Common\ActivityCorrelator.cs">
<Link>Microsoft\Data\Common\ActivityCorrelator.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionStringCommon.cs">
<Link>Microsoft\Data\Common\DbConnectionStringCommon.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionPoolKey.cs">
<Link>Microsoft\Data\Common\DbConnectionPoolKey.cs</Link>
</Compile>
Expand Down Expand Up @@ -513,7 +516,7 @@
<Compile Include="Microsoft\Data\Common\AdapterSwitches.cs" />
<Compile Include="Microsoft\Data\Common\AdapterUtil.cs" />
<Compile Include="Microsoft\Data\Common\DbConnectionOptions.cs" />
<Compile Include="Microsoft\Data\Common\DbConnectionStringCommon.cs" />
<Compile Include="Microsoft\Data\Common\DbConnectionOptionKeywords.cs" />
<Compile Include="Microsoft\Data\Common\DbConnectionString.cs" />
<Compile Include="Microsoft\Data\Common\UnsafeNativeMethods.cs" />
<Compile Include="Microsoft\Data\Common\SafeNativeMethods.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Microsoft.Data.Common
{
[Serializable()]
internal sealed class ReadOnlyCollection<T> : System.Collections.ICollection, ICollection<T>
{
private T[] _items;

internal ReadOnlyCollection(T[] items)
{
_items = items;
#if DEBUG
for (int i = 0; i < items.Length; ++i)
{
Debug.Assert(null != items[i], "null item");
}
#endif
}

public void CopyTo(T[] array, int arrayIndex)
{
Array.Copy(_items, 0, array, arrayIndex, _items.Length);
}

void System.Collections.ICollection.CopyTo(Array array, int arrayIndex)
{
Array.Copy(_items, 0, array, arrayIndex, _items.Length);
}


IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator<T>(_items);
}

public System.Collections.IEnumerator GetEnumerator()
{
return new Enumerator<T>(_items);
}

bool System.Collections.ICollection.IsSynchronized
{
get { return false; }
}

Object System.Collections.ICollection.SyncRoot
{
get { return _items; }
}

bool ICollection<T>.IsReadOnly
{
get { return true; }
}

void ICollection<T>.Add(T value)
{
throw new NotSupportedException();
}

void ICollection<T>.Clear()
{
throw new NotSupportedException();
}

bool ICollection<T>.Contains(T value)
{
return Array.IndexOf(_items, value) >= 0;
}

bool ICollection<T>.Remove(T value)
{
throw new NotSupportedException();
}

public int Count
{
get { return _items.Length; }
}

[Serializable()]
internal struct Enumerator<K> : IEnumerator<K>, System.Collections.IEnumerator
{ // based on List<T>.Enumerator
private K[] _items;
private int _index;

internal Enumerator(K[] items)
{
_items = items;
_index = -1;
}

public void Dispose()
{
}

public bool MoveNext()
{
return (++_index < _items.Length);
}

public K Current
{
get
{
return _items[_index];
}
}

Object System.Collections.IEnumerator.Current
{
get
{
return _items[_index];
}
}

void System.Collections.IEnumerator.Reset()
{
_index = -1;
}
}
}

internal static class DbConnectionOptionKeywords
{
// Odbc
internal const string Driver = "driver";
internal const string Pwd = "pwd";
internal const string UID = "uid";

// OleDb
internal const string DataProvider = "data provider";
internal const string ExtendedProperties = "extended properties";
internal const string FileName = "file name";
internal const string Provider = "provider";
internal const string RemoteProvider = "remote provider";

// common keywords (OleDb, OracleClient, SqlClient)
internal const string Password = "password";
internal const string UserID = "user id";
}
}
Loading