/// <summary> /// Searches filtered local assemblies and plugin assemblies for the Plugin type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="typeFinder"></param> /// <returns></returns> private IEnumerable <Type> FindTypesInRequiredAssemblies <T>(TypeFinder typeFinder) { var types = new List <Type>(); //register the built in types types.AddRange(typeFinder.FindClassesOfType <T>(_localAssemblies)); //register any types defined in plugins types.AddRange(typeFinder.FindClassesOfType <T, AssemblyContainsPluginsAttribute>(_pluginAssemblies)); return(types); }
public IContainer BuildContainer() { lock (_locker) { if (_configured) return _container; var builder = new ContainerBuilder(); //type finder var typeFinder = new TypeFinder(); builder.Register(c => typeFinder); //find IDependencyRegistar implementations var drTypes = typeFinder.FindClassesOfType<IDependencyRegistar>(); foreach (var t in drTypes) { dynamic dependencyRegistar = Activator.CreateInstance(t); dependencyRegistar.Register(builder, typeFinder); } //event OnContainerBuilding(new ContainerBuilderEventArgs(builder)); _container = builder.Build(); //event OnContainerBuildingComplete(new ContainerBuilderEventArgs(builder)); _configured = true; return _container; } }
public IContainer BuildContainer() { lock (_locker) { if (_configured) { return(_container); } var builder = new ContainerBuilder(); //type finder var typeFinder = new TypeFinder(); builder.Register(c => typeFinder); //find IDependencyRegistar implementations var drTypes = typeFinder.FindClassesOfType <IDependencyRegistar>(); foreach (var t in drTypes) { dynamic dependencyRegistar = Activator.CreateInstance(t); dependencyRegistar.Register(builder, typeFinder); } //event OnContainerBuilding(new ContainerBuilderEventArgs(builder)); _container = builder.Build(); //event OnContainerBuildingComplete(new ContainerBuilderEventArgs(builder)); _configured = true; return(_container); } }
internal static void EnsureInitialized() { if (cache == null) { lock (locker) { if (cache == null) { var location = IOHelper.MapPath(TypeCache); if (!File.Exists(location)) { var types = TypeFinder.FindClassesOfType <DocumentTypeBase>(); cache = new Dictionary <Type, string>(); StoreCache(location, types.ToDictionary(t => t, CreateHash)); } else { var readTypes = ReadTypesFromCache(location); cache = readTypes; } } } } }
public void Benchmark_New_Finder() { using (DisposableTimer.TraceDuration <TypeFinderTests>("Starting test", "Finished test")) { using (DisposableTimer.TraceDuration <TypeFinderTests>("Starting FindClassesOfType", "Finished FindClassesOfType")) { for (var i = 0; i < 1000; i++) { Assert.Greater(TypeFinder.FindClassesOfType <DisposableObject>(_assemblies).Count(), 0); } } using (DisposableTimer.TraceDuration <TypeFinderTests>("Starting FindClassesOfTypeWithAttribute", "Finished FindClassesOfTypeWithAttribute")) { for (var i = 0; i < 1000; i++) { Assert.Greater(TypeFinder.FindClassesOfTypeWithAttribute <TestEditor, MyTestAttribute>(_assemblies).Count(), 0); } } using (DisposableTimer.TraceDuration <TypeFinderTests>("Starting FindClassesWithAttribute", "Finished FindClassesWithAttribute")) { for (var i = 0; i < 1000; i++) { Assert.Greater(TypeFinder.FindClassesWithAttribute <XsltExtensionAttribute>(_assemblies).Count(), 0); } } } }
private static void Initialize() { var types = TypeFinder.FindClassesOfType <IMediaFactory>(); foreach (var t in types) { IMediaFactory typeInstance = null; try { if (t.IsVisible) { typeInstance = Activator.CreateInstance(t) as IMediaFactory; } } catch { } if (typeInstance != null) { try { Factories.Add(typeInstance); } catch (Exception ee) { Log.Add(LogTypes.Error, -1, "Can't import MediaFactory '" + t.FullName + "': " + ee); } } } Factories.Sort((f1, f2) => f1.Priority.CompareTo(f2.Priority)); }
/// <summary> /// Stores all IActions that have been loaded into memory into a list /// </summary> private static void RegisterIActions() { if (_actions.Count == 0) { List <Type> foundIActions = TypeFinder.FindClassesOfType <IAction>(true); foreach (Type type in foundIActions) { IAction typeInstance; PropertyInfo instance = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static); //if the singletone initializer is not found, try simply creating an instance of the IAction if it supports public constructors if (instance == null) { typeInstance = Activator.CreateInstance(type) as IAction; } else { typeInstance = instance.GetValue(null, null) as IAction; } if (typeInstance != null) { if (!string.IsNullOrEmpty(typeInstance.JsSource)) { _actionJSReference.Add(typeInstance.JsSource); } _actions.Add(typeInstance); } } } }
public static void AddBaseReposity(this IServiceCollection services, IConfiguration configuration) { //找到所有的DBcontext var typeFinder = new TypeFinder(); var dbContextTypes = typeFinder.FindClassesOfType <DbContext>(); var contextTypes = dbContextTypes as Type[] ?? dbContextTypes.ToArray(); if (!contextTypes.Any()) { throw new Exception("没有找到任何数据库访问上下文"); } foreach (var dbContextType in contextTypes) { //注入每个实体仓库 var entities = from property in dbContextType.GetProperties(BindingFlags.Public | BindingFlags.Instance) where (ReflectionHelper.IsAssignableToGenericType(property.PropertyType, typeof(DbSet <>)) || ReflectionHelper.IsAssignableToGenericType(property.PropertyType, typeof(DbQuery <>))) && ReflectionHelper.IsAssignableToGenericType(property.PropertyType.GenericTypeArguments[0], typeof(IEntity <>)) select new EntityTypeInfo(property.PropertyType.GenericTypeArguments[0], property.DeclaringType); foreach (var entity in entities) { var primaryKeyType = GetPrimaryKeyType(entity.EntityType); var protype = typeof(IRepository <>).MakeGenericType(entity.EntityType); var eFprotype = typeof(EfCoreRepositoryBase <,>).MakeGenericType(entity.DeclaringType, entity.EntityType); var protypekey = typeof(IRepository <,>).MakeGenericType(entity.EntityType, primaryKeyType); var eFprotypekey = typeof(EfCoreRepositoryBase <, ,>).MakeGenericType(entity.DeclaringType, entity.EntityType, primaryKeyType); services.AddTransient(protype, eFprotype); services.AddTransient(protypekey, eFprotypekey); } } services.BuildServiceProvider(); }
/// <summary> /// Stores all references to classes that are of type IApplication /// </summary> public static void RegisterIApplications() { if (GlobalSettings.Configured) { List <Type> types = TypeFinder.FindClassesOfType <IApplication>(); foreach (Type t in types) { try { IApplication typeInstance = Activator.CreateInstance(t) as IApplication; if (typeInstance != null) { _applications.Add(typeInstance); if (HttpContext.Current != null) { HttpContext.Current.Trace.Write("registerIapplications", " + Adding application '" + typeInstance.Alias); } } } catch (Exception ee) { Log.Add(LogTypes.Error, -1, "Error loading IApplication: " + ee.ToString()); } } } }
private static void Initialize() { // Get all datatypes from interface List <Type> types = TypeFinder.FindClassesOfType <IDataType>(); getDataTypes(types); }
protected override void FreezeResolution() { var assembly = Assembly.Load("Our.Umbraco.Nexu.Parsers"); var propertyParsers = TypeFinder.FindClassesOfType <IPropertyParser>(new List <Assembly> { assembly }).ToList(); var gridEditorParsers = TypeFinder.FindClassesOfType <IGridEditorParser>(new List <Assembly> { assembly }).ToList(); // set up property parser resolver PropertyParserResolver.Current = new PropertyParserResolver( new ActivatorServiceProvider(), this.Logger, propertyParsers); // setup grid editor parser resolver GridEditorParserResolver.Current = new GridEditorParserResolver( new ActivatorServiceProvider(), this.Logger, gridEditorParsers); base.FreezeResolution(); }
public AddOnInfo GetAddOns() { var addOnInfo = new AddOnInfo(); var addOns = TypeFinder.FindClassesOfType <ISyncAddOn>(); foreach (var addOn in addOns) { var instance = Activator.CreateInstance(addOn) as ISyncAddOn; if (instance != null) { addOnInfo.AddOns.Add(instance); } } addOnInfo.Version = typeof(uSync8.BackOffice.uSync8BackOffice).Assembly.GetName().Version.ToString() + uSyncBackOfficeConstants.ReleaseSuffix; addOnInfo.AddOns = addOnInfo.AddOns.OrderBy(x => x.SortOrder).ToList(); addOnInfo.AddOnString = string.Join(", ", addOnInfo.AddOns .Where(x => !string.IsNullOrWhiteSpace(x.Name) && x.Name[0] != '_') .Select(x => $"{x.Name} (v{x.Version})")); return(addOnInfo); }
public IActionResult Index(string id) { var typeInfo = TypeFinder .FindClassesOfType <ISettings>() .FirstOrDefault(t => t.Guid == id); if (typeInfo == null) { return(Content("404")); } var setting = _settingService.LoadSetting(typeInfo.Type); var model = new IndexSettingRespModel { Guid = id, Title = typeInfo.DisplayName, TypeName = typeInfo.Name, PropertiesItems = typeInfo.Type.GetProperties().Select(t => new SettingPropertiesItem { DisplayName = GetPropertyDisplayName(t), Name = t.Name, Value = t.GetValue(setting)?.ToString(), PropertType = GetPropertType(t) }).ToList() }; return(View("~/Administration/Views/Setting/Index.cshtml", model)); }
/// <summary> /// Gets all available package actions. /// </summary> /// <returns></returns> public static IEnumerable <PackageActionModel> GetAll() { var foundValueParsers = TypeFinder.FindClassesOfType <IPackageAction>(); return(foundValueParsers.Select(type => Activator.CreateInstance(type) as IPackageAction).Select(a => new PackageActionModel { Alias = a.Alias(), SampleXMl = a.GetSampleOrDefault() }).OrderBy(p => p.Alias).ToList()); }
public void Benchmark_Finding_First_Type_In_Assemblies() { var timer = new Stopwatch(); var assemblies = new[] { //both contain the type this.GetType().Assembly, typeof(MandatoryPropertyEditor).Assembly, //these dont contain the type typeof(StandardAnalyzer).Assembly, typeof(NSubstitute.Substitute).Assembly, typeof(Remotion.Linq.DefaultQueryProvider).Assembly, typeof(NHibernate.IdentityEqualityComparer).Assembly, typeof(System.Guid).Assembly, typeof(NUnit.Framework.Assert).Assembly, typeof(Microsoft.CSharp.CSharpCodeProvider).Assembly, typeof(System.Xml.NameTable).Assembly, typeof(System.Configuration.GenericEnumConverter).Assembly, typeof(System.Web.SiteMap).Assembly, typeof(System.Data.SQLite.CollationSequence).Assembly, typeof(System.Web.Mvc.ActionResult).Assembly, typeof(Umbraco.Hive.LazyRelation <>).Assembly, typeof(Umbraco.Framework.DependencyManagement.AbstractContainerBuilder).Assembly, typeof(FixedIndexedFields).Assembly, typeof(Umbraco.Framework.Persistence.DefaultAttributeTypeRegistry).Assembly, typeof(Umbraco.Framework.Security.FixedPermissionTypes).Assembly }; //we'll use PropertyEditors for this tests since there are some int he text Extensions project var finder = new TypeFinder(); timer.Start(); var found1 = finder.FindClassesOfType <PropertyEditor, AssemblyContainsPluginsAttribute>(assemblies); timer.Stop(); Console.WriteLine("Total time to find propery editors (" + found1.Count() + ") in " + assemblies.Count() + " assemblies using AssemblyContainsPluginsAttribute: " + timer.ElapsedMilliseconds); timer.Start(); var found2 = finder.FindClassesOfType <PropertyEditor>(assemblies); timer.Stop(); Console.WriteLine("Total time to find propery editors (" + found2.Count() + ") in " + assemblies.Count() + " assemblies without AssemblyContainsPluginsAttribute: " + timer.ElapsedMilliseconds); }
public void Find_Classes_Of_Type() { var typesFound = TypeFinder.FindClassesOfType <IApplicationStartupHandler>(_assemblies); var originalTypesFound = TypeFinderOriginal.FindClassesOfType <IApplicationStartupHandler>(_assemblies); Assert.AreEqual(originalTypesFound.Count(), typesFound.Count()); Assert.AreEqual(6, typesFound.Count()); Assert.AreEqual(6, originalTypesFound.Count()); }
public ShittyIoC() { var deliverables = TypeFinder.FindClassesOfType <Deliverable>(); foreach (var deliverable in deliverables) { RegisterDeliverable(deliverable); } }
public void Ensure_All_Tasks_Are_Secured() { var allTasks = TypeFinder.FindClassesOfType <ITask>(); foreach (var t in allTasks) { Assert.IsTrue(TypeHelper.IsTypeAssignableFrom <LegacyDialogTask>(t), "The type " + t + " is not of type " + typeof(LegacyDialogTask)); } }
private void ConfigAutofac() { var builder = new ContainerBuilder(); var typeFinder = new TypeFinder(); var assemblies = typeFinder.GetAssemblies().ToArray(); // OPTIONAL: Register model binders that require DI. builder.RegisterModelBinders(assemblies); builder.RegisterModelBinderProvider(); builder.RegisterAssemblyTypes(assemblies); // OPTIONAL: Register web abstractions like HttpContextBase. builder.RegisterModule <AutofacWebTypesModule>(); // OPTIONAL: Enable property injection in view pages. builder.RegisterSource(new ViewRegistrationSource()); // OPTIONAL: Enable property injection into action filters. builder.RegisterFilterProvider(); // Register your MVC controllers. builder.RegisterControllers(assemblies).EnableClassInterceptors(); //Register All Other Services //dependencies builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); //register dependencies provided by other assemblies var drTypes = typeFinder.FindClassesOfType <IDependencyRegistrar>(); var drInstances = new List <IDependencyRegistrar>(); foreach (var drType in drTypes) { //Ignore not installed plugins var plugin = PluginManager.FindPluginByType(drType); if (plugin != null && !plugin.Installed) { continue; } drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType)); } //sort drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList(); foreach (var dependencyRegistrar in drInstances) { dependencyRegistrar.Register(builder, typeFinder); } var container = builder.Build(); // Set the dependency resolver to be Autofac. DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }
public List <SelectItem> GetDataSource() { var fileUploaders = TypeFinder.FindClassesOfType <IFileUploader>(); return(fileUploaders.Select(it => new SelectItem { Name = it.DisplayName, Value = it.UniqueId }).ToList()); }
private void ProcessApplicationMigrations(ApplicationContext applicationContext) { var umbracoApps = TypeFinder.FindClassesOfType <IUmbracoApp>(); foreach (var application in umbracoApps) { var appInstance = Activator.CreateInstance(application) as IUmbracoApp; ApplyMigration(applicationContext, appInstance.Name, appInstance.Version); } }
public void Benchmark_Finding_First_Type_In_Assemblies() { var timer = new Stopwatch(); var assemblies = new[] { //both contain the type this.GetType().Assembly, typeof (MandatoryPropertyEditor).Assembly, //these dont contain the type typeof(NSubstitute.Substitute).Assembly, typeof(Remotion.Linq.DefaultQueryProvider).Assembly, typeof(NHibernate.IdentityEqualityComparer).Assembly, typeof(System.Guid).Assembly, typeof(NUnit.Framework.Assert).Assembly, typeof(Microsoft.CSharp.CSharpCodeProvider).Assembly, typeof(System.Xml.NameTable).Assembly, typeof(System.Configuration.GenericEnumConverter).Assembly, typeof(System.Web.SiteMap).Assembly, typeof(System.Data.SQLite.CollationSequence).Assembly, typeof(System.Web.Mvc.ActionResult).Assembly, typeof(Umbraco.Hive.LazyRelation<>).Assembly, typeof(Umbraco.Framework.DependencyManagement.AbstractContainerBuilder).Assembly, typeof(Umbraco.Framework.Persistence.DefaultAttributeTypeRegistry).Assembly, typeof(Umbraco.Framework.Security.FixedPermissionTypes).Assembly }; //we'll use PropertyEditors for this tests since there are some int he text Extensions project var finder = new TypeFinder(); timer.Start(); var found1 = finder.FindClassesOfType<PropertyEditor, AssemblyContainsPluginsAttribute>(assemblies); timer.Stop(); Console.WriteLine("Total time to find propery editors (" + found1.Count() + ") in " + assemblies.Count() + " assemblies using AssemblyContainsPluginsAttribute: " + timer.ElapsedMilliseconds); timer.Start(); var found2 = finder.FindClassesOfType<PropertyEditor>(assemblies); timer.Stop(); Console.WriteLine("Total time to find propery editors (" + found2.Count() + ") in " + assemblies.Count() + " assemblies without AssemblyContainsPluginsAttribute: " + timer.ElapsedMilliseconds); }
public IEnumerable <string> Initialize() { return ((from migration in TypeFinder.FindClassesOfType <MigrationBase>() from migrationAttribute in migration.GetCustomAttributes <MigrationAttribute>() select migrationAttribute.ProductName) .Where(s => !s.Equals("Umbraco", StringComparison.InvariantCultureIgnoreCase)) .Distinct() .OrderBy(s => s)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { var typesToRegister = TypeFinder.FindClassesOfType(typeof(IEntityMapConfig)); foreach (var type in typesToRegister) { var mapConfig = (IEntityMapConfig)Activator.CreateInstance(type); mapConfig.Map(modelBuilder); } base.OnModelCreating(modelBuilder); }
/// <summary> /// Register all controllers found in the specified assemblies /// </summary> /// <param name="containerBuilder"></param> /// <param name="assemblies"></param> /// <param name="typeFinder"></param> /// <returns></returns> public static IContainerBuilder RegisterControllers(this IContainerBuilder containerBuilder, IEnumerable<Assembly> assemblies, TypeFinder typeFinder) { //TODO: Include extenders! foreach (var type in typeFinder.FindClassesOfType<IController>(assemblies) .Where(t => t.Name.EndsWith("Controller"))) { containerBuilder.For(type).KnownAsSelf(); } return containerBuilder; }
/// <summary> /// Register all controllers found in the specified assemblies /// </summary> /// <param name="containerBuilder"></param> /// <param name="assemblies"></param> /// <param name="typeFinder"></param> /// <returns></returns> public static IContainerBuilder RegisterControllers(this IContainerBuilder containerBuilder, IEnumerable <Assembly> assemblies, TypeFinder typeFinder) { //TODO: Include extenders! foreach (var type in typeFinder.FindClassesOfType <IController>(assemblies) .Where(t => t.Name.EndsWith("Controller"))) { containerBuilder.For(type).KnownAsSelf(); } return(containerBuilder); }
private static void Initialize() { List <Type> types = TypeFinder.FindClassesOfType <ICacheRefresher>(); foreach (Type t in types) { ICacheRefresher typeInstance = Activator.CreateInstance(t) as ICacheRefresher; if (typeInstance != null) { _refreshers.Add(typeInstance.UniqueIdentifier, t); } } }
public IController CreateController(RequestContext requestContext, string controllerName) { var tf = new TypeFinder(); var types = tf.FindClassesOfType<ControllerBase>(new[] { Assembly.GetExecutingAssembly() }); var controllerTypes = types.Where(x => x.Name.Equals(controllerName + "Controller", StringComparison.InvariantCultureIgnoreCase)); var t = controllerTypes.SingleOrDefault(); if (t == null) return null; return Activator.CreateInstance(t) as IController; }
private void LoadInstalledPageTypesByReflection() { var inherentPageTypes = TypeFinder.FindClassesOfType <IModelBase>(true, true); foreach (var inherentPageType in inherentPageTypes) { var typeName = inherentPageType.Name; if (!_pageTypeMap.ContainsKey(typeName)) { _pageTypeMap.Add(typeName, inherentPageType); } } }
/// <summary> /// Finds all instances of ITree in loaded assemblies, then finds their associated ApplicationTree and Application objects /// and stores them together in a TreeDefinition class and adds the definition to our list. /// This will also store an instance of each tree object in the TreeDefinition class which should be /// used when referencing all tree classes. /// </summary> private void RegisterTrees() { if (this.Count > 0) { return; } List <Type> foundITrees = TypeFinder.FindClassesOfType <ITree>(); ApplicationTree[] objTrees = ApplicationTree.getAll(); List <ApplicationTree> appTrees = new List <ApplicationTree>(); appTrees.AddRange(objTrees); List <Application> apps = Application.getAll(); foreach (Type type in foundITrees) { //find the Application tree's who's combination of assembly name and tree type is equal to //the Type that was found's full name. //Since a tree can exist in multiple applications we'll need to register them all. List <ApplicationTree> appTreesForType = appTrees.FindAll( delegate(ApplicationTree tree) { return(string.Format("{0}.{1}", tree.AssemblyName, tree.Type) == type.FullName); } ); if (appTreesForType != null) { foreach (ApplicationTree appTree in appTreesForType) { //find the Application object whos name is the same as our appTree ApplicationAlias Application app = apps.Find( delegate(Application a) { return(a.alias == appTree.ApplicationAlias); } ); TreeDefinition def = new TreeDefinition(type, appTree, app); this.Add(def); } } } //sort our trees with the sort order definition this.Sort(delegate(TreeDefinition t1, TreeDefinition t2) { return(t1.Tree.SortOrder.CompareTo(t2.Tree.SortOrder)); }); }
private DataTypeDefinitionSynchronizer() { _installedDataTypeDefinitions = DataTypeDefinition.GetAll(); _synchronizableDataTypeTypes = TypeFinder.FindClassesOfType <ISynchronizableDataType>(); _synchronizableDataTypes = new List <ISynchronizableDataType>(); foreach (var instance in _synchronizableDataTypeTypes.Select(Activator.CreateInstance).OfType <ISynchronizableDataType>()) { _synchronizableDataTypes.Add(instance); } _idToTypeMappings = new Dictionary <int, ISynchronizableDataType>(); _typeToIdMappings = new Dictionary <ISynchronizableDataType, int>(); LoadInstalledDataTypes(); }
/// <summary> /// create an instance per each Startup class that implements IAppStartup and then call ConfigureServices /// </summary> /// <param name="services"></param> /// <param name="configuration"></param> /// <param name="typeFinder"></param> protected virtual void ConfigureStartupServices(IServiceCollection services) { var startupConfigurations = TypeFinder.FindClassesOfType <IAppStartup>(); //create and sort instances of startup configurations var instances = startupConfigurations .Select(startup => (IAppStartup)Activator.CreateInstance(startup)) .OrderBy(startup => startup.Order); //configure services foreach (var instance in instances) { instance.ConfigureServices(services, this, Configuration); } }
private static void RegisterPropertyType() { var types = TypeFinder.FindClassesOfType <IPropertyType>(true); foreach (var t in types) { var typeInstance = Activator.CreateInstance(t) as IPropertyType; if (typeInstance != null) { PropertyTypesList.Add(typeInstance.Id, typeInstance); PropertyTypes.Add(typeInstance.Id, typeInstance.Name); } } }
public IController CreateController(RequestContext requestContext, string controllerName) { var types = TypeFinder.FindClassesOfType <ControllerBase>(new[] { Assembly.GetExecutingAssembly() }); var controllerTypes = types.Where(x => x.Name.Equals(controllerName + "Controller", StringComparison.InvariantCultureIgnoreCase)); var t = controllerTypes.SingleOrDefault(); if (t == null) { return(null); } return(Activator.CreateInstance(t) as IController); }
/// <summary> /// Register all model binders found in the specified Assemblies which are registered to types based /// on the ModelBinderForAttribute. /// </summary> /// <param name="containerBuilder"></param> /// <param name="assemblies"></param> /// <param name="typeFinder"></param> /// <returns></returns> public static IContainerBuilder RegisterModelBinders(this IContainerBuilder containerBuilder, IEnumerable<Assembly> assemblies, TypeFinder typeFinder) { foreach (var type in typeFinder.FindClassesOfType<IModelBinder>(assemblies)) { var register = containerBuilder.For(type) .KnownAs<IModelBinder>(); foreach (ModelBinderForAttribute item in type.GetCustomAttributes(typeof(ModelBinderForAttribute), true)) { register.WithMetadata<ModelBinderMetadata, Type>(prop => prop.BinderType, item.TargetType); ModelBinders.Binders.Add(item.TargetType, new ModelBinderAdapter(item.TargetType)); } } return containerBuilder; }