ModelBinding\ModelBinderFactory.cs (16)
20/// A factory for <see cref="IModelBinder"/> instances.
26private readonly ConcurrentDictionary<Key, IModelBinder> _cache;
43_cache = new ConcurrentDictionary<Key, IModelBinder>();
51public IModelBinder CreateBinder(ModelBinderFactoryContext context)
63if (TryGetCachedBinder(context.Metadata, context.CacheToken, out var binder))
87private IModelBinder CreateBinderCoreCached(DefaultModelBinderProviderContext providerContext, object? token)
89if (TryGetCachedBinder(providerContext.Metadata, token, out var binder))
106private IModelBinder? CreateBinderCoreUncached(DefaultModelBinderProviderContext providerContext, object? token)
127if (visited.TryGetValue(key, out var binder))
146IModelBinder? result = null;
174private void AddToCache(ModelMetadata metadata, object? cacheToken, IModelBinder binder)
187private bool TryGetCachedBinder(ModelMetadata metadata, object? cacheToken, [NotNullWhen(true)] out IModelBinder? binder)
224Visited = new Dictionary<Key, IModelBinder?>();
246public Dictionary<Key, IModelBinder?> Visited { get; }
250public override IModelBinder CreateBinder(ModelMetadata metadata)
258public override IModelBinder CreateBinder(ModelMetadata metadata, BindingInfo bindingInfo)
ModelBinding\Binders\ComplexObjectModelBinderTest.cs (9)
298var binders = new Dictionary<ModelMetadata, IModelBinder>();
306Array.Empty<IModelBinder>(),
349new Dictionary<ModelMetadata, IModelBinder>(),
350Array.Empty<IModelBinder>(),
393new Dictionary<ModelMetadata, IModelBinder>(),
394Array.Empty<IModelBinder>(),
443elementSelector: item => (IModelBinder)new TestModelBinderProvider(item, ModelBindingResult.Success("Test")));
447Array.Empty<IModelBinder>(),
644public IModelBinder GetBinder(ModelBinderProviderContext context)
ModelBinding\Binders\ComplexTypeModelBinderTest.cs (11)
358var binders = new Dictionary<ModelMetadata, IModelBinder>();
409new Dictionary<ModelMetadata, IModelBinder>(),
453new Dictionary<ModelMetadata, IModelBinder>(),
599elementSelector: item => (IModelBinder)null);
621elementSelector: item => (IModelBinder)null);
1582public IModelBinder GetBinder(ModelBinderProviderContext context)
1586var propertyBinders = new Dictionary<ModelMetadata, IModelBinder>();
1603: this(new Dictionary<ModelMetadata, IModelBinder>())
1608: this(new Dictionary<ModelMetadata, IModelBinder>(), allowValidatingTopLevelNodes)
1612public TestableComplexTypeModelBinder(IDictionary<ModelMetadata, IModelBinder> propertyBinders)
1618IDictionary<ModelMetadata, IModelBinder> propertyBinders,