Compare commits
2
Commits
65fdcdc12c
...
a5249f8fac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5249f8fac | ||
|
|
b4e17972b9 |
+21
-4
@@ -14,19 +14,25 @@ namespace BlubbFish.Utils
|
|||||||
#region Classes
|
#region Classes
|
||||||
public struct VaildArguments
|
public struct VaildArguments
|
||||||
{
|
{
|
||||||
public VaildArguments(ArgLength length, Boolean required)
|
public VaildArguments(ArgLength length, Boolean required, String @default = "", String description = "")
|
||||||
{
|
{
|
||||||
this.Required = required;
|
this.Required = required;
|
||||||
this.Length = length;
|
this.Length = length;
|
||||||
|
this.Description = description;
|
||||||
|
this.@Default = @default;
|
||||||
}
|
}
|
||||||
public VaildArguments(ArgLength length)
|
public VaildArguments(ArgLength length, String @default = "", String description = "")
|
||||||
{
|
{
|
||||||
this.Required = false;
|
this.Required = false;
|
||||||
this.Length = length;
|
this.Length = length;
|
||||||
|
this.Description = description;
|
||||||
|
this.@Default = @default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArgLength Length { get; private set; }
|
public ArgLength Length { get; private set; }
|
||||||
public Boolean Required { get; private set; }
|
public Boolean Required { get; private set; }
|
||||||
|
public String Description { get; private set; }
|
||||||
|
public String Default { get; private set; }
|
||||||
}
|
}
|
||||||
private struct ArgTouple
|
private struct ArgTouple
|
||||||
{
|
{
|
||||||
@@ -107,6 +113,11 @@ namespace BlubbFish.Utils
|
|||||||
this.argList.Add(arg);
|
this.argList.Add(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach(KeyValuePair<String, VaildArguments> item in this.argsPosible) {
|
||||||
|
if(!this.HasArgumentType(item.Key) && item.Value.Length == ArgLength.Touple && item.Value.Default != "") {
|
||||||
|
this.argList.Add(new ArgTouple(item.Key, item.Value.Default));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -162,7 +173,10 @@ namespace BlubbFish.Utils
|
|||||||
String opt = "";
|
String opt = "";
|
||||||
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
|
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
|
||||||
if (item.Value.Required) {
|
if (item.Value.Required) {
|
||||||
req += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? " [data]\n" : "\n");
|
req += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? (item.Value.Default != "" ? " " + item.Value.Default + "\n" : " [data]\n") : "\n");
|
||||||
|
if(item.Value.Description != "") {
|
||||||
|
req += "\t" + item.Value.Description + "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (req != "") {
|
if (req != "") {
|
||||||
@@ -170,7 +184,10 @@ namespace BlubbFish.Utils
|
|||||||
}
|
}
|
||||||
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
|
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
|
||||||
if (!item.Value.Required) {
|
if (!item.Value.Required) {
|
||||||
opt += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? " [data]\n" : "\n");
|
opt += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? (item.Value.Default != "" ? " " + item.Value.Default + "\n" : " [data]\n") : "\n");
|
||||||
|
if (item.Value.Description != "") {
|
||||||
|
opt += "\t" + item.Value.Description + "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt != "") {
|
if (opt != "") {
|
||||||
|
|||||||
@@ -44,6 +44,17 @@ namespace BlubbFish.Utils {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region FieldHelper
|
||||||
|
public static Object GetField(this Object o, String name) {
|
||||||
|
FieldInfo field = o.GetType().GetField(name);
|
||||||
|
return field.IsPublic ? field.GetValue(o) : null;
|
||||||
|
}
|
||||||
|
public static Object GetField(this Type o, String name) {
|
||||||
|
FieldInfo field = o.GetField(name);
|
||||||
|
return field.IsPublic ? field.GetValue(o) : null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region InterfaceHelper
|
#region InterfaceHelper
|
||||||
public static Boolean HasInterface(this Type o, Type interf) {
|
public static Boolean HasInterface(this Type o, Type interf) {
|
||||||
foreach (Type item in o.GetInterfaces()) {
|
foreach (Type item in o.GetInterfaces()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user