Shim to instantiate a known type

This commit is contained in:
Chris Cameron
2018-02-19 15:23:08 -05:00
parent e07bffaf90
commit cd4791538a

View File

@@ -260,6 +260,21 @@ namespace ICD.Common.Utils
}
}
/// <summary>
/// Creates an instance of the given type, calling the default constructor.
/// </summary>
/// <returns></returns>
public static T CreateInstance<T>(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
if (!type.IsAssignableTo(typeof(T)))
throw new InvalidOperationException("Type is not assignable to T");
return (T)CreateInstance(type);
}
/// <summary>
/// Gets the custom attributes added to the given assembly.
/// </summary>