-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ConsoleCustomTypeParserAttribute (#97)
This attribute is an alternative to DebugLogConsole.AddCustomParameterType.
- Loading branch information
1 parent
51e0996
commit fe646cf
Showing
8 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
Plugins/IngameDebugConsole/Scripts/Attributes/ConsoleAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace IngameDebugConsole | ||
{ | ||
public abstract class ConsoleAttribute : Attribute | ||
{ | ||
public MethodInfo Method { get; private set; } | ||
public abstract int Order { get; } | ||
|
||
public void SetMethod(MethodInfo method) | ||
{ | ||
if (Method != null) | ||
throw new Exception("Method was already initialized."); | ||
|
||
Method = method; | ||
} | ||
|
||
public abstract void Load(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
Plugins/IngameDebugConsole/Scripts/Attributes/ConsoleAttribute.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
Plugins/IngameDebugConsole/Scripts/Attributes/ConsoleCustomTypeParserAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace IngameDebugConsole | ||
{ | ||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)] | ||
public class ConsoleCustomTypeParserAttribute : ConsoleAttribute | ||
{ | ||
public readonly Type type; | ||
public readonly string readableName; | ||
|
||
public override int Order { get { return 0; } } | ||
|
||
public ConsoleCustomTypeParserAttribute(Type type, string readableName) | ||
{ | ||
this.type = type; | ||
this.readableName = readableName; | ||
} | ||
|
||
public override void Load() | ||
{ | ||
DebugLogConsole.AddCustomParameterType(Method, type, readableName); | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
Plugins/IngameDebugConsole/Scripts/Attributes/ConsoleCustomTypeParserAttribute.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters