/// <summary> /// This implementation requires the View Model Type to have a public parameterless constructor /// </summary> /// <param name="type"></param> /// <param name="data"></param> /// <returns></returns> public IViewModel ResolveModel(Type type, IModel data) { //Use explicit cast or "as" cast? Using as will result in null return value if the Type passed in doesn't implement IViewModel //Using explicit cast (IViewModel) will result in InvalidCastException if Type doesn't implement IViewModel if (type.IsInterface) { throw new InvalidViewModelTypeException(type); } return((IViewModel)helper.CreateInstance(type)); }
public ISkipLogic CreateOrDefault(Type providedSkipLogicType) { return(providedSkipLogicType == null ? new TestConditionAttributeIsMetSkipLogic() : typeCreator.CreateInstance <ISkipLogic>(providedSkipLogicType, new object[] { })); }