本文整理汇总了C#中ParameterCollection.ToInteger方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterCollection.ToInteger方法的具体用法?C# ParameterCollection.ToInteger怎么用?C# ParameterCollection.ToInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterCollection
的用法示例。
在下文中一共展示了ParameterCollection.ToInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: editStructureParam_console
/// <summary>
/// Edits a structure's parameter value, using the console input.
/// </summary>
/// <param name="parameters">The console input..</param>
private void editStructureParam_console(ParameterCollection parameters)
{
if (parameters.Count < 4)
{
Game.Console.Print("usage: si_editparam <structure name> <element index> <param name> <new value>");
return;
}
string structName = parameters.ToString(0);
int index = 0;
if (!int.TryParse(parameters.ToString(1), out index))
{
Game.Console.Print("Invalid index specified!");
return;
}
CEditableStruct tempStruct = GlobalVars.Structures.Find(x => x.Name == structName);
if (tempStruct == null)
{
Game.Console.Print("No struct found with name \"" + structName + "\"!");
return;
}
string paramName = parameters.ToString(2);
SParameter tempParam = new SParameter();
if (tempStruct.GetGenericParamByName(paramName, ref tempParam) != 0)
{
Game.Console.Print("No parameter found with name \"" + paramName + "\"!");
return;
}
if (tempParam.Type == typeof(int))
{
int newVal = parameters.ToInteger(3);
int retVal = tempStruct.SetParamValue<int>(index, paramName, newVal);
if (retVal == -1)
{
Game.Console.Print("Invalid parameter index number");
return;
}
else
{
Game.Console.Print("Parameter changed");
}
}
else if (tempParam.Type == typeof(uint))
{
uint newVal = uint.Parse(parameters.ToString(3));
int retVal = tempStruct.SetParamValue(index, paramName, newVal);
if (retVal == -1)
{
Game.Console.Print("Invalid parameter index number");
return;
}
else
{
Game.Console.Print("Parameter changed");
}
}
else if (tempParam.Type == typeof(string))
{
string newVal = parameters.ToString(3);
int retVal = tempStruct.SetParamValue(index, paramName, newVal);
if (retVal == -1)
{
Game.Console.Print("Invalid parameter index number");
return;
}
else if (retVal == -3)
{
Game.Console.Print("Input string too long! Max size: " + tempParam.StringSize.ToString() + ", your input: " + newVal.Length);
return;
}
}
else if (tempParam.Type == typeof(char))
{
string newValString = parameters.ToString(3);
char newVal = '\0';
int retVal = 0;
if (newValString != string.Empty)
{
newVal = newValString[0];
if (retVal == -1)
{
Game.Console.Print("Invalid parameter index number");
return;
}
else
//.........这里部分代码省略.........
示例2: ConnectCommand
public static void ConnectCommand(ParameterCollection Parameter)
{
Connect(Parameter[0], Parameter.ToInteger(1));
}