本文整理汇总了C#中ParameterCollection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterCollection.ToString方法的具体用法?C# ParameterCollection.ToString怎么用?C# ParameterCollection.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterCollection
的用法示例。
在下文中一共展示了ParameterCollection.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRoutingUrl
public static string GetRoutingUrl(RoutingDefinition routingDefinition)
{
var parameters = new ParameterCollection();
if (routingDefinition != null && routingDefinition.ParentId != null)
{
parameters.Add("parent", routingDefinition.ParentId.ToString());
}
if (routingDefinition != null && routingDefinition.RoutingId != null)
{
parameters.Add("routing", routingDefinition.RoutingId.ToString());
}
return parameters.ToString();
}
示例2: ToString_PrintsCorrectly
public void ToString_PrintsCorrectly(IDictionary<string, string> parameters, string expected)
{
// Arrange
ParameterCollection collection = new ParameterCollection();
foreach (var parameter in parameters)
{
collection.Add(parameter.Key, parameter.Value);
}
// Act
string actual = collection.ToString();
// Assert
Assert.Equal(expected, actual);
}
示例3: 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
//.........这里部分代码省略.........
示例4: printStructureValues_console
/// <summary>
/// Prints a structure´s parameter values to the console.
/// </summary>
/// <param name="parameters">The console input.</param>
private void printStructureValues_console(ParameterCollection parameters)
{
if (parameters.Count < 2)
{
Game.Console.Print("usage: si_printvalues <structure name> <element index>");
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;
}
SParameter tempParam = new SParameter();
for (int i = 0; i < tempStruct.NumParams; i++)
{
tempStruct.GetGenericParamByIndex(i, out tempParam);
if (tempParam.Type == typeof(float))
{
float value = 0f;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(uint))
{
uint value = 0;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(string))
{
string value = string.Empty;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value);
}
else if (tempParam.Type == typeof(char))
{
char value = '\0';
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value);
}
else if (tempParam.Type == typeof(int))
{
int value = 0;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(short))
{
short value = 0;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(double))
{
double value = 0f;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(long))
{
long value = 0;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
else if (tempParam.Type == typeof(char[]))
{
int value = 0;
tempStruct.GetParamValue(index, i, ref value);
Game.Console.Print(tempParam.ParamName + " " + value.ToString());
}
}
}
示例5: printStructureParams_console
/// <summary>
/// Prints a structure´s parameters to the console.
/// </summary>
/// <param name="parameters">The console input.</param>
private void printStructureParams_console(ParameterCollection parameters)
{
if (parameters.Count == 0)
{
Game.Console.Print("usage: si_printparams <structure name>");
return;
}
string structName = parameters.ToString(0);
CEditableStruct tempStruct = GlobalVars.Structures.Find(x => x.Name == structName);
if (tempStruct == null)
{
Game.Console.Print("No struct found with name \"" + structName + "\"!");
return;
}
Game.Console.Print("Listing parameters for structure \"" + structName + "\":");
SParameter tempParameter = new SParameter();
for (int i = 0; i < tempStruct.NumParams; i++)
{
tempStruct.GetGenericParamByIndex(i, out tempParameter);
Game.Console.Print(tempParameter.ParamName.ToString() + " " + "0x" + String.Format("{0:X}", tempParameter.Offset) + " " + tempParameter.Type.ToString() + " " + tempParameter.MinVal.ToString() + " " + tempParameter.MaxVal.ToString());
}
}
示例6: GetUrlParameters
public string GetUrlParameters()
{
var parameters = new ParameterCollection();
parameters.Add("routing", _routing, _routingSet);
parameters.Add("pretty", "true", _prettySet);
parameters.Add("search_type", _seachType.ToString(), _seachTypeSet);
parameters.Add("query_cache", _queryCache.ToString().ToLower(), _queryCacheSet);
return parameters.ToString();
}