本文整理汇总了C#中Compiler.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于Compiler命名空间,在下文中一共展示了Expression类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Make
internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
if (returnType == typeof(object)) {
return new DynamicExpression4(delegateType, binder, arg0, arg1, arg2, arg3);
} else {
return new TypedDynamicExpression4(returnType, delegateType, binder, arg0, arg1, arg2, arg3);
}
}
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:DynamicExpression.cs
示例2: SetCurrentLine
public void SetCurrentLine(string line)
{
lineNumber++;
currentLine = line;
Value = null;
if(currentLine.Count() > 0){
localExpression = new Expression(currentLine);
if (localExpression.NumericalEvaluation != null) {
Value = localExpression.NumericalEvaluation;
OutputString = localExpression.OutputString;
} else {
OutputString = "\""+line+"\" " + localExpression.OutputString;
}
}
}
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:15,代码来源:TextualContent.cs
示例3: ExpressionConstructorTest
public void ExpressionConstructorTest()
{
Expression target = new Expression("3+4*334 - te 33z 34.3.4,() || ,");
Tokens tokens = new Tokens(new System.Collections.Generic.List<Token>(){
new Token("3", TokenType.numberLiteral),
new Token("+", TokenType.operatorOrPunctuation),
new Token("+4", TokenType.numberLiteral),
new Token("*", TokenType.operatorOrPunctuation),
new Token("334", TokenType.numberLiteral),
new Token("-", TokenType.atomicOperatorOrPunctuation),
new Token("te", TokenType.identifier),
new Token("33z", TokenType.identifier),
new Token("34.3.4", TokenType.numberLiteral),
new Token(",", TokenType.operatorOrPunctuation),
new Token("(", TokenType.atomicOperatorOrPunctuation),
new Token(")", TokenType.atomicOperatorOrPunctuation),
new Token("||", TokenType.operatorOrPunctuation),
new Token(",", TokenType.operatorOrPunctuation)
});
for(int i=0; i < tokens.AsList().Count; i++){
Assert.AreEqual<string>(tokens.AsList()[i].TokenString, target.Tokens.AsList()[i].TokenString);
Assert.AreEqual<TokenType>(tokens.AsList()[i].TokenType, target.Tokens.AsList()[i].TokenType);
}
}
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:24,代码来源:ExpressionTest.cs
示例4: TypedDynamicExpression4
internal TypedDynamicExpression4(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
: base(delegateType, binder, arg0, arg1, arg2, arg3) {
_retType = retType;
}
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:DynamicExpression.cs
示例5: Rewrite
internal override DynamicExpression Rewrite(Expression[] args) {
Debug.Assert(args.Length == 4);
return Expression.MakeDynamic(DelegateType, Binder, args[0], args[1], args[2], args[3]);
}
开发者ID:jschementi,项目名称:iron,代码行数:5,代码来源:DynamicExpression.cs
示例6: DynamicExpression4
private readonly Expression _arg1, _arg2, _arg3; // storage for the 2nd - 4th arguments
internal DynamicExpression4(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
: base(delegateType, binder) {
_arg0 = arg0;
_arg1 = arg1;
_arg2 = arg2;
_arg3 = arg3;
}
开发者ID:jschementi,项目名称:iron,代码行数:9,代码来源:DynamicExpression.cs
示例7: DynamicExpression2
private readonly Expression _arg1; // storage for the 2nd argument
internal DynamicExpression2(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1)
: base(delegateType, binder) {
_arg0 = arg0;
_arg1 = arg1;
}
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:DynamicExpression.cs
示例8: TypedDynamicExpression1
internal TypedDynamicExpression1(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0)
: base(delegateType, binder, arg0) {
_retType = retType;
}
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:DynamicExpression.cs
示例9: ExpressionConstructorTest1
public void ExpressionConstructorTest1()
{
string textOfCurrentLine = "4+-1(3)(-3)3--3";
Expression target = new Expression(textOfCurrentLine);
//Assert.AreEqual(target.OutputString, "34");
}
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:6,代码来源:ExpressionTest.cs
示例10:
Expression IDynamicExpression.Rewrite(Expression[] args)
{
return this.Rewrite(args);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:4,代码来源:DynamicExpression.cs
示例11: MakeDynamic
/// <summary>
/// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" /> and four arguments.
/// </summary>
/// <param name="delegateType">The type of the delegate used by the <see cref="CallSite" />.</param>
/// <param name="binder">The runtime binder for the dynamic operation.</param>
/// <param name="arg0">The first argument to the dynamic operation.</param>
/// <param name="arg1">The second argument to the dynamic operation.</param>
/// <param name="arg2">The third argument to the dynamic operation.</param>
/// <param name="arg3">The fourth argument to the dynamic operation.</param>
/// <returns>
/// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
/// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
/// <see cref="DynamicExpression.DelegateType">DelegateType</see>,
/// <see cref="DynamicExpression.Binder">Binder</see>, and
/// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
/// </returns>
public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
return Expression.MakeDynamic(delegateType, binder, arg0, arg1, arg2, arg3);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:19,代码来源:DynamicExpression.cs
示例12: Dynamic
/// <summary>
/// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" />.
/// </summary>
/// <param name="binder">The runtime binder for the dynamic operation.</param>
/// <param name="returnType">The result type of the dynamic expression.</param>
/// <param name="arg0">The first argument to the dynamic operation.</param>
/// <param name="arg1">The second argument to the dynamic operation.</param>
/// <param name="arg2">The third argument to the dynamic operation.</param>
/// <param name="arg3">The fourth argument to the dynamic operation.</param>
/// <returns>
/// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
/// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
/// <see cref="DynamicExpression.Binder">Binder</see> and
/// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
/// </returns>
/// <remarks>
/// The <see cref="DynamicExpression.DelegateType">DelegateType</see> property of the
/// result will be inferred from the types of the arguments and the specified return type.
/// </remarks>
public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
return Expression.Dynamic(binder, returnType, arg0, arg1, arg2, arg3);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:22,代码来源:DynamicExpression.cs
示例13: MakeDynamic
/// <summary>
/// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" /> and one argument.
/// </summary>
/// <param name="delegateType">The type of the delegate used by the <see cref="CallSite" />.</param>
/// <param name="binder">The runtime binder for the dynamic operation.</param>
/// <param name="arg0">The argument to the dynamic operation.</param>
/// <returns>
/// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
/// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
/// <see cref="DynamicExpression.DelegateType">DelegateType</see>,
/// <see cref="DynamicExpression.Binder">Binder</see>, and
/// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
/// </returns>
public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0) {
ContractUtils.RequiresNotNull(delegateType, "delegatType");
ContractUtils.RequiresNotNull(binder, "binder");
ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), "delegateType", Strings.TypeMustBeDerivedFromSystemDelegate);
var method = GetValidMethodForDynamic(delegateType);
var parameters = method.GetParametersCached();
ValidateArgumentCount(method, ExpressionType.Dynamic, 2, parameters);
ValidateDynamicArgument(arg0);
ValidateOneArgument(method, ExpressionType.Dynamic, arg0, parameters[1]);
return DynamicExpression.Make(method.GetReturnType(), delegateType, binder, arg0);
}
开发者ID:bclubb,项目名称:ironruby,代码行数:27,代码来源:DynamicExpression.cs
示例14: MakeDynamic
/// <summary>
/// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" /> and four arguments.
/// </summary>
/// <param name="delegateType">The type of the delegate used by the <see cref="CallSite" />.</param>
/// <param name="binder">The runtime binder for the dynamic operation.</param>
/// <param name="arg0">The first argument to the dynamic operation.</param>
/// <param name="arg1">The second argument to the dynamic operation.</param>
/// <param name="arg2">The third argument to the dynamic operation.</param>
/// <param name="arg3">The fourth argument to the dynamic operation.</param>
/// <returns>
/// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
/// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
/// <see cref="DynamicExpression.DelegateType">DelegateType</see>,
/// <see cref="DynamicExpression.Binder">Binder</see>, and
/// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
/// </returns>
public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
ContractUtils.RequiresNotNull(delegateType, "delegateType");
ContractUtils.RequiresNotNull(binder, "binder");
if (!delegateType.IsSubclassOf(typeof(MulticastDelegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
var method = GetValidMethodForDynamic(delegateType);
var parameters = method.GetParametersCached();
ValidateArgumentCount(method, ExpressionType.Dynamic, 5, parameters);
ValidateDynamicArgument(arg0);
ValidateOneArgument(method, ExpressionType.Dynamic, arg0, parameters[1]);
ValidateDynamicArgument(arg1);
ValidateOneArgument(method, ExpressionType.Dynamic, arg1, parameters[2]);
ValidateDynamicArgument(arg2);
ValidateOneArgument(method, ExpressionType.Dynamic, arg2, parameters[3]);
ValidateDynamicArgument(arg3);
ValidateOneArgument(method, ExpressionType.Dynamic, arg3, parameters[4]);
return DynamicExpression.Make(method.GetReturnType(), delegateType, binder, arg0, arg1, arg2, arg3);
}
开发者ID:jschementi,项目名称:iron,代码行数:36,代码来源:DynamicExpression.cs
示例15: Dynamic
/// <summary>
/// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" />.
/// </summary>
/// <param name="binder">The runtime binder for the dynamic operation.</param>
/// <param name="returnType">The result type of the dynamic expression.</param>
/// <param name="arg0">The first argument to the dynamic operation.</param>
/// <param name="arg1">The second argument to the dynamic operation.</param>
/// <param name="arg2">The third argument to the dynamic operation.</param>
/// <param name="arg3">The fourth argument to the dynamic operation.</param>
/// <returns>
/// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
/// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
/// <see cref="DynamicExpression.Binder">Binder</see> and
/// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
/// </returns>
/// <remarks>
/// The <see cref="DynamicExpression.DelegateType">DelegateType</see> property of the
/// result will be inferred from the types of the arguments and the specified return type.
/// </remarks>
public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
ContractUtils.RequiresNotNull(binder, "binder");
ValidateDynamicArgument(arg0);
ValidateDynamicArgument(arg1);
ValidateDynamicArgument(arg2);
ValidateDynamicArgument(arg3);
DelegateHelpers.TypeInfo info = DelegateHelpers.GetNextTypeInfo(
returnType,
DelegateHelpers.GetNextTypeInfo(
arg3.Type,
DelegateHelpers.GetNextTypeInfo(
arg2.Type,
DelegateHelpers.GetNextTypeInfo(
arg1.Type,
DelegateHelpers.GetNextTypeInfo(
arg0.Type,
DelegateHelpers.NextTypeInfo(typeof(CallSite))
)
)
)
)
);
Type delegateType = info.DelegateType;
if (delegateType == null) {
delegateType = info.MakeDelegateType(returnType, arg0, arg1, arg2, arg3);
}
return DynamicExpression.Make(returnType, delegateType, binder, arg0, arg1, arg2, arg3);
}
开发者ID:jschementi,项目名称:iron,代码行数:50,代码来源:DynamicExpression.cs
示例16: ValidateDynamicArgument
private static void ValidateDynamicArgument(Expression arg) {
RequiresCanRead(arg, "arguments");
var type = arg.Type;
ContractUtils.RequiresNotNull(type, "type");
TypeUtils.ValidateType(type);
if (type == typeof(void)) throw Error.ArgumentTypeCannotBeVoid();
}
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:DynamicExpression.cs
示例17: DynamicExpression1
private object _arg0; // storage for the 1st argument or a readonly collection. See IArgumentProvider for more info.
internal DynamicExpression1(Type delegateType, CallSiteBinder binder, Expression arg0)
: base(delegateType, binder) {
_arg0 = arg0;
}
开发者ID:jschementi,项目名称:iron,代码行数:6,代码来源:DynamicExpression.cs
注:本文中的Compiler.Expression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论