Initial commit.
This commit is contained in:
commit
3dfd79a26d
|
|
@ -0,0 +1,50 @@
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
||||||
|
|
||||||
|
*.jpg binary
|
||||||
|
*.png binary
|
||||||
|
*.gif binary
|
||||||
|
|
||||||
|
*.cs text=auto diff=csharp
|
||||||
|
*.vb text=auto
|
||||||
|
*.resx text=auto
|
||||||
|
*.c text=auto
|
||||||
|
*.cpp text=auto
|
||||||
|
*.cxx text=auto
|
||||||
|
*.h text=auto
|
||||||
|
*.hxx text=auto
|
||||||
|
*.py text=auto
|
||||||
|
*.rb text=auto
|
||||||
|
*.java text=auto
|
||||||
|
*.html text=auto
|
||||||
|
*.htm text=auto
|
||||||
|
*.css text=auto
|
||||||
|
*.scss text=auto
|
||||||
|
*.sass text=auto
|
||||||
|
*.less text=auto
|
||||||
|
*.js text=auto
|
||||||
|
*.lisp text=auto
|
||||||
|
*.clj text=auto
|
||||||
|
*.sql text=auto
|
||||||
|
*.php text=auto
|
||||||
|
*.lua text=auto
|
||||||
|
*.m text=auto
|
||||||
|
*.asm text=auto
|
||||||
|
*.erl text=auto
|
||||||
|
*.fs text=auto
|
||||||
|
*.fsx text=auto
|
||||||
|
*.hs text=auto
|
||||||
|
|
||||||
|
*.csproj text=auto
|
||||||
|
*.vbproj text=auto
|
||||||
|
*.fsproj text=auto
|
||||||
|
*.dbproj text=auto
|
||||||
|
*.sln text=auto eol=crlf
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
*.xap
|
||||||
|
*.user
|
||||||
|
/TestResults
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.docstates
|
||||||
|
_ReSharper.*
|
||||||
|
*.csproj.user
|
||||||
|
*[Rr]e[Ss]harper.user
|
||||||
|
_ReSharper.*/
|
||||||
|
packages/*
|
||||||
|
artifacts/*
|
||||||
|
msbuild.log
|
||||||
|
PublishProfiles/
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*DS_Store
|
||||||
|
*.ncrunchsolution
|
||||||
|
*.log
|
||||||
|
*.vspx
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.CoreServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper code for the various activator services.
|
||||||
|
/// </summary>
|
||||||
|
public static class ActivatorUtilities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object GetServiceOrCreateInstance(IServiceProvider services, Type type)
|
||||||
|
{
|
||||||
|
return GetServiceNoExceptions(services, type) ?? CreateInstance(services, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "IServiceProvider may throw unknown exceptions")]
|
||||||
|
private static object GetServiceNoExceptions(IServiceProvider services, Type type)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return services.GetService(type);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiate an object of the given type, using constructor service injection if possible.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object CreateInstance(IServiceProvider services, Type type)
|
||||||
|
{
|
||||||
|
return CreateFactory(type).Invoke(services);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a factory to instantiate a type using constructor service injection if possible.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Func<IServiceProvider, object> CreateFactory(Type type)
|
||||||
|
{
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("type");
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstructorInfo[] constructors = type
|
||||||
|
.GetConstructors()
|
||||||
|
.Where(IsInjectable)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (constructors.Length == 1)
|
||||||
|
{
|
||||||
|
ParameterInfo[] parameters = constructors[0].GetParameters();
|
||||||
|
return services =>
|
||||||
|
{
|
||||||
|
var args = new object[parameters.Length];
|
||||||
|
for (int index = 0; index != parameters.Length; ++index)
|
||||||
|
{
|
||||||
|
args[index] = services.GetService(parameters[index].ParameterType);
|
||||||
|
}
|
||||||
|
return Activator.CreateInstance(type, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return _ => Activator.CreateInstance(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsInjectable(ConstructorInfo constructor)
|
||||||
|
{
|
||||||
|
return constructor.IsPublic && constructor.GetParameters().Length != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Microsoft.AspNet.CoreServices</RootNamespace>
|
||||||
|
<AssemblyName>Microsoft.AspNet.CoreServices</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ActivatorUtilities.cs" />
|
||||||
|
<Compile Include="ServiceProvider.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ServiceProviderExtensions.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
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.
|
||||||
|
[assembly: AssemblyTitle("Microsoft.AspNet.CoreServices")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Microsoft.AspNet.CoreServices")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("96e86a39-7c32-4257-af76-d12e449dc25a")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.CoreServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default IServiceProvider.
|
||||||
|
/// </summary>
|
||||||
|
public class ServiceProvider : IServiceProvider
|
||||||
|
{
|
||||||
|
private readonly IDictionary<Type, Func<object>> _services = new Dictionary<Type, Func<object>>();
|
||||||
|
private readonly IDictionary<Type, List<Func<object>>> _priorServices = new Dictionary<Type, List<Func<object>>>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ServiceProvider()
|
||||||
|
{
|
||||||
|
_services[typeof(IServiceProvider)] = () => this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the service object of the specified type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual object GetService(Type serviceType)
|
||||||
|
{
|
||||||
|
return GetSingleService(serviceType) ?? GetMultiService(serviceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object GetSingleService(Type serviceType)
|
||||||
|
{
|
||||||
|
Func<object> serviceFactory;
|
||||||
|
return _services.TryGetValue(serviceType, out serviceFactory)
|
||||||
|
? serviceFactory.Invoke()
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private object GetMultiService(Type collectionType)
|
||||||
|
{
|
||||||
|
if (collectionType.IsGenericType &&
|
||||||
|
collectionType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
|
||||||
|
{
|
||||||
|
Type serviceType = collectionType.GetGenericArguments().Single();
|
||||||
|
Type listType = typeof(List<>).MakeGenericType(serviceType);
|
||||||
|
var services = (IList)Activator.CreateInstance(listType);
|
||||||
|
|
||||||
|
Func<object> serviceFactory;
|
||||||
|
if (_services.TryGetValue(serviceType, out serviceFactory))
|
||||||
|
{
|
||||||
|
services.Add(serviceFactory());
|
||||||
|
|
||||||
|
List<Func<object>> prior;
|
||||||
|
if (_priorServices.TryGetValue(serviceType, out prior))
|
||||||
|
{
|
||||||
|
foreach (var factory in prior)
|
||||||
|
{
|
||||||
|
services.Add(factory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all occurrences of the given type from the provider.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider RemoveAll<T>()
|
||||||
|
{
|
||||||
|
return RemoveAll(typeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all occurrences of the given type from the provider.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider RemoveAll(Type type)
|
||||||
|
{
|
||||||
|
_services.Remove(type);
|
||||||
|
_priorServices.Remove(type);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an instance of type TService to the list of providers.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TService"></typeparam>
|
||||||
|
/// <param name="instance"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider AddInstance<TService>(object instance)
|
||||||
|
{
|
||||||
|
return AddInstance(typeof(TService), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an instance of the given type to the list of providers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="service"></param>
|
||||||
|
/// <param name="instance"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider AddInstance(Type service, object instance)
|
||||||
|
{
|
||||||
|
return Add(service, () => instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specify that services of the type TService should be fulfilled by the type TImplementation.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TService"></typeparam>
|
||||||
|
/// <typeparam name="TImplementation"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider Add<TService, TImplementation>()
|
||||||
|
{
|
||||||
|
return Add(typeof(TService), typeof(TImplementation));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specify that services of the type serviceType should be fulfilled by the type implementationType.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceType"></param>
|
||||||
|
/// <param name="implementationType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider Add(Type serviceType, Type implementationType)
|
||||||
|
{
|
||||||
|
Func<IServiceProvider, object> factory = ActivatorUtilities.CreateFactory(implementationType);
|
||||||
|
return Add(serviceType, () => factory(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specify that services of the given type should be created with the given serviceFactory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceType"></param>
|
||||||
|
/// <param name="serviceFactory"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ServiceProvider Add(Type serviceType, Func<object> serviceFactory)
|
||||||
|
{
|
||||||
|
Func<object> existing;
|
||||||
|
if (_services.TryGetValue(serviceType, out existing))
|
||||||
|
{
|
||||||
|
List<Func<object>> prior;
|
||||||
|
if (_priorServices.TryGetValue(serviceType, out prior))
|
||||||
|
{
|
||||||
|
prior.Add(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prior = new List<Func<object>> { existing };
|
||||||
|
_priorServices.Add(serviceType, prior);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_services[serviceType] = serviceFactory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.CoreServices
|
||||||
|
{
|
||||||
|
public static class ServiceProviderExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a service of type T from the IServiceProvider.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T GetService<T>(this IServiceProvider services)
|
||||||
|
{
|
||||||
|
if (services == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("services");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T)services.GetService(typeof(T));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.21005.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc", "Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj", "{2A0C26F1-0240-4AE1-AE00-4691C291B122}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcSample", "MvcSample\MvcSample.csproj", "{069EA0A1-BB68-41D1-A973-3429EC09264C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.CoreServices", "Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj", "{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{2A0C26F1-0240-4AE1-AE00-4691C291B122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2A0C26F1-0240-4AE1-AE00-4691C291B122}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2A0C26F1-0240-4AE1-AE00-4691C291B122}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2A0C26F1-0240-4AE1-AE00-4691C291B122}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{069EA0A1-BB68-41D1-A973-3429EC09264C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{069EA0A1-BB68-41D1-A973-3429EC09264C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{069EA0A1-BB68-41D1-A973-3429EC09264C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{069EA0A1-BB68-41D1-A973-3429EC09264C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EC38534C-A2D1-413F-97D1-55EEF5D2FB71}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class Controller
|
||||||
|
{
|
||||||
|
public void Initialize(IOwinContext context)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOwinContext Context { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class ControllerActionInvoker : IActionInvoker
|
||||||
|
{
|
||||||
|
private ControllerContext _context;
|
||||||
|
|
||||||
|
public ControllerActionInvoker(ControllerContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task InvokeActionAsync(string actionName)
|
||||||
|
{
|
||||||
|
var method = _context.Controller.GetType().GetMethod(actionName);
|
||||||
|
|
||||||
|
if (method == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(String.Format("Could not find action method '{0}'", actionName));
|
||||||
|
}
|
||||||
|
|
||||||
|
method.Invoke(_context.Controller, null);
|
||||||
|
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class ControllerActionInvokerFactory : IActionInvokerFactory
|
||||||
|
{
|
||||||
|
public IActionInvoker CreateInvoker(ControllerContext context)
|
||||||
|
{
|
||||||
|
return new ControllerActionInvoker(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class ControllerContext
|
||||||
|
{
|
||||||
|
public ControllerContext(IOwinContext context, object controller)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("context");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controller == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("controller");
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpContext = context;
|
||||||
|
Controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object Controller { get; set; }
|
||||||
|
|
||||||
|
public virtual IOwinContext HttpContext { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.AspNet.CoreServices;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class DefaultControllerFactory : IControllerFactory
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
public DefaultControllerFactory(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object CreateController(IOwinContext context, string controllerName)
|
||||||
|
{
|
||||||
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
var type = a.GetType(controllerName) ??
|
||||||
|
a.GetType(a.GetName().Name + "." + controllerName) ??
|
||||||
|
a.GetTypes().FirstOrDefault(t => t.Name.Equals(controllerName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
return ActivatorUtilities.CreateInstance(_serviceProvider, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseController(object controller)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public interface IActionInvoker
|
||||||
|
{
|
||||||
|
Task InvokeActionAsync(string actionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public interface IActionInvokerFactory
|
||||||
|
{
|
||||||
|
IActionInvoker CreateInvoker(ControllerContext context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public interface IController
|
||||||
|
{
|
||||||
|
Task Execute(IOwinContext context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public interface IControllerFactory
|
||||||
|
{
|
||||||
|
object CreateController(IOwinContext context, string controllerName);
|
||||||
|
|
||||||
|
void ReleaseController(object controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{2A0C26F1-0240-4AE1-AE00-4691C291B122}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Microsoft.AspNet.Mvc</RootNamespace>
|
||||||
|
<AssemblyName>Microsoft.AspNet.Mvc</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Owin">
|
||||||
|
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Owin">
|
||||||
|
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Controller.cs" />
|
||||||
|
<Compile Include="ControllerActionInvoker.cs" />
|
||||||
|
<Compile Include="ControllerActionInvokerFactory.cs" />
|
||||||
|
<Compile Include="ControllerContext.cs" />
|
||||||
|
<Compile Include="DefaultControllerFactory.cs" />
|
||||||
|
<Compile Include="IActionInvoker.cs" />
|
||||||
|
<Compile Include="IActionInvokerFactory.cs" />
|
||||||
|
<Compile Include="IController.cs" />
|
||||||
|
<Compile Include="IControllerFactory.cs" />
|
||||||
|
<Compile Include="MvcHandler.cs" />
|
||||||
|
<Compile Include="MvcServices.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Microsoft.AspNet.CoreServices\Microsoft.AspNet.CoreServices.csproj">
|
||||||
|
<Project>{ec38534c-a2d1-413f-97d1-55eef5d2fb71}</Project>
|
||||||
|
<Name>Microsoft.AspNet.CoreServices</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.CoreServices;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public class MvcHandler
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
public MvcHandler()
|
||||||
|
: this(null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MvcHandler(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
_serviceProvider = serviceProvider ?? MvcServices.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task ExecuteAsync(IOwinContext context)
|
||||||
|
{
|
||||||
|
string[] parts = (context.Request.PathBase + context.Request.Path).Value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
// {controller}/{action}
|
||||||
|
string controllerName = GetPartOrDefault(parts, 0, "HomeController");
|
||||||
|
string actionName = GetPartOrDefault(parts, 1, "Index");
|
||||||
|
|
||||||
|
var factory = _serviceProvider.GetService<IControllerFactory>();
|
||||||
|
object controller = factory.CreateController(context, controllerName);
|
||||||
|
|
||||||
|
if (controller == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(String.Format("Couldn't find controller '{0}'.", controllerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
var controllerBase = controller as Controller;
|
||||||
|
|
||||||
|
if (controllerBase != null)
|
||||||
|
{
|
||||||
|
// TODO: Make this the controller context
|
||||||
|
controllerBase.Initialize(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
var controllerContext = new ControllerContext(context, controller);
|
||||||
|
|
||||||
|
IActionInvokerFactory invokerFactory = _serviceProvider.GetService<IActionInvokerFactory>();
|
||||||
|
var invoker = invokerFactory.CreateInvoker(controllerContext);
|
||||||
|
|
||||||
|
return invoker.InvokeActionAsync(actionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPartOrDefault(string[] parts, int index, string defaultValue)
|
||||||
|
{
|
||||||
|
return index < parts.Length ? parts[index] : defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.AspNet.CoreServices;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public static class MvcServices
|
||||||
|
{
|
||||||
|
public static IServiceProvider Create()
|
||||||
|
{
|
||||||
|
var services = new ServiceProvider();
|
||||||
|
DoCallback((service, implementation) => services.Add(service, implementation));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DoCallback(Action<Type, Type> callback)
|
||||||
|
{
|
||||||
|
callback(typeof(IControllerFactory), typeof(DefaultControllerFactory));
|
||||||
|
callback(typeof(IActionInvokerFactory), typeof(ControllerActionInvokerFactory));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
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.
|
||||||
|
[assembly: AssemblyTitle("Microsoft.AspNet.Mvc")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Microsoft.AspNet.Mvc")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("8d29eb97-6f81-4304-86b1-adc94ffcff7d")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net45" />
|
||||||
|
<package id="Owin" version="1.0" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Microsoft.AspNet.Mvc;
|
||||||
|
|
||||||
|
namespace MvcSample
|
||||||
|
{
|
||||||
|
public class HomeController
|
||||||
|
{
|
||||||
|
public string Index()
|
||||||
|
{
|
||||||
|
return "Hello World";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>
|
||||||
|
</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{069EA0A1-BB68-41D1-A973-3429EC09264C}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>MvcSample</RootNamespace>
|
||||||
|
<AssemblyName>MvcSample</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<UseIISExpress>true</UseIISExpress>
|
||||||
|
<IISExpressSSLPort />
|
||||||
|
<IISExpressAnonymousAuthentication />
|
||||||
|
<IISExpressWindowsAuthentication />
|
||||||
|
<IISExpressUseClassicPipelineMode />
|
||||||
|
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Owin.Diagnostics">
|
||||||
|
<HintPath>..\packages\Microsoft.Owin.Diagnostics.2.0.2\lib\net40\Microsoft.Owin.Diagnostics.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Owin">
|
||||||
|
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="packages.config" />
|
||||||
|
<None Include="Web.Debug.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<None Include="Web.Release.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Web.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="HomeController.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Startup.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Microsoft.AspNet.Mvc\Microsoft.AspNet.Mvc.csproj">
|
||||||
|
<Project>{2a0c26f1-0240-4ae1-ae00-4691c291b122}</Project>
|
||||||
|
<Name>Microsoft.AspNet.Mvc</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||||
|
<WebProjectProperties>
|
||||||
|
<UseIIS>False</UseIIS>
|
||||||
|
<AutoAssignPort>True</AutoAssignPort>
|
||||||
|
<DevelopmentServerPort>48140</DevelopmentServerPort>
|
||||||
|
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||||
|
<IISUrl>http://localhost:48140/</IISUrl>
|
||||||
|
<NTLMAuthentication>False</NTLMAuthentication>
|
||||||
|
<UseCustomServer>True</UseCustomServer>
|
||||||
|
<CustomServerUrl>
|
||||||
|
</CustomServerUrl>
|
||||||
|
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||||
|
<servers defaultServer="OwinHost">
|
||||||
|
<server name="OwinHost" exePath="{solutiondir}\packages\OwinHost.2.0.2\tools\OwinHost.exe" cmdArgs="-u {url}" url="http://localhost:12345/" workingDir="{projectdir}" />
|
||||||
|
</servers>
|
||||||
|
</WebProjectProperties>
|
||||||
|
</FlavorProperties>
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
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.
|
||||||
|
[assembly: AssemblyTitle("MvcSample")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("MvcSample")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("d5a71550-dac9-4925-ad7c-f0fd3ccf5dab")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.Mvc;
|
||||||
|
using Microsoft.Owin;
|
||||||
|
using Owin;
|
||||||
|
|
||||||
|
[assembly: OwinStartup(typeof(MvcSample.Startup))]
|
||||||
|
|
||||||
|
namespace MvcSample
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public void Configuration(IAppBuilder app)
|
||||||
|
{
|
||||||
|
var handler = new MvcHandler();
|
||||||
|
|
||||||
|
// Pretending to be routing
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
await handler.ExecuteAsync(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
In the example below, the "SetAttributes" transform will change the value of
|
||||||
|
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||||
|
finds an attribute "name" that has a value of "MyDB".
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<!--
|
||||||
|
In the example below, the "Replace" transform will replace the entire
|
||||||
|
<customErrors> section of your web.config file.
|
||||||
|
Note that because there is only one customErrors section under the
|
||||||
|
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
In the example below, the "SetAttributes" transform will change the value of
|
||||||
|
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||||
|
finds an attribute "name" that has a value of "MyDB".
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||||
|
<!--
|
||||||
|
In the example below, the "Replace" transform will replace the entire
|
||||||
|
<customErrors> section of your web.config file.
|
||||||
|
Note that because there is only one customErrors section under the
|
||||||
|
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
For more information on how to configure your ASP.NET application, please visit
|
||||||
|
http://go.microsoft.com/fwlink/?LinkId=169433
|
||||||
|
-->
|
||||||
|
<configuration>
|
||||||
|
<system.web>
|
||||||
|
<compilation debug="true" targetFramework="4.5" />
|
||||||
|
<httpRuntime targetFramework="4.5" />
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Owin.Diagnostics" version="2.0.2" targetFramework="net45" />
|
||||||
|
<package id="Owin" version="1.0" targetFramework="net45" />
|
||||||
|
<package id="OwinHost" version="2.0.2" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
Loading…
Reference in New Issue