本文整理汇总了C#中Variable.GetCodeType方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.GetCodeType方法的具体用法?C# Variable.GetCodeType怎么用?C# Variable.GetCodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.GetCodeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrongCodeTypeException
/// <summary>
/// Initializes a new instance of the <see cref="WrongCodeTypeException" /> class.
/// </summary>
/// <param name="variable">The variable.</param>
/// <param name="argumentName">Name of the argument.</param>
/// <param name="expectedText">The expected text.</param>
public WrongCodeTypeException(Variable variable, string argumentName, string expectedText)
: base(string.Format("Wrong code type [{0}] of passed parameter '{1}'. Expected {2}.", variable.GetCodeType().Name, argumentName, expectedText))
{
Variable = variable;
CodeType = variable.GetCodeType();
ArgumentName = argumentName;
}
示例2: CodeFunction
/// <summary>
/// Initializes a new instance of the <see cref="CodeFunction"/> class.
/// </summary>
/// <param name="variable">The variable.</param>
public CodeFunction(Variable variable)
: this(variable.GetPointerAddress(), variable.GetCodeType().Module.Process)
{
// Verify code type
if (!VerifyCodeType(variable.GetCodeType()))
{
throw new WrongCodeTypeException(variable, nameof(variable), "function");
}
}
示例3: ClrString
/// <summary>
/// Initializes a new instance of the <see cref="ClrString"/> class.
/// </summary>
/// <param name="variable">The variable.</param>
public ClrString(Variable variable)
: base(variable)
{
// Check if code type is string type
ClrCodeType codeType = variable.GetCodeType() as ClrCodeType;
if (codeType == null || !codeType.ClrType.IsString)
{
throw new WrongCodeTypeException(variable.GetCodeType(), nameof(variable), "System.String");
}
}
示例4: ClrException
/// <summary>
/// Initializes a new instance of the <see cref="ClrException"/> class.
/// </summary>
/// <param name="variable">The variable.</param>
public ClrException(Variable variable)
: base(variable)
{
// Check if code type is exception type
ClrCodeType codeType = variable.GetCodeType() as ClrCodeType;
bool found = false;
while (!found && codeType != null)
{
if (codeType.Name == "System.Exception")
{
found = true;
}
else
{
codeType = (ClrCodeType)codeType.InheritedClass;
}
}
if (!found)
{
throw new WrongCodeTypeException(variable.GetCodeType(), nameof(variable), "System.Exception");
}
}