public static Game GetGameClass()
{
Type[] types = Assembly.GetEntryAssembly().GetTypes();
foreach (Type type in types.Where(type => type.BaseType == typeof (Game)))
{
try
{
return (Game) Activator.CreateInstance(type);
}
catch (Exception ex)
{
LogManager.GetClassLogger().Error(
"Failed to initialize constructor of {0}. Parameters at constructor are not supported.",
type.Name);
throw new TargetInvocationException(ex);
}
}
throw new InvalidOperationException("The game class was not found.");
}
/// <summary> /// Initializes SGL. /// </summary> public static void Initialize() { Game gameInstance = InitializeHelper.GetGameClass(); RenderTarget renderTarget; try { renderTarget = RenderTarget.Default; } catch (InvalidOperationException) { renderTarget = RenderTarget.Create(); } var sglInitializer = new Configurator(gameInstance, renderTarget); Initialize(sglInitializer); }