From c0d8ca8aedf312d71d2339c3c3b495538377e3b8 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 17 Oct 2014 16:08:52 -0700 Subject: [PATCH] Fix for #1366 - Remove Injector --- src/Microsoft.AspNet.Mvc.Core/Injector.cs | 72 ----------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/Microsoft.AspNet.Mvc.Core/Injector.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/Injector.cs b/src/Microsoft.AspNet.Mvc.Core/Injector.cs deleted file mode 100644 index 7a57907074..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/Injector.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Reflection; -using Microsoft.Framework.DependencyInjection; - -namespace Microsoft.AspNet.Mvc -{ - public static class Injector - { - public static void CallInitializer([NotNull] object obj, [NotNull] IServiceProvider services) - { - var type = obj.GetType(); - - var initializeMethod = - type.GetRuntimeMethods() - .FirstOrDefault(m => m.Name.Equals("Initialize", StringComparison.OrdinalIgnoreCase)); - - if (initializeMethod == null) - { - return; - } - - var args = - initializeMethod.GetParameters() - .Select(p => services.GetRequiredService(p.ParameterType)) - .ToArray(); - - initializeMethod.Invoke(obj, args); - } - - public static void InjectProperty( - [NotNull] object obj, - [NotNull] string propertyName, - TProperty value) - { - var type = obj.GetType(); - - var property = type.GetRuntimeProperty(propertyName); - if (property == null) - { - return; - } - - if (property.PropertyType.IsAssignableFrom(typeof(TProperty))) - { - property.SetValue(obj, value); - } - } - - public static void InjectProperty( - [NotNull] object obj, - [NotNull] string propertyName, - [NotNull] IServiceProvider services) - { - var type = obj.GetType(); - - var property = type.GetRuntimeProperty(propertyName); - if (property == null) - { - return; - } - - if (property.PropertyType.IsAssignableFrom(typeof(TProperty))) - { - property.SetValue(obj, services.GetRequiredService()); - } - } - } -}