当前位置: 首页>>代码示例>>C#>>正文


C# CodeDom.CodeExpression类代码示例

本文整理汇总了C#中System.CodeDom.CodeExpression的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression类的具体用法?C# CodeExpression怎么用?C# CodeExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CodeExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CodeVariableDeclarationStatement

	public CodeVariableDeclarationStatement(Type type, String name,
											CodeExpression initExpression)
			{
				this.type = new CodeTypeReference(type);
				this.name = name;
				this.initExpression = initExpression;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:CodeVariableDeclarationStatement.cs

示例2: SerializeCell

        object SerializeCell(IDesignerSerializationManager manager, CodeExpression target, Cell cell)
        {
            object codeObject = null;
            ExpressionContext context = null;
            ExpressionContext context2 = manager.Context[typeof(ExpressionContext)] as ExpressionContext;
            if (context2 != null)
            {
                CodeMethodInvokeExpression codeIndexer = new CodeMethodInvokeExpression(target, "GetAt", new CodePrimitiveExpression(cell.Column.Index));
                context = new ExpressionContext(codeIndexer, typeof(RowCollection), context2.PresetValue, cell);
                manager.Context.Push(context);
            }
            try
            {
                CodeDomSerializer rowSerialzier = (CodeDomSerializer)manager.GetSerializer(cell.GetType(), typeof(CodeDomSerializer));

                //codeObject = rowSerialzier.Serialize(manager, row);
                codeObject = rowSerialzier.SerializeAbsolute(manager, cell);
            }
            finally
            {
                if (context != null)
                {
                    manager.Context.Pop();
                }
            }

            return codeObject;
        }
开发者ID:NtreevSoft,项目名称:GridControl,代码行数:28,代码来源:RowCollectionCodeDomSerializer.cs

示例3: Analyze

 internal override void Analyze(RuleAnalysis analysis, MemberInfo member, CodeExpression targetExpression, RulePathQualifier targetQualifier, CodeExpressionCollection argumentExpressions, ParameterInfo[] parameters, List<CodeExpression> attributedExpressions)
 {
     if (!analysis.ForWrites)
     {
         base.AnalyzeReadWrite(analysis, targetExpression, targetQualifier, argumentExpressions, parameters, attributedExpressions);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:RuleReadAttribute.cs

示例4: CodeMethodReferenceExpression

 public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName, params CodeTypeReference[] typeParameters) {
     TargetObject = targetObject;
     MethodName = methodName;
     if( typeParameters != null && typeParameters.Length > 0) {
         TypeArguments.AddRange(typeParameters);
     }
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:codemethodreferenceexpression.cs

示例5: MakeEqual

 /// <summary>
 /// Generates a test to determine if the given expressions are equal.
 /// </summary>
 /// <param name="clrType">The Type of the values being compared.</param>
 /// <param name="left">The left side of the test.</param>
 /// <param name="right">The right side of the test.</param>
 /// <param name="isCSharp">Indicates whether or not the output should be C# specific.</param>
 /// <returns>A new <see cref="CodeExpression"/>.</returns>
 public static CodeExpression MakeEqual(Type clrType, CodeExpression left, CodeExpression right, bool isCSharp)
 {
     if (isCSharp)
     {
         return new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.IdentityEquality, right);
     }
     else
     {
         CodeExpression eq;
         if (clrType != null && clrType.IsGenericType && clrType.GetGenericTypeDefinition() == typeof(Nullable<>))
         {
             eq = new CodeMethodInvokeExpression(left, "Equals", right);
         }
         else if (clrType != null && clrType.IsValueType)
         {
             eq = new CodeBinaryOperatorExpression(
                     left,
                     CodeBinaryOperatorType.ValueEquality,
                     right);
         }
         else if (clrType == typeof(string))
         {
             eq = new CodeMethodInvokeExpression(null, "String.Equals", left, right);
         }
         else
         {
             eq = new CodeMethodInvokeExpression(null, typeof(object).Name + ".Equals", left, right);
         }
         return eq;
     }
 }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:39,代码来源:CodeGenUtilities.cs

示例6: GeneratePropertySet

		protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			if (prop.Name == "Alpha" && Alpha == -1)
				return;
			else
				base.GeneratePropertySet (ctx, var, prop);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:ColorButton.cs

示例7: Decompile

 internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
 {
     CodeCastExpression childExpr = (CodeCastExpression) expression;
     CodeExpression expression3 = childExpr.Expression;
     if (expression3 == null)
     {
         RuleEvaluationException exception = new RuleEvaluationException(Messages.NullCastExpr);
         exception.Data["ErrorObject"] = childExpr;
         throw exception;
     }
     if (childExpr.TargetType == null)
     {
         RuleEvaluationException exception2 = new RuleEvaluationException(Messages.NullCastType);
         exception2.Data["ErrorObject"] = childExpr;
         throw exception2;
     }
     bool flag = RuleDecompiler.MustParenthesize(childExpr, parentExpression);
     if (flag)
     {
         stringBuilder.Append("(");
     }
     stringBuilder.Append("(");
     RuleDecompiler.DecompileType(stringBuilder, childExpr.TargetType);
     stringBuilder.Append(")");
     RuleExpressionWalker.Decompile(stringBuilder, expression3, childExpr);
     if (flag)
     {
         stringBuilder.Append(")");
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:CastExpression.cs

示例8: AnalyzeUsage

        internal override void AnalyzeUsage(CodeExpression expression, RuleAnalysis analysis, bool isRead, bool isWritten, RulePathQualifier qualifier)
        {
            CodeDirectionExpression expression2 = (CodeDirectionExpression) expression;
            CodeExpression expression3 = expression2.Expression;
            bool flag = false;
            bool flag2 = true;
            RulePathQualifier qualifier2 = null;
            switch (expression2.Direction)
            {
                case FieldDirection.In:
                    flag = false;
                    flag2 = true;
                    qualifier2 = new RulePathQualifier("*", null);
                    break;

                case FieldDirection.Out:
                    flag = true;
                    flag2 = false;
                    qualifier2 = null;
                    break;

                case FieldDirection.Ref:
                    flag = true;
                    flag2 = true;
                    qualifier2 = analysis.ForWrites ? null : new RulePathQualifier("*", null);
                    break;
            }
            RuleExpressionWalker.AnalyzeUsage(analysis, expression3, flag2, flag, qualifier2);
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:DirectionExpression.cs

示例9: Validate

 internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
 {
     RuleExpressionInfo info;
     bool flag;
     CodeDirectionExpression expression2 = (CodeDirectionExpression) expression;
     if (isWritten)
     {
         ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodeDirectionExpression).ToString() }), 0x17a);
         item.UserData["ErrorObject"] = expression2;
         validation.Errors.Add(item);
         return null;
     }
     if (expression2.Expression == null)
     {
         ValidationError error2 = new ValidationError(Messages.NullDirectionTarget, 0x53d);
         error2.UserData["ErrorObject"] = expression2;
         validation.Errors.Add(error2);
         return null;
     }
     if (expression2.Expression is CodeTypeReferenceExpression)
     {
         ValidationError error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CodeExpressionNotHandled, new object[] { expression2.Expression.GetType().FullName }), 0x548);
         error.UserData["ErrorObject"] = expression2.Expression;
         validation.AddError(error);
         return null;
     }
     if (expression2.Direction == FieldDirection.Ref)
     {
         flag = true;
         if (RuleExpressionWalker.Validate(validation, expression2.Expression, false) == null)
         {
             return null;
         }
         info = RuleExpressionWalker.Validate(validation, expression2.Expression, true);
     }
     else if (expression2.Direction == FieldDirection.Out)
     {
         flag = true;
         info = RuleExpressionWalker.Validate(validation, expression2.Expression, true);
     }
     else
     {
         flag = false;
         info = RuleExpressionWalker.Validate(validation, expression2.Expression, false);
     }
     if (info == null)
     {
         return null;
     }
     Type expressionType = info.ExpressionType;
     if (expressionType == null)
     {
         return null;
     }
     if (((expressionType != typeof(NullLiteral)) && flag) && !expressionType.IsByRef)
     {
         expressionType = expressionType.MakeByRefType();
     }
     return new RuleExpressionInfo(expressionType);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:DirectionExpression.cs

