Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -391,6 +391,15 @@
<Compile Include="$(CommonSourceROot)Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs">
<Link>Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs">
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbInstanceElement.netfx.cs">
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbInstanceElement.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbInstancesCollection.netfx.cs">
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbInstancesCollection.netfx.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalAppContextSwitches.cs">
<Link>Microsoft\Data\SqlClient\LocalAppContextSwitches.cs</Link>
</Compile>
Expand Down Expand Up @@ -839,7 +848,6 @@
<Compile Include="Microsoft\Data\Common\DbConnectionString.cs" />
<Compile Include="Microsoft\Data\Common\GreenMethods.cs" />
<Compile Include="Microsoft\Data\SqlClient\assemblycache.cs" />
<Compile Include="Microsoft\Data\SqlClient\LocalDBConfig.cs" />
<Compile Include="Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.LoadType.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiConnection.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiContext.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<Reference Include="System.Configuration" Condition="'$(TargetFramework)' == 'net462'" />
<Reference Include="System.Configuration" Condition="'$(TargetFramework)' == 'net462'"/>
<Reference Include="System.Transactions" Condition="'$(TargetFramework)' == 'net462'" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using Interop.Windows.Kernel32;
using Interop.Windows.Sni;
using Microsoft.Data.SqlClient;
using Interop.Windows.Kernel32;

#if NETFRAMEWORK
using System.Collections.Generic;
using System.Configuration;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.Data.SqlClient.LocalDb;
#endif

namespace Microsoft.Data
Expand Down Expand Up @@ -182,13 +183,13 @@ internal static void CreateLocalDBInstance(string instance)
if (section != null) // if no section just skip creation
{
// validate section type
LocalDBConfigurationSection configSection = section as LocalDBConfigurationSection;
LocalDbConfigurationSection configSection = section as LocalDbConfigurationSection;
if (configSection == null)
{
throw CreateLocalDBException(errorMessage: StringsHelper.GetString("LocalDB_BadConfigSectionType"));
}
foreach (LocalDBInstanceElement confElement in configSection.LocalDbInstances)

foreach (LocalDbInstanceElement confElement in configSection.LocalDbInstances)
{
Debug.Assert(confElement.Name != null && confElement.Version != null, "Both name and version should not be null");
tempConfigurableInstances.Add(confElement.Name.Trim(), new InstanceInfo(confElement.Version.Trim()));
Expand All @@ -215,7 +216,7 @@ internal static void CreateLocalDBInstance(string instance)
if (!s_configurableInstances.TryGetValue(instance, out instanceInfo))
{
// instance name was not in the config
return;
return;
}

if (instanceInfo.created)
Expand Down Expand Up @@ -364,7 +365,7 @@ private static SqlException CreateLocalDBException(string errorMessage, string i

if (localDbError != 0)
{
collection.Add(new SqlError(errorCode, 0, TdsEnums.FATAL_ERROR_CLASS, instance, GetLocalDBMessage(localDbError), null, 0));
collection.Add(new SqlError(errorCode, 0, TdsEnums.FATAL_ERROR_CLASS, instance, GetLocalDBMessage(localDbError), null, 0));
}

SqlException exc = SqlException.CreateException(collection, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

#if NETFRAMEWORK

using System.Configuration;

namespace Microsoft.Data.SqlClient.LocalDb
{
internal sealed class LocalDbConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("localdbinstances", IsRequired = true)]
public LocalDbInstancesCollection LocalDbInstances =>
(LocalDbInstancesCollection)this["localdbinstances"] ?? new LocalDbInstancesCollection();
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

#if NETFRAMEWORK

using System.Configuration;

namespace Microsoft.Data.SqlClient.LocalDb
{
internal sealed class LocalDbInstanceElement : ConfigurationElement
{
[ConfigurationProperty("name", IsRequired = true)]
public string Name => this["name"] as string;

[ConfigurationProperty("version", IsRequired = true)]
public string Version => this["version"] as string;
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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.

#if NETFRAMEWORK

using System;
using System.Collections;
using System.Configuration;

namespace Microsoft.Data.SqlClient.LocalDb
{
internal sealed class LocalDbInstancesCollection : ConfigurationElementCollection
{
private static readonly TrimOrdinalIgnoreCaseStringComparer s_comparer = new TrimOrdinalIgnoreCaseStringComparer();

internal LocalDbInstancesCollection()
: base(s_comparer)
{
}

protected override ConfigurationElement CreateNewElement() =>
new LocalDbInstanceElement();

protected override object GetElementKey(ConfigurationElement element) =>
((LocalDbInstanceElement)element).Name;

private class TrimOrdinalIgnoreCaseStringComparer : IComparer
{
public int Compare(object x, object y)
{
if (x is string xStr)
{
x = xStr.Trim();
}

if (y is string yStr)
{
y = yStr.Trim();
}

return StringComparer.OrdinalIgnoreCase.Compare(x, y);
}
}
}
}

#endif
Loading