Skip to content

Commit

Permalink
Merge pull request #1 from Jinhuafei/master
Browse files Browse the repository at this point in the history
1.0.0 version
  • Loading branch information
Jinhuafei authored Nov 30, 2016
2 parents 050db7a + 2a77778 commit e8037c6
Show file tree
Hide file tree
Showing 56 changed files with 5,922 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Oo]bj/
[Bb]in/
.vs/
msbuild.*
obj/
packages/
9 changes: 9 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
144 changes: 144 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup>
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
</PropertyGroup>

<PropertyGroup>
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
43 changes: 43 additions & 0 deletions Microsoft.Aspnet.SessionState.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{58E8143E-86D8-4CA3-AAC3-1CF253D91207}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{93AD624B-85A6-4EE9-B40E-42914D40C0CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync", "src\SqlSessionStateProviderAsync\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj", "{493B0482-572A-4465-BD52-4094351C2647}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SessionStateModule", "src\SessionStateModule\Microsoft.AspNet.SessionState.SessionStateModule.csproj", "{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test", "test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj", "{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{493B0482-572A-4465-BD52-4094351C2647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{493B0482-572A-4465-BD52-4094351C2647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{493B0482-572A-4465-BD52-4094351C2647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{493B0482-572A-4465-BD52-4094351C2647}.Release|Any CPU.Build.0 = Release|Any CPU
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Release|Any CPU.Build.0 = Release|Any CPU
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{493B0482-572A-4465-BD52-4094351C2647} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
EndGlobalSection
EndGlobal
62 changes: 62 additions & 0 deletions MicrosoftAspNetSessionState.msbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="tools\MicrosoftAspNetSessionState.settings.targets"/>

<ItemGroup>
<AssemblyProject Include="src\SessionStateModule\Microsoft.AspNet.SessionState.SessionStateModule.csproj" />
<AssemblyProject Include="src\SqlSessionStateProviderAsync\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(BuildCoreOnly)' != 'true'">
<AssemblyProject Include="test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj" />
</ItemGroup>
<ItemGroup>
<PackageProject Include="src\Packages\Packages.csproj" />
</ItemGroup>

<Target Name="Build" DependsOnTargets="BuildAssemblies;BuildPackages" />
<Target Name="Clean" DependsOnTargets="CleanPackages;CleanAssemblies" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

<Target Name="BuildAssemblies" DependsOnTargets="RestorePackages">
<MSBuild Targets="Build" Projects="@(AssemblyProject)" />
</Target>

<Target Name="CleanAssemblies">
<MSBuild Targets="Clean" Projects="Microsoft.Aspnet.SessionState.sln" />
</Target>

<Target Name="RebuildAssemblies" DependsOnTargets="Clean;Build" />

<!-- Packages build -->

<Target Name="BuildPackages" DependsOnTargets="RestorePackages">
<MSBuild Targets="" Projects="@(PackageProject)" />
</Target>

<Target Name="CleanPackages">
<MSBuild Targets="Clean" Projects="@(PackageProject)" />
</Target>

<Target Name="RebuildPackages" DependsOnTargets="CleanPackages;BuildPackages" />

<Target Name="RestorePackages">
<Exec Command=".nuget\NuGet.exe restore" />
</Target>

<!--
<Target Name="UnitTest">
<ItemGroup>
<TestDLLs Include="test\SystemWebProvidersUnitTest\bin\$(Configuration)\*Test.dll" />
</ItemGroup>

<PropertyGroup>
<TestSettingsFile Condition=" '$(Configuration)' == 'CodeCoverage' ">$(MsBuildProjectDirectory)\test\CodeCoverage.testsettings</TestSettingsFile>
<TestSettingsFile Condition=" '$(Configuration)' != 'CodeCoverage' ">$(MsBuildProjectDirectory)\unittest.testsettings</TestSettingsFile>
</PropertyGroup>

<Delete Files="bin\$(Configuration)-TestResults.trx" />
<Exec
Command="&quot;$(VS100COMNTOOLS)..\IDE\MSTEST.EXE&quot; /nologo /usestderr /resultsfile:&quot;bin\$(Configuration)-TestResults.trx&quot; @(TestDLLs -> '/testcontainer:&quot;%(Identity)&quot;', ' ') /testsettings:&quot;$(TestSettingsFile)&quot;" />
</Target>
-->
<Import Project="tools\MicrosoftAspNetSessionState.targets"/>
</Project>
26 changes: 26 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@ECHO OFF

setlocal

set logOptions=/flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err

set MSBUILDEXE=
if exist "%SystemDrive%\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (
set MSBUILDEXE="%SystemDrive%\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
GOTO BUILD
)

if exist "%SystemDrive%\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" (
set MSBUILDEXE="%SystemDrive%\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"
GOTO BUILD
)

if not defined MSBUILDEXE (
set MSBUILDEXE="C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
)

:BUILD
REM %MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" %logOptions% /v:d /maxcpucount /nodeReuse:false %*
%MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" %logOptions% /v:diag /maxcpucount /nodeReuse:false %*

endlocal
66 changes: 66 additions & 0 deletions src/SessionStateModule/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.AspNet.SessionState
{
using System.Collections.Specialized;
using System.Web.Configuration;

static class AppSettings
{
private static volatile bool _settingsInitialized;
private static object _lock = new object();

private static void LoadSettings(NameValueCollection appSettings)
{
//
// RequestQueueLimitPerSession
//
string requestQueueLimit = appSettings["aspnet:RequestQueueLimitPerSession"];

if (!int.TryParse(requestQueueLimit, out _requestQueueLimitPerSession) || _requestQueueLimitPerSession < 0)
{
_requestQueueLimitPerSession = DefaultRequestQueueLimitPerSession;
}
}

private static void EnsureSettingsLoaded()
{
if (_settingsInitialized)
{
return;
}

lock (_lock)
{
if (!_settingsInitialized)
{
try
{
LoadSettings(WebConfigurationManager.AppSettings);
}
finally
{
_settingsInitialized = true;
}
}
}
}

//
// RequestQueueLimitPerSession
// Limit of queued requests per session
//
public const int DefaultRequestQueueLimitPerSession = 50;
private static int _requestQueueLimitPerSession = DefaultRequestQueueLimitPerSession;

public static int RequestQueueLimitPerSession
{
get
{
EnsureSettingsLoaded();
return _requestQueueLimitPerSession;
}
}
}
}
Loading

0 comments on commit e8037c6

Please sign in to comment.