remove redundant parameter from ObjectCreator.Param attribute

This commit is contained in:
Bob
2010-10-11 15:16:08 +13:00
parent 6a25d989a7
commit beecb8aeb1
10 changed files with 14 additions and 12 deletions

View File

@@ -67,7 +67,7 @@ namespace OpenRA
{ {
var attrs = p[ i ].GetCustomAttributes<ParamAttribute>(); var attrs = p[ i ].GetCustomAttributes<ParamAttribute>();
if( attrs.Length != 1 ) throw new InvalidOperationException( "ObjectCreator: argument in [UseCtor] doesn't have [Param]" ); if( attrs.Length != 1 ) throw new InvalidOperationException( "ObjectCreator: argument in [UseCtor] doesn't have [Param]" );
a[ i ] = args[ attrs[ 0 ].ParamName ]; a[ i ] = args[ attrs[ 0 ].ParamName ?? p[i].Name ];
} }
return ctor.Invoke( a ); return ctor.Invoke( a );
} }
@@ -77,6 +77,8 @@ namespace OpenRA
{ {
public string ParamName { get; private set; } public string ParamName { get; private set; }
public ParamAttribute() { }
public ParamAttribute( string paramName ) public ParamAttribute( string paramName )
{ {
ParamName = paramName; ParamName = paramName;

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Widgets.Delegates
public class ConnectionDialogsDelegate : IWidgetDelegate public class ConnectionDialogsDelegate : IWidgetDelegate
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionDialogsDelegate( [ObjectCreator.Param( "widget" )] Widget widget ) public ConnectionDialogsDelegate( [ObjectCreator.Param] Widget widget )
{ {
widget.GetWidget("CONNECTION_BUTTON_ABORT").OnMouseUp = mi => { widget.GetWidget("CONNECTION_BUTTON_ABORT").OnMouseUp = mi => {
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false; widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
@@ -31,7 +31,7 @@ namespace OpenRA.Widgets.Delegates
public class ConnectionFailedDelegate : IWidgetDelegate public class ConnectionFailedDelegate : IWidgetDelegate
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionFailedDelegate( [ObjectCreator.Param( "widget" )] Widget widget ) public ConnectionFailedDelegate( [ObjectCreator.Param] Widget widget )
{ {
widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => { widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => {
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false; widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Widgets.Delegates
{ {
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DeveloperModeDelegate( [ObjectCreator.Param("world")] World world ) public DeveloperModeDelegate( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG"); var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Widgets.Delegates
int validPlayers = 0; int validPlayers = 0;
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DiplomacyDelegate( [ObjectCreator.Param("world")] World world ) public DiplomacyDelegate( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
var root = Widget.RootWidget.GetWidget("INGAME_ROOT"); var root = Widget.RootWidget.GetWidget("INGAME_ROOT");

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates
public class MainMenuButtonsDelegate : IWidgetDelegate public class MainMenuButtonsDelegate : IWidgetDelegate
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MainMenuButtonsDelegate( [ObjectCreator.Param( "widget" )] Widget widget ) public MainMenuButtonsDelegate( [ObjectCreator.Param] Widget widget )
{ {
// Main menu is the default window // Main menu is the default window
widget.GetWidget( "MAINMENU_BUTTON_JOIN" ).OnMouseUp = mi => { Widget.OpenWindow( "JOINSERVER_BG" ); return true; }; widget.GetWidget( "MAINMENU_BUTTON_JOIN" ).OnMouseUp = mi => { Widget.OpenWindow( "JOINSERVER_BG" ); return true; };

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Widgets.Delegates
Widget ServerTemplate; Widget ServerTemplate;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ServerBrowserDelegate( [ObjectCreator.Param( "widget" )] Widget widget ) public ServerBrowserDelegate( [ObjectCreator.Param] Widget widget )
{ {
var bg = widget.GetWidget("JOINSERVER_BG"); var bg = widget.GetWidget("JOINSERVER_BG");
@@ -187,7 +187,7 @@ namespace OpenRA.Widgets.Delegates
public class DirectConnectDelegate : IWidgetDelegate public class DirectConnectDelegate : IWidgetDelegate
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DirectConnectDelegate( [ObjectCreator.Param( "widget" )] Widget widget ) public DirectConnectDelegate( [ObjectCreator.Param] Widget widget )
{ {
var dc = widget.GetWidget("DIRECTCONNECT_BG"); var dc = widget.GetWidget("DIRECTCONNECT_BG");

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
{ {
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldInteractionControllerWidget( [ObjectCreator.Param( "world" )] World world ) public WorldInteractionControllerWidget( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
} }

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public BuildPaletteWidget( [ObjectCreator.Param("world")] World world ) public BuildPaletteWidget( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
} }

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{ {
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public IngameChromeDelegate( [ObjectCreator.Param("world")] World world ) public IngameChromeDelegate( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
var r = Widget.RootWidget; var r = Widget.RootWidget;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
{ {
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public OrderButtonsChromeDelegate( [ObjectCreator.Param("world")] World world ) public OrderButtonsChromeDelegate( [ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
var r = Widget.RootWidget; var r = Widget.RootWidget;