Skip to content

Instantly share code, notes, and snippets.

@d2funlife
d2funlife / ConfigValue
Last active July 25, 2021 14:58
Свой источник конфигурации Entity Framework
public class ConfigValue
{
public string Key { get; set; }
public string Value { get; set; }
}
@d2funlife
d2funlife / ControllerActionInvoker.cs
Created September 20, 2017 19:26
ControllerActionInvoker
namespace System.Web.Mvc
{
[SuppressMessage(
"Microsoft.Maintainability",
"CA1506:AvoidExcessiveClassCoupling",
Justification = "This class has to work with both traditional and direct routing, which is the cause of the high" +
"number of classes it uses.")]
public class ControllerActionInvoker : IActionInvoker
{
private static readonly ControllerDescriptorCache _staticDescriptorCache = new ControllerDescriptorCache();
@d2funlife
d2funlife / DefaultControllerActivator.cs
Created September 20, 2017 19:23
DefaultControllerActivator
private class DefaultControllerActivator : IControllerActivator
{
private Func<IDependencyResolver> _resolverThunk;
public DefaultControllerActivator()
: this(null)
{
}
public DefaultControllerActivator(IDependencyResolver resolver)
@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()
@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 / 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 / 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 / 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 / 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 / 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;