Click or drag to resize

YArgumentParser Methods

The YArgumentParser type exposes the following members.

Methods
  Name Description
Public method Code example ArgumentIsSet(String) Check if the argName is set as a boolean.
Example
C#
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
In results :
  • argumentParser.ArgumentIsSet(string.Empty) will return false because the main argument cannot be set as boolean
  • argumentParser.ArgumentIsSet("s") will return false because this argument is not set as boolean
  • argumentParser.ArgumentIsSet("readonly") will return true
  • argumentParser.ArgumentIsSet("override") will return false
Public method Code example ArgumentIsSetT(T) Check if the argName is set as a boolean.
Example
C#
enum ArumentsTypes
{
    main = 0,
    s,
    m,
    readonly,
}
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
In results :
  • argumentParser.ArgumentIsSet(ArumentsTypes.main) will return false because the main argument cannot be set as boolean
  • argumentParser.ArgumentIsSet(ArumentsTypes.s) will return false because this argument is not set as boolean
  • argumentParser.ArgumentIsSet(ArumentsTypes.readonly) will return true
  • argumentParser.ArgumentIsSet(ArumentsTypes.m) will return false
Public method Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
Public method Code example GetArgument(String) Get a YArgument from the argName. Throw a KeyNotFoundException if the given param is not found.
Example
C#
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument("s");
YArgument mainArgument = argumentParser.GetArgument(string.Empty);
YArgument nullArgument = argumentParser.GetArgument("m");
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Public method Code example GetArgumentT(T) Get a YArgument from the argName. Throw a KeyNotFoundException if the given param is not found.
Example
C#
enum ArumentsTypes
{
    main = 0,
    s,
    m,
    readonly,
}
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument(ArumentsTypes.s);
YArgument mainArgument = argumentParser.GetArgument(ArumentsTypes.main);
YArgument nullArgument = argumentParser.GetArgument(ArumentsTypes.m);
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Public method GetHashCode Serves as the default hash function.
(Inherited from Object)
Public method GetMainArgument Get the main YArgument or null if not found.
Public method GetType Gets the Type of the current instance.
(Inherited from Object)
Public method Code example HasArgument(String) Check if the argName is set.
Example
C#
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
In results :
  • argumentParser.HasArgument(string.Empty) will return true because it has main argument
  • argumentParser.HasArgument("s") will return true
  • argumentParser.HasArgument("readonly") will return true
  • argumentParser.HasArgument("m") will return false
Public method Code example HasArgumentT(T) Check if the enum value argName is set.
Example
C#
enum ArumentsTypes
{
    main = 0,
    s,
    m,
    readonly,
}
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
In results :
  • argumentParser.ArgumentIsSet(ArumentsTypes.main) will return true
  • argumentParser.HasArgument(ArumentsTypes.s) will return true
  • argumentParser.HasArgument(ArumentsTypes.readonly) will return true
  • argumentParser.HasArgument(ArumentsTypes.m) will return false
Public method RegisterArgumentNameSet(String) Register an Argument name set.
Public method RegisterArgumentNameSetT(T) Register an Argument name set.
Public method ToString Returns a string that represents the current object.
(Inherited from Object)
Public method Code example TryGetArgument(String) Try to get a YArgument from the argName or null if the given param is not found.
Example
C#
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument("s");
YArgument mainArgument = argumentParser.GetArgument(string.Empty);
YArgument nullArgument = argumentParser.GetArgument("m");
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Public method Code example TryGetArgumentT(T) Try to get a YArgument from the argName or null if the given param is not found.
Example
C#
enum ArumentsTypes
{
    main = 0,
    s,
    m,
    readonly,
}
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument(ArumentsTypes.s);
YArgument mainArgument = argumentParser.GetArgument(ArumentsTypes.main);
YArgument nullArgument = argumentParser.GetArgument(ArumentsTypes.m);
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Top
Extension Methods
  Name Description
Public Extension Method GetMD5HashCode Get the MD5 Hash code of an Objectobj as a string.
(Defined by YObjectExtentionMethods)
Public Extension Method SerializeObject Serialize an ObjecttoSerialize.
(Defined by YSerializationCenter)
Top
See Also