Browse Source

Added embedded httpmodule declaration

Former-commit-id: d730995864bc1477022e61a44a257fcf715f1daf
af/merge-core
James South 12 years ago
parent
commit
e2d2c6834f
  1. 7
      src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
  2. 1
      src/ImageProcessor.Web/NET4/packages.config
  3. 7
      src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
  4. 31
      src/ImageProcessor.Web/NET45/Helpers/StartUp.cs
  5. 25
      src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
  6. 8
      src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
  7. 7
      src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs
  8. 4
      src/ImageProcessor.Web/NET45/packages.config
  9. 4
      src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj
  10. 25
      src/TestWebsites/NET45/Test_Website_NET45/Web.config
  11. 1
      src/packages/repositories.config

7
src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj

@ -51,6 +51,10 @@
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.165\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@ -86,6 +90,9 @@
<Link>ImageHelpers.cs</Link>
</Compile>
<Compile Include="..\NET45\Helpers\RemoteFile.cs" />
<Compile Include="..\NET45\Helpers\StartUp.cs">
<Link>StartUp.cs</Link>
</Compile>
<Compile Include="..\NET45\Helpers\TaskHelpers.cs" />
<Compile Include="..\NET45\HttpModules\ImageProcessingModule.cs" />
<Compile Include="..\NET45\ImageFactoryExtensions.cs" />

1
src/ImageProcessor.Web/NET4/packages.config

@ -3,4 +3,5 @@
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
</packages>

7
src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs

@ -13,12 +13,9 @@ namespace ImageProcessor.Web.Config
#region Using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Compilation;
using ImageProcessor.Processors;
#endregion
@ -300,7 +297,7 @@ namespace ImageProcessor.Web.Config
.SelectMany(s => s.GetTypes())
.Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
.ToList();
// Create them and add.
this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList();
@ -310,7 +307,7 @@ namespace ImageProcessor.Web.Config
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
}
catch (ReflectionTypeLoadException ex)
catch (ReflectionTypeLoadException)
{
this.LoadGraphicsProcessorsFromConfiguration();
}

31
src/ImageProcessor.Web/NET45/Helpers/StartUp.cs

@ -0,0 +1,31 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StartUp.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Provides methods to handle startup events.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
[assembly: System.Web.PreApplicationStartMethod(typeof(ImageProcessor.Web.Helpers.StartUp), "PreApplicationStart")]
namespace ImageProcessor.Web.Helpers
{
using ImageProcessor.Web.HttpModules;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
/// <summary>
/// Provides methods to handle startup events.
/// </summary>
public static class StartUp
{
/// <summary>
/// The pre application start.
/// </summary>
public static void PreApplicationStart()
{
DynamicModuleUtility.RegisterModule(typeof(ImageProcessingModule));
}
}
}

25
src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs

@ -31,6 +31,9 @@ namespace ImageProcessor.Web.HttpModules
using ImageProcessor.Web.Caching;
using ImageProcessor.Web.Config;
using ImageProcessor.Web.Helpers;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
#endregion
/// <summary>
@ -49,11 +52,6 @@ namespace ImageProcessor.Web.HttpModules
/// </summary>
private static readonly Regex PresetRegex = new Regex(@"preset=[^&]*", RegexOptions.Compiled);
/// <summary>
/// The value to prefix any remote image requests with to ensure they get captured.
/// </summary>
private static readonly string RemotePrefix = ImageProcessorConfig.Instance.RemotePrefix;
/// <summary>
/// The assembly version.
/// </summary>
@ -64,6 +62,11 @@ namespace ImageProcessor.Web.HttpModules
/// </summary>
private static readonly Dictionary<string, SemaphoreSlim> SemaphoreSlims = new Dictionary<string, SemaphoreSlim>();
/// <summary>
/// The value to prefix any remote image requests with to ensure they get captured.
/// </summary>
private static string remotePrefix;
/// <summary>
/// A value indicating whether this instance of the given entity has been disposed.
/// </summary>
@ -109,17 +112,17 @@ namespace ImageProcessor.Web.HttpModules
/// </param>
public void Init(HttpApplication context)
{
#if NET45
if (remotePrefix == null)
{
remotePrefix = ImageProcessorConfig.Instance.RemotePrefix;
}
#if NET45
EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);
#else
context.PostAuthorizeRequest += this.PostAuthorizeRequest;
#endif
context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
}
@ -264,7 +267,7 @@ namespace ImageProcessor.Web.HttpModules
HttpRequest request = context.Request;
// Fixes issue 10.
bool isRemote = request.Path.EndsWith(RemotePrefix, StringComparison.OrdinalIgnoreCase);
bool isRemote = request.Path.EndsWith(remotePrefix, StringComparison.OrdinalIgnoreCase);
string requestPath = string.Empty;
string queryString = string.Empty;

8
src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj

@ -32,6 +32,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@ -53,6 +57,7 @@
<Compile Include="Config\ImageProcessingSection.cs" />
<Compile Include="Config\ImageProcessorConfig.cs" />
<Compile Include="Config\ImageSecuritySection.cs" />
<Compile Include="Helpers\StartUp.cs" />
<Compile Include="Helpers\ImageHelpers.cs" />
<Compile Include="Helpers\RemoteFile.cs" />
<Compile Include="Helpers\TaskHelpers.cs" />
@ -66,6 +71,9 @@
<Name>ImageProcessor</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

7
src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs

@ -5,6 +5,10 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
using System.Web;
using ImageProcessor.Web.HttpModules;
[assembly: AssemblyTitle("ImageProcessor.Web")]
[assembly: AssemblyDescription("A library for on-the-fly processing of image files with ASP.NET written in C#")]
[assembly: AssemblyConfiguration("James South")]
@ -32,5 +36,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]

4
src/ImageProcessor.Web/NET45/packages.config

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
</packages>

4
src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj

@ -205,11 +205,11 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>56639</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:51117/</IISUrl>
<IISUrl>http://localhost:56639/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>

25
src/TestWebsites/NET45/Test_Website_NET45/Web.config

@ -6,24 +6,24 @@
<configuration>
<configSections>
<sectionGroup name="imageProcessor">
<!--<sectionGroup name="imageProcessor">
<section name="security" requirePermission="false" type="ImageProcessor.Web.Config.ImageSecuritySection, ImageProcessor.Web"/>
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Config.ImageProcessingSection, ImageProcessor.Web"/>
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Config.ImageCacheSection, ImageProcessor.Web"/>
</sectionGroup>
</sectionGroup>-->
</configSections>
<imageProcessor >
<!--<imageProcessor >
<security configSource="config\imageprocessor\security.config"/>
<cache configSource="config\imageprocessor\cache.config"/>
<processing configSource="config\imageprocessor\processing.config"/>
</imageProcessor>
</imageProcessor>-->
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
</appSettings>
<system.web>
@ -41,16 +41,9 @@
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpModules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
@ -60,8 +53,6 @@
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
</modules>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

1
src/packages/repositories.config

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\ImageProcessor.Web\NET4\packages.config" />
<repository path="..\ImageProcessor.Web\NET45\packages.config" />
<repository path="..\TestWebsites\NET4\packages.config" />
<repository path="..\TestWebsites\NET45\Test_Website_MVC5_NET45\packages.config" />
<repository path="..\TestWebsites\NET45\Test_Website_NET45\packages.config" />

Loading…
Cancel
Save