本文整理汇总了C#中CodeExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression类的具体用法?C# CodeExpression怎么用?C# CodeExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeExpression类属于命名空间,在下文中一共展示了CodeExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateDefaultArgMethod
protected override void GenerateDefaultArgMethod(
CodeParameterDeclarationExpression[] argList,
CodeExpression [] paramList)
{
var cons = gen.Constructor(argList, () => {});
cons.ChainedConstructorArgs.AddRange(paramList);
}
示例2: CodeMethodInvokeExpression
public CodeMethodInvokeExpression(CodeExpression targetObject,
string methodName,
params CodeExpression[] parameters)
{
this.method = new CodeMethodReferenceExpression(targetObject, methodName);
this.Parameters.AddRange(parameters);
}
示例3: CodeForStatement
public CodeForStatement(CodeExpression init, CodeExpression condition,CodeExpression next, CodeStatement statement)
{
Init = init;
Condition = condition;
Next = next;
Statement = statement;
}
示例4: CodeMethodReferenceExpression
public CodeMethodReferenceExpression(CodeExpression targetObject,
string methodName, params CodeTypeReference[] typeParameters) :
this (targetObject, methodName)
{
if (typeParameters != null && typeParameters.Length > 0)
TypeArguments.AddRange(typeParameters);
}
示例5: WrapInCast
public static CodeExpression WrapInCast(CodeExpression srcExpr, byte sizeInBits, bool forceCastOnLiteral = false)
{
CodeTypeReference tp = null;
if (sizeInBits <= 8)
tp = StaticTypeReferences.Byte;
else if (sizeInBits <= 16)
tp = StaticTypeReferences.UShort;
else if (sizeInBits <= 32)
tp = StaticTypeReferences.UInt;
else if (sizeInBits <= 64)
tp = StaticTypeReferences.ULong;
else
throw new Exception("Geeze, that's giant!");
if (srcExpr is CodeCastExpression)
{
if (((CodeCastExpression)srcExpr).TargetType != tp)
((CodeCastExpression)srcExpr).TargetType = tp;
return srcExpr;
}
// This is only valid because of the
// context in which this method is called.
// (aka. this call is used only to widen
// values, it is never used to make them
// smaller)
else if (!forceCastOnLiteral && srcExpr is CodePrimitiveExpression)
{
return srcExpr;
}
return new CodeCastExpression(tp, srcExpr);
}
示例6: CodeIterationStatement
public CodeIterationStatement(CodeStatement initStatement, CodeExpression testExpression, CodeStatement incrementStatement, params CodeStatement[] statements)
{
InitStatement = initStatement;
TestExpression = testExpression;
IncrementStatement = incrementStatement;
Statements.AddRange(statements);
}
示例7: CodeVariableDeclarationStatement
public CodeVariableDeclarationStatement(string type,
string name,
CodeExpression initExpression)
{
this.type = new CodeTypeReference(type);
this.name = name;
this.initExpression = initExpression;
}
示例8: CodeBinaryOperatorExpression
public CodeBinaryOperatorExpression(CodeExpression left,
CodeBinaryOperatorType op,
CodeExpression right)
{
this.left = left;
this.op = op;
this.right = right;
}
示例9: CodeConditionStatement
public CodeConditionStatement(CodeExpression condition,
CodeStatement[] trueStatements,
CodeStatement[] falseStatements)
{
this.condition = condition;
this.TrueStatements.AddRange(trueStatements);
this.FalseStatements.AddRange(falseStatements);
}
示例10: CodeMethodReferenceExpression
public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName, params CodeTypeReference[] typeParameters)
{
TargetObject = targetObject;
MethodName = methodName;
if (typeParameters != null && typeParameters.Length > 0)
{
TypeArguments.AddRange(typeParameters);
}
}
示例11: CodeView
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Windows.Forms.Form"/> class.
/// </summary>
/// <remarks></remarks>
public CodeView(CodeExpression<Proband> code)
{
InitializeComponent();
Code = code;
if (code != null)
{
string rtf = RenderToRtf(code);
richTextBoxCode.Rtf = rtf;
}
}
示例12: AddRange
public void AddRange(CodeExpression[] value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
for (int i = 0; i < value.Length; i++)
{
Add(value[i]);
}
}
示例13: Ctor
public void Ctor(string name, CodeExpression value)
{
if (string.IsNullOrEmpty(name))
{
var argument1 = new CodeAttributeArgument(value);
Assert.Empty(argument1.Name);
Assert.Equal(value, argument1.Value);
}
var argument2 = new CodeAttributeArgument(name, value);
Assert.Equal(name ?? string.Empty, argument2.Name);
Assert.Equal(value, argument2.Value);
}
示例14: RenderToRtf
/// <summary>
/// Rendert den Code als Rich Text
/// </summary>
/// <param name="code">Der Code</param>
/// <returns></returns>
private string RenderToRtf(CodeExpression<Proband> code)
{
StringBuilder builder = new StringBuilder();
builder.AppendLine(@"{\rtf1\ansi\deff0");
// crimson --> #DC143C
// dodger --> #1E90FF
builder.AppendLine(@"{\colortbl;\red255\green255\blue255;\red220\green20\blue60;\red30\green144\blue255;}");
builder.AppendLine(@"{\fonttbl\f0\fswiss Consolas;}\f0\cf1");
RenderToRtf(code, 0, builder);
builder.AppendLine("}");
return builder.ToString();
}
示例15: GetPaddedHexToString
public override CodeExpression GetPaddedHexToString(CodeExpression obj, int padSize)
{
return new CodeBinaryOperatorExpression(
new CodePrimitiveExpression("0x"),
CodeBinaryOperatorType.StringConcat,
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression()
{
MethodName = "format"
},
new CodePrimitiveExpression("%0" + padSize.ToString() + "X"),
obj
)
);
}