本文整理汇总了C#中ParameterType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterType.ToString方法的具体用法?C# ParameterType.ToString怎么用?C# ParameterType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterType
的用法示例。
在下文中一共展示了ParameterType.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertParameterTypeToUnitType
/// <summary>
/// Returns the UnitType for the given
/// ParameterType (where possible).
/// </summary>
/// <param name="parameterType">The ParameterType
/// for which we need to know the UnitType</param>
/// <exception cref="ArgumentException">Thrown if
/// it is not possible to convert the ParameterType
/// to a UnitType.</exception>
public static UnitType ConvertParameterTypeToUnitType(
ParameterType parameterType)
{
// The conversion will from the in-memory dictionary.
//foreach( KeyValuePair<UnitType, ParameterType> kvp
// in BuildUnitTypeToParameterTypeMapping() )
//{
// if( kvp.Value == parameterType )
// {
// return kvp.Key;
// }
//}
if (_map_parameter_type_to_unit_type.ContainsKey(
parameterType))
{
return _map_parameter_type_to_unit_type[
parameterType];
}
else
{
// If we made it this far, there's
// no entry in the dictionary.
throw new ArgumentException(
"Cannot convert ParameterType '"
+ parameterType.ToString()
+ "' to a UnitType.");
}
}
示例2: ParameterTypeName
/// <summary>
/// The ParameterType method returns a human-readable
/// form of the ParameterType received as parameter.
/// </summary>
/// <param name="x">The ParameterType to be transformed to human-readable form.</param>
/// <returns>A human-readable string form of the ParameterType received as parameter.</returns>
public static string ParameterTypeName(ParameterType x)
{
switch(x)
{
case ParameterType.OPTIONAL: return "Optional";
case ParameterType.REQUIRED: return "Required";
default: return "Unrecognized Parameter Type: "+x.ToString();
}
}
示例3: isValidParameter
private bool isValidParameter(string name, ParameterType type, InterpolationType interp, int requestedSize, Parameter p)
{
if (p == null)
return false;
if (p.type != type)
{
UI.printWarning(UI.Module.API, "Parameter {0} requested as a {1} - declared as {2}", name, type.ToString().ToLower(), p.type.ToString().ToLower());
return false;
}
if (p.interp != interp)
{
UI.printWarning(UI.Module.API, "Parameter {0} requested as a {1} - declared as {2}", name, interp.ToString().ToLower(), p.interp.ToString().ToLower());
return false;
}
if (requestedSize > 0 && p.size() != requestedSize)
{
UI.printWarning(UI.Module.API, "Parameter {0} requires {1} {2} - declared with {3}", name, requestedSize, requestedSize == 1 ? "value" : "values", p.size());
return false;
}
p.Checked = true;
return true;
}
示例4: GetValueByType
public string GetValueByType(ParameterType type)
{
return Parameters.FirstOrDefault(x => x.Definition == type.ToString()).Value;
}
示例5: GetParameterAsString
private string GetParameterAsString(ParameterType param)
{
switch (param)
{
case ParameterType.String:
return " - text string";
case ParameterType.Type:
return " - type";
case ParameterType.VariableReference:
return " - reference to another parameter in the template";
}
return param.ToString();
}