MvcContrib.Binders.DerivedTypeModelBinder.DetectInstantiationType C# (CSharp) Method

DetectInstantiationType() protected method

protected DetectInstantiationType ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext, Type typeToCreate ) : Type
controllerContext System.Web.Mvc.ControllerContext
bindingContext System.Web.Mvc.ModelBindingContext
typeToCreate System.Type
return System.Type
        protected Type DetectInstantiationType(ControllerContext controllerContext, ModelBindingContext bindingContext, Type typeToCreate)
        {
            var typeValue = _typeStampOperator.DetectTypeStamp(bindingContext, this);

            if (String.IsNullOrEmpty(typeValue))
                return typeToCreate;

            var derivedType = DerivedTypeModelBinderCache.GetDerivedType(typeValue);

            if (derivedType != null)
                return derivedType;

            throw new InvalidOperationException(string.Format("unable to located identified type '{0}' as a variant of '{1}'", typeValue, typeToCreate.FullName));
        }