本文整理汇总了C#中TypeOfExpression.AddAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# TypeOfExpression.AddAnnotation方法的具体用法?C# TypeOfExpression.AddAnnotation怎么用?C# TypeOfExpression.AddAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeOfExpression
的用法示例。
在下文中一共展示了TypeOfExpression.AddAnnotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertConstantValue
public Expression ConvertConstantValue(ResolveResult rr)
{
if (rr == null)
throw new ArgumentNullException("rr");
if (rr is ConversionResolveResult) {
// unpack ConversionResolveResult if necessary
// (e.g. a boxing conversion or string->object reference conversion)
rr = ((ConversionResolveResult)rr).Input;
}
if (rr is TypeOfResolveResult) {
var expr = new TypeOfExpression(ConvertType(((TypeOfResolveResult)rr).ReferencedType));
if (AddResolveResultAnnotations)
expr.AddAnnotation(rr);
return expr;
} else if (rr is ArrayCreateResolveResult) {
ArrayCreateResolveResult acrr = (ArrayCreateResolveResult)rr;
ArrayCreateExpression ace = new ArrayCreateExpression();
ace.Type = ConvertType(acrr.Type);
ComposedType composedType = ace.Type as ComposedType;
if (composedType != null) {
composedType.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers);
if (!composedType.HasNullableSpecifier && composedType.PointerRank == 0)
ace.Type = composedType.BaseType;
}
if (acrr.SizeArguments != null && acrr.InitializerElements == null) {
ace.AdditionalArraySpecifiers.FirstOrNullObject().Remove();
ace.Arguments.AddRange(acrr.SizeArguments.Select(ConvertConstantValue));
}
if (acrr.InitializerElements != null) {
ArrayInitializerExpression initializer = new ArrayInitializerExpression();
initializer.Elements.AddRange(acrr.InitializerElements.Select(ConvertConstantValue));
ace.Initializer = initializer;
}
if (AddResolveResultAnnotations)
ace.AddAnnotation(rr);
return ace;
} else if (rr.IsCompileTimeConstant) {
return ConvertConstantValue(rr.Type, rr.ConstantValue);
} else {
return new ErrorExpression();
}
}