Skip to content

Instantly share code, notes, and snippets.

@d2funlife
d2funlife / Global.asax.cs
Created September 12, 2017 20:08
HTTP приложение точки интеграции / HTTP application integration points
[assembly: PreApplicationStartMethod(typeof(MvcApplication), "PreStartApp")]
namespace Sample
{
public class MvcApplication : System.Web.HttpApplication
{
public static void PreStartApp()
{
//code
}
protected void Application_Start()
@d2funlife
d2funlife / MvcRouteHandler.cs
Created September 16, 2017 19:10
MvcRouteHandler
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Web.Mvc.Properties;
using System.Web.Routing;
using System.Web.SessionState;
namespace System.Web.Mvc
{
public class MvcRouteHandler : IRouteHandler
{
@d2funlife
d2funlife / MvcHandler.cs
Created September 16, 2017 19:12
MvcHandler
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Web.Mvc.Async;
using System.Web.Mvc.Properties;
using System.Web.Routing;
@d2funlife
d2funlife / DefaultControllerFactory.cs
Created September 16, 2017 19:29
DefaultControllerFactory
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
@d2funlife
d2funlife / DefaultDependencyResolver.cs
Created September 19, 2017 19:08
DefaultDependencyResolver
private class DefaultDependencyResolver : IDependencyResolver
{
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This method might throexceptions whose type we cannot strongly link against; namely, ActivationException from common service locator")]
public object GetService(Type serviceType)
{
// Since attempting to create an instance of an interface or an abstract type results in an exception, immediatelreturn null
// to improve performance and the debugging experience with first-chance exceptions enabled.
if (serviceType.IsInterface || serviceType.IsAbstract)
{
return null;
@d2funlife
d2funlife / DependencyResolver.cs
Created September 19, 2017 19:16
DependencyResolver
namespace System.Web.Mvc
{
public class DependencyResolver
{
private static DependencyResolver _instance = new DependencyResolver();
private IDependencyResolver _current;
/// <summary>
/// Cache should always be a new CacheDependencyResolver(_current).
@d2funlife
d2funlife / ControllerBase.cs
Created September 19, 2017 19:31
ControllerBase
namespace System.Web.Mvc
{
public abstract class ControllerBase : IController
{
private readonly SingleEntryGate _executeWasCalledGate = new SingleEntryGate();
private DynamicViewDataDictionary _dynamicViewDataDictionary;
private TempDataDictionary _tempDataDictionary;
private bool _validateRequest = true;
private IValueProvider _valueProvider;
@d2funlife
d2funlife / Controller.cs
Created September 19, 2017 19:33
Controller
namespace System.Web.Mvc
{
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Class complexity dictated by public surface area")]
public abstract class Controller : ControllerBase, IActionFilter, IAuthenticationFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter, IAsyncController, IAsyncManagerContainer
{
private static readonly object _executeTag = new object();
private static readonly object _executeCoreTag = new object();
private readonly AsyncManager _asyncManager = new AsyncManager();
private IActionInvoker _actionInvoker;
@d2funlife
d2funlife / ViewResult.cs
Created September 20, 2017 05:19
ViewResult
namespace System.Web.Mvc
{
public class ViewResult : ViewResultBase
{
private string _masterName;
public string MasterName
{
get { return _masterName ?? String.Empty; }
set { _masterName = value; }
@d2funlife
d2funlife / ControllerBuilder.cs
Created September 20, 2017 19:21
ControllerBuilder
namespace System.Web.Mvc
{
public class ControllerBuilder
{
private static ControllerBuilder _instance = new ControllerBuilder();
private Func<IControllerFactory> _factoryThunk = () => null;
private HashSet<string> _namespaces = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private IResolver<IControllerFactory> _serviceResolver;
public ControllerBuilder()