Skip to content

Commit

Permalink
upgrade .NET Core 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jacking75 committed Sep 24, 2019
1 parent ed70df5 commit 18974e7
Show file tree
Hide file tree
Showing 42 changed files with 952 additions and 137 deletions.
108 changes: 54 additions & 54 deletions Common/ConfigurationExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,59 +231,59 @@ public static Configuration GetCurrentConfiguration(this ConfigurationElement co
return (Configuration)configProperty.GetValue(configElement, null);
}

#if !NETSTANDARD2_0
private static void ResetConfigurationForMono(AppDomain appDomain, string configFilePath)
{
appDomain.SetupInformation.ConfigurationFile = configFilePath;

var configSystem = typeof(ConfigurationManager)
.GetField("configSystem", BindingFlags.Static | BindingFlags.NonPublic)
.GetValue(null);

// clear previous state
typeof(ConfigurationManager)
.Assembly.GetTypes()
.Where(x => x.FullName == "System.Configuration.ClientConfigurationSystem")
.First()
.GetField("cfg", BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(configSystem, null);
}

private static void ResetConfigurationForDotNet(AppDomain appDomain, string configFilePath)
{
appDomain.SetData("APP_CONFIG_FILE", configFilePath);

// clear previous state
BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Static;

typeof(ConfigurationManager)
.GetField("s_initState", flags)
.SetValue(null, 0);

typeof(ConfigurationManager)
.GetField("s_configSystem", flags)
.SetValue(null, null);

typeof(ConfigurationManager)
.Assembly.GetTypes()
.Where(x => x.FullName == "System.Configuration.ClientConfigPaths")
.First()
.GetField("s_current", flags)
.SetValue(null, null);
}

/// <summary>
/// Reset application's configuration to a another config file
/// </summary>
/// <param name="appDomain">the assosiated AppDomain</param>
/// <param name="configFilePath">the config file path want to reset to</param>
public static void ResetConfiguration(this AppDomain appDomain, string configFilePath)
{
if (Platform.IsMono)
ResetConfigurationForMono(appDomain, configFilePath);
else
ResetConfigurationForDotNet(appDomain, configFilePath);
}
#endif
//#if !NETSTANDARD2_0
//private static void ResetConfigurationForMono(AppDomain appDomain, string configFilePath)
//{
// appDomain.SetupInformation.ConfigurationFile = configFilePath;

// var configSystem = typeof(ConfigurationManager)
// .GetField("configSystem", BindingFlags.Static | BindingFlags.NonPublic)
// .GetValue(null);

// // clear previous state
// typeof(ConfigurationManager)
// .Assembly.GetTypes()
// .Where(x => x.FullName == "System.Configuration.ClientConfigurationSystem")
// .First()
// .GetField("cfg", BindingFlags.Instance | BindingFlags.NonPublic)
// .SetValue(configSystem, null);
//}

//private static void ResetConfigurationForDotNet(AppDomain appDomain, string configFilePath)
//{
// appDomain.SetData("APP_CONFIG_FILE", configFilePath);

// // clear previous state
// BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Static;

// typeof(ConfigurationManager)
// .GetField("s_initState", flags)
// .SetValue(null, 0);

// typeof(ConfigurationManager)
// .GetField("s_configSystem", flags)
// .SetValue(null, null);

// typeof(ConfigurationManager)
// .Assembly.GetTypes()
// .Where(x => x.FullName == "System.Configuration.ClientConfigPaths")
// .First()
// .GetField("s_current", flags)
// .SetValue(null, null);
//}

///// <summary>
///// Reset application's configuration to a another config file
///// </summary>
///// <param name="appDomain">the assosiated AppDomain</param>
///// <param name="configFilePath">the config file path want to reset to</param>
//public static void ResetConfiguration(this AppDomain appDomain, string configFilePath)
//{
// if (Platform.IsMono)
// ResetConfigurationForMono(appDomain, configFilePath);
// else
// ResetConfigurationForDotNet(appDomain, configFilePath);
//}
//#endif
}
}
5 changes: 3 additions & 2 deletions Common/SuperSocket.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.0.1</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions Samples/00_superSocketLite_libs/netstandard2.1/RevDeBug.setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Repository.Port=42742;
Repository.Address=127.0.0.1;
Application.Name=SuperSocket.SocketEngine;
SolutionName=SuperSocket.SocketEngine;
StateStorageClassName=LiveRecorder;
AuthorizationToken=;
Release=;
BacklogSize=1000;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 18974e7

Please sign in to comment.