示例10: CodeMethodInvokeExpression

		public CodeMethodInvokeExpression (CodeExpression targetObject,
						   string methodName,
						   params CodeExpression [] parameters)
		{
			this.method = new CodeMethodReferenceExpression( targetObject, methodName );
			this.Parameters.AddRange (parameters);
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:CodeMethodInvokeExpression.cs

示例11: GetCodeExpression

        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            if (!entry.Expression.Contains(","))
              {
            throw new ArgumentException("Must include two numbers separated by a comma.");
              }
              else
              {
            // get 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))
              {
            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:bq-wang,项目名称:aspnet,代码行数:33,代码来源:RandomNumberExpressionBuilder.cs

示例12: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeExpression expression = new CodeExpression ();
			CodeMethodReturnStatement cmrs = new CodeMethodReturnStatement (expression);
			Assert.AreSame (expression, cmrs.Expression, "Expression");
			cmrs.Expression = new CodeExpression ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeMethodReturnStatementCas.cs

示例13: Constructor1

		public void Constructor1 ()
		{
			CodeEventReferenceExpression eventref = new CodeEventReferenceExpression ();
			CodeExpression listener = new CodeExpression ();

			CodeRemoveEventStatement caes = new CodeRemoveEventStatement (eventref, listener);
			Assert.AreSame (eventref, caes.Event, "#1");
			Assert.AreEqual (string.Empty, caes.Event.EventName, "#2");
			Assert.IsNull (caes.Event.TargetObject, "#3");
			Assert.AreSame (listener, caes.Listener, "#4");

			caes.Event = null;
			Assert.IsNotNull (caes.Event, "#5");
			Assert.AreEqual (string.Empty, caes.Event.EventName, "#6");
			Assert.IsNull (caes.Event.TargetObject, "#7");
			Assert.AreSame (listener, caes.Listener, "#8");

			caes.Listener = null;
			Assert.IsNull (caes.Listener, "#9");

			caes.Event = eventref;
			Assert.AreSame (eventref, caes.Event, "#10");

			caes.Listener = listener;
			Assert.AreSame (listener, caes.Listener, "#11");

			caes = new CodeRemoveEventStatement ((CodeEventReferenceExpression) null, (CodeExpression) null);
			Assert.IsNotNull (caes.Event, "#12");
			Assert.IsNull (caes.Listener, "#13");
			Assert.AreEqual (string.Empty, caes.Event.EventName, "#14");
			Assert.IsNull (caes.Event.TargetObject, "#15");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:CodeRemoveEventStatementTest.cs

示例14: EmitExpression

 void EmitExpression(CodeExpression expr)
 {
     if (expr is CodeMethodInvokeExpression)
         EmitInvoke((CodeMethodInvokeExpression)expr);
     else if (expr is CodeArrayCreateExpression)
         EmitArray((CodeArrayCreateExpression)expr);
     else if (expr is CodePrimitiveExpression)
         EmitPrimitive((CodePrimitiveExpression)expr);
     else if (expr is CodeBinaryOperatorExpression)
         EmitBinary((CodeBinaryOperatorExpression)expr);
     else if (expr is CodeTernaryOperatorExpression)
         EmitTernary((CodeTernaryOperatorExpression)expr);
     else if (expr is CodeVariableReferenceExpression)
         EmitVariableReference((CodeVariableReferenceExpression)expr);
     else if (expr is CodeArgumentReferenceExpression)
         EmitArgumentReference((CodeArgumentReferenceExpression)expr);
     else if (expr is CodeFieldReferenceExpression)
         EmitFieldReference((CodeFieldReferenceExpression)expr);
     else if (expr is CodeTypeReferenceExpression)
         EmitTypeReference((CodeTypeReferenceExpression)expr);
     else if (expr is CodeArrayIndexerExpression)
         EmitArrayIndexer((CodeArrayIndexerExpression)expr);
     else if (expr is CodePropertyReferenceExpression)
         EmitPropertyReference((CodePropertyReferenceExpression)expr);
     else
         throw new ArgumentException("Unrecognised expression: " + expr.GetType());
 }
开发者ID:BillTheBest,项目名称:IronAHK,代码行数:27,代码来源:Expression.cs

示例15: OptimiseExpression

        CodeExpression OptimiseExpression(CodeExpression expr)
        {
            if (!IsOptimisableExpression(expr))
                return expr;

            var invoke = (CodeMethodInvokeExpression)expr;

            for (int i = 1; i < 3; i++)
                invoke.Parameters[i] = OptimiseExpression(invoke.Parameters[i]);

            if (invoke.Parameters[1] is CodePrimitiveExpression && invoke.Parameters[2] is CodePrimitiveExpression)
            {
                object result = null;

                try
                {
                    result = Script.Operate((Script.Operator)invoke.Parameters[0].UserData[RawData],
                        ((CodePrimitiveExpression)invoke.Parameters[1]).Value,
                        ((CodePrimitiveExpression)invoke.Parameters[2]).Value);
                }
                catch (Exception) { }

                return new CodePrimitiveExpression(result);
            }

            return invoke;
        }
开发者ID:lnsoso,项目名称:IronAHK,代码行数:27,代码来源:Optimise.cs


注:本文中的System.CodeDom.CodeExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。