From 75588b050e20daef2c8e189639ef3c60cd63e01e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 5 May 2011 20:31:03 +1200 Subject: [PATCH] improve error message in CreateDevice --- OpenRA.Game/Graphics/Renderer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index b30056a7ea..02c3b7b316 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -135,12 +135,13 @@ namespace OpenRA.Graphics static IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync ) { + var argTypes = new Type[] { typeof( int ), typeof( int ), typeof( WindowMode ), typeof( bool ) }; + var argValues = new object[] { width, height, window, vsync }; + foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) ) - { - return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( WindowMode ), typeof( bool ) } ) - .Invoke( new object[] { width, height, window, vsync } ); - } - throw new NotImplementedException(); + return (IGraphicsDevice)r.Type.GetConstructor( argTypes ).Invoke( argValues ); + + throw new InvalidOperationException("Renderer DLL is missing RendererAttribute to tell us what type to use!"); } internal IVertexBuffer GetTempVertexBuffer()