本文整理汇总了C#中CodeExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression类的具体用法?C# CodeExpression怎么用?C# CodeExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeExpression类属于命名空间,在下文中一共展示了CodeExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateDefaultArgMethod
protected override void GenerateDefaultArgMethod(
CodeParameterDeclarationExpression[] argList,
CodeExpression [] paramList)
{
var cons = gen.Constructor(argList, () => {});
cons.ChainedConstructorArgs.AddRange(paramList);
}
开发者ID:uxmal,项目名称:pytocs,代码行数:7,代码来源:ConstructorGenerator.cs
示例2: CodeMethodInvokeExpression
public CodeMethodInvokeExpression(CodeExpression targetObject,
string methodName,
params CodeExpression[] parameters)
{
this.method = new CodeMethodReferenceExpression(targetObject, methodName);
this.Parameters.AddRange(parameters);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:7,代码来源:CodeMethodInvokeExpression.cs
示例3: CodeForStatement
public CodeForStatement(CodeExpression init, CodeExpression condition,CodeExpression next, CodeStatement statement)
{
Init = init;
Condition = condition;
Next = next;
Statement = statement;
}
开发者ID:eightrivers,项目名称:SSharp,代码行数:7,代码来源:CodeForStatement.cs
示例4: CodeMethodReferenceExpression
public CodeMethodReferenceExpression(CodeExpression targetObject,
string methodName, params CodeTypeReference[] typeParameters) :
this (targetObject, methodName)
{
if (typeParameters != null && typeParameters.Length > 0)
TypeArguments.AddRange(typeParameters);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:7,代码来源:CodeMethodReferenceExpression.cs
示例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);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:32,代码来源:Utils.cs
示例6: CodeIterationStatement
public CodeIterationStatement(CodeStatement initStatement, CodeExpression testExpression, CodeStatement incrementStatement, params CodeStatement[] statements)
{
InitStatement = initStatement;
TestExpression = testExpression;
IncrementStatement = incrementStatement;
Statements.AddRange(statements);
}
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:CodeIterationStatement.cs
示例7: CodeVariableDeclarationStatement
public CodeVariableDeclarationStatement(string type,
string name,
CodeExpression initExpression)
{
this.type = new CodeTypeReference(type);
this.name = name;
this.initExpression = initExpression;
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:8,代码来源:CodeVariableDeclarationStatement.cs
示例8: CodeBinaryOperatorExpression
public CodeBinaryOperatorExpression(CodeExpression left,
CodeBinaryOperatorType op,
CodeExpression right)
{
this.left = left;
this.op = op;
this.right = right;
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:8,代码来源:CodeBinaryOperatorExpression.cs
示例9: CodeConditionStatement
public CodeConditionStatement(CodeExpression condition,
CodeStatement[] trueStatements,
CodeStatement[] falseStatements)
{
this.condition = condition;
this.TrueStatements.AddRange(trueStatements);
this.FalseStatements.AddRange(falseStatements);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:8,代码来源:CodeConditionStatement.cs
示例10: CodeMethodReferenceExpression
public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName, params CodeTypeReference[] typeParameters)
{
TargetObject = targetObject;
MethodName = methodName;
if (typeParameters != null && typeParameters.Length > 0)
{
TypeArguments.AddRange(typeParameters);
}
}
开发者ID:Corillian,项目名称:corefx,代码行数:9,代码来源:codemethodreferenceexpression.cs
示例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;
}
}
开发者ID:sunsided,项目名称:maze-evolution,代码行数:14,代码来源:CodeView.cs
示例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]);
}
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:12,代码来源:CodeExpressionCollection.cs
示例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);
}
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:CodeAttributeArgumentTests.cs
示例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();
}
开发者ID:sunsided,项目名称:maze-evolution,代码行数:17,代码来源:CodeView.cs
示例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
)
);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:15,代码来源:DLangaugeProvider.cs
示例16: GetCodeExpression
public override CodeExpression GetCodeExpression(
BoundPropertyEntry entry, object parsedData,
ExpressionBuilderContext context)
{
// entry.Expression is the number string
// (minus the RandomNumber: prefix).
if (!entry.Expression.Contains(","))
{
throw new ArgumentException("Must include two numbers separated by a comma.");
}
else
{
// Get the two numbers.
string[] numbers = entry.Expression.Split(',');
if (numbers.Length != 2)
{
throw new ArgumentException("Only include two numbers.");
}
else
{
int lowerLimit, upperLimit;
if (Int32.TryParse(numbers[0], out lowerLimit) &&
Int32.TryParse(numbers[1], out upperLimit))
{
// So far all the operations have been performed in
// normal code. That's because the two numbers are
// specified in the expression, and so they won't
// change each time the page is requested.
// However, the random number should be allowed to
// change each time, so you need to switch to CodeDOM.
Type type = entry.DeclaringType;
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(type)[entry.PropertyInfo.Name];
CodeExpression[] expressionArray = new CodeExpression[2];
expressionArray[0] = new CodePrimitiveExpression(lowerLimit);
expressionArray[1] = new CodePrimitiveExpression(upperLimit);
return new CodeCastExpression(descriptor.PropertyType, new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetRandomNumber", expressionArray));
}
else
{
throw new ArgumentException("Use valid integers.");
}
}
}
}
开发者ID:Helen1987,项目名称:edu,代码行数:48,代码来源:RandomNumberExpressionBuilder.cs
示例17: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
object parsedData, ExpressionBuilderContext context)
{
// entry.Expression - строка с числом
// без префикса (например: "1,6").
if (!entry.Expression.Contains(","))
{
throw new ArgumentException(" Должны быть указаны два числа, разделенные запятой");
}
else
{
// Получить два числа
string[] numbers = entry.Expression.Split(',');
if (numbers.Length != 2)
{
throw new ArgumentException("Должны быть указаны два числа");
}
else
{
int min, max;
if (Int32.TryParse(numbers[0], out min) &&
Int32.TryParse(numbers[1], out max))
{
// Получить ссылку на класс, имеющий метод GetRandomNumber().
// (Это класс, где данный код выполняется.)
CodeTypeReferenceExpression typeRef = new CodeTypeReferenceExpression(this.GetType());
// Определить параметры для GetRandomNumber().
CodeExpression[] methodParameters = new CodeExpression[2];
methodParameters[0] = new CodePrimitiveExpression(min);
methodParameters[1] = new CodePrimitiveExpression(max);
// Вернуть выражение привязки вызвав метод GetRandomNumber()
CodeMethodInvokeExpression methodCall = new CodeMethodInvokeExpression(
typeRef, "GetRandomNumber", methodParameters);
return methodCall;
}
else
{
throw new ArgumentException("Должны использоваться допустимые целые числа");
}
}
}
}
开发者ID:ShartepStudy,项目名称:WPF,代码行数:47,代码来源:RandomNumberExpressionBuilder.cs
示例18: GetPaddedHexToString
public virtual CodeExpression GetPaddedHexToString(CodeExpression obj, int padSize)
{
return new CodeBinaryOperatorExpression(
new CodePrimitiveExpression("0x"),
CodeBinaryOperatorType.StringConcat,
new CodeMethodInvokeExpression(
new CodeMethodInvokeExpression(
obj,
"ToString",
new CodePrimitiveExpression("X")
),
"PadLeft",
new CodePrimitiveExpression(padSize),
new CodePrimitiveExpression('0')
)
);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:17,代码来源:LanguageProvider.cs
示例19: GetExpression
public CodeExpression GetExpression(CodeExpression src)
{
CodeExpression baseExpression = new CodeBinaryOperatorExpression(
src,
CodeBinaryOperatorType.BitwiseAnd,
new CodePrimitiveExpression((uint)(((1u << (byte)(EndIdx - StartIdx + 1)) - 1) << (byte)StartIdx))
);
if (StartIdx != 0)
{
baseExpression = new CodeBinaryOperatorExpression(
baseExpression,
CodeBinaryOperatorType.ShiftRight,
new CodePrimitiveExpression((int)StartIdx)
);
}
return Utils.WrapInCast(
baseExpression,
(byte)Length
);
}
开发者ID:Orvid,项目名称:Orvid.Assembler,代码行数:20,代码来源:BitPatternRegistry.cs
示例20: GetCodeExpression
public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
if (!entry.Expression.Contains(","))
{
throw new ArgumentException(
"Must include two numbers separated by a comma.");
}
else
{
// Get the two numbers.
string[] numbers = entry.Expression.Split(',');
if (numbers.Length != 2)
{
throw new ArgumentException("Only include two numbers.");
}
else
{
int lowerLimit, upperLimit;
if (Int32.TryParse(numbers[0], out lowerLimit) &&
Int32.TryParse(numbers[1], out upperLimit))
{
// Get a reference to the class that has the
// GetRandomNumber() method.
// (It's the class where this code is executing.)
CodeTypeReferenceExpression typeRef = new
CodeTypeReferenceExpression(this.GetType());
CodeExpression[] methodParameters = new CodeExpression[2];
methodParameters[0] = new CodePrimitiveExpression(lowerLimit);
methodParameters[1] = new CodePrimitiveExpression(upperLimit);
return new CodeMethodInvokeExpression(typeRef, "GetRandomNumber", methodParameters);
}
else
{
throw new ArgumentException("Use valid integers.");
}
}
}
}
开发者ID:naynishchaughule,项目名称:ASP.NET,代码行数:38,代码来源:RandomNumberExpressionBuilder.cs
注:本文中的CodeExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论