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


C# AssignmentExpression类代码示例

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


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

示例1: GetActions

        public IEnumerable<CodeAction> GetActions(RefactoringContext context)
        {
            if (context.IsSomethingSelected) {
                yield break;
            }
            AstType type;
            var varDecl = GetVariableDeclarationStatement(context, out type);
            if (varDecl == null) {
                yield break;
            }
            yield return new CodeAction(context.TranslateString("Split local variable declaration and assignment"), script => {
                var assign = new AssignmentExpression (new IdentifierExpression (varDecl.Variables.First().Name), AssignmentOperatorType.Assign, varDecl.Variables.First().Initializer.Clone());

                var newVarDecl = (VariableDeclarationStatement)varDecl.Clone();
                newVarDecl.Role = BlockStatement.StatementRole;

                if (newVarDecl.Type.IsMatch(new SimpleType ("var"))) {
                    newVarDecl.Type = type;
                }

                newVarDecl.Variables.First().Initializer = Expression.Null;

                script.InsertBefore(varDecl, newVarDecl);
                script.Replace(varDecl, varDecl.Parent is ForStatement ? (AstNode)assign : new ExpressionStatement (assign));
            }, varDecl.Variables.First ().AssignToken);
        }
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:26,代码来源:SplitDeclarationAndAssignmentAction.cs

示例2: VisitAssignmentExpression

        public override void VisitAssignmentExpression(AssignmentExpression expression)
        {
            base.VisitAssignmentExpression (expression);

            Identifier identifier = expression.FindIdentifier();
            if (identifier == null)
                return;

            switch (expression.Operator)
            {
                case AssignmentOperatorType.BitwiseOr:
                case AssignmentOperatorType.BitwiseAnd:
                case AssignmentOperatorType.ExclusiveOr:
                case AssignmentOperatorType.Add:
                case AssignmentOperatorType.Subtract:
                case AssignmentOperatorType.Divide:
                case AssignmentOperatorType.Modulus:
                case AssignmentOperatorType.Multiply:
                case AssignmentOperatorType.ShiftLeft:
                case AssignmentOperatorType.ShiftRight:
                case AssignmentOperatorType.Assign:
                    this.lineMap[this.id++] = expression.StartLocation.Line;
                    break;
            }
        }
开发者ID:ermau,项目名称:Instant,代码行数:25,代码来源:IdentifyingVisitor.cs

示例3: GetActions

		public override IEnumerable<CodeAction> GetActions(RefactoringContext context)
		{
			if (context.IsSomethingSelected) {
				yield break;
			}
			AstType type;
			var varInitializer = GetVariableDeclarationStatement(context, out type);
			if (varInitializer == null)
				yield break;
			var statement = varInitializer.GetParent<Statement>();
			var declaration = varInitializer.GetParent<VariableDeclarationStatement>();
			if (declaration == null || (declaration.Modifiers & Modifiers.Const) != 0)
				yield break;

			var selectedNode = varInitializer.GetNodeAt(context.Location) ?? varInitializer;

			yield return new CodeAction(context.TranslateString("Split local variable declaration and assignment"), script => {
				var assign = new AssignmentExpression (new IdentifierExpression (varInitializer.Name), AssignmentOperatorType.Assign, varInitializer.Initializer.Clone());

				if (declaration != null && declaration.Type.IsVar())
					script.Replace(declaration.Type, type);
				if (declaration.Parent is ForStatement) {
					script.InsertBefore(statement, new VariableDeclarationStatement (type, varInitializer.Name));
					script.Replace(declaration, assign);
				} else {
					script.Replace(varInitializer, new IdentifierExpression (varInitializer.Name));
					script.InsertAfter(statement, new ExpressionStatement (assign));
				}

			}, selectedNode);
		}
开发者ID:sphynx79,项目名称:dotfiles,代码行数:31,代码来源:SplitDeclarationAndAssignmentAction.cs

示例4: VisitAssignmentExpression

        public override void VisitAssignmentExpression(AssignmentExpression expression)
        {
            base.VisitAssignmentExpression (expression);

            Identifier identifier = expression.FindIdentifier();
            if (identifier == null)
                return;

            switch (expression.Operator)
            {
                case AssignmentOperatorType.BitwiseOr:
                case AssignmentOperatorType.BitwiseAnd:
                case AssignmentOperatorType.ExclusiveOr:
                case AssignmentOperatorType.Add:
                case AssignmentOperatorType.Subtract:
                case AssignmentOperatorType.Divide:
                case AssignmentOperatorType.Modulus:
                case AssignmentOperatorType.Multiply:
                case AssignmentOperatorType.ShiftLeft:
                case AssignmentOperatorType.ShiftRight:
                {
                    BinaryOperatorType op = GetComplexAssignOperator (expression.Operator);
                    Expression right = new BinaryOperatorExpression (new IdentifierExpression (identifier.Name), op, expression.Right.Clone());

                    expression.Operator = AssignmentOperatorType.Assign;
                    expression.Right = GetAssignmentExpression (identifier, right);

                    break;
                }

                case AssignmentOperatorType.Assign:
                    expression.Right = GetAssignmentExpression (identifier, expression.Right);
                    break;
            }
        }
开发者ID:ermau,项目名称:Instant,代码行数:35,代码来源:InstrumentingRewriter.cs

示例5: VisitAssignmentExpression

		public virtual object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) {
			Debug.Assert((assignmentExpression != null));
			Debug.Assert((assignmentExpression.Left != null));
			Debug.Assert((assignmentExpression.Right != null));
			assignmentExpression.Left.AcceptVisitor(this, data);
			return assignmentExpression.Right.AcceptVisitor(this, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:AbstractASTVisitor.cs

示例6: Visit

        public override void Visit(AssignmentExpression expression)
        {
            outStream.Write(printFuncName + "(");
            expression.Left.Accept(this);            

            switch (expression.AssignmentOperator)
            {
                case AssignmentOperator.Add: outStream.Write(" += "); break;
                case AssignmentOperator.And: outStream.Write(" &= "); break;
                case AssignmentOperator.Assign: outStream.Write(" = "); break;
                case AssignmentOperator.Divide: outStream.Write(" /= "); break;
                case AssignmentOperator.Modulo: outStream.Write(" %= "); break;
                case AssignmentOperator.Multiply: outStream.Write(" *= "); break;
                case AssignmentOperator.Or: outStream.Write(" |= "); break;
                case AssignmentOperator.ShiftLeft: outStream.Write(" <<= "); break;
                case AssignmentOperator.ShiftRight: outStream.Write(" >>= "); break;
                case AssignmentOperator.Substract: outStream.Write(" -= "); break;
                case AssignmentOperator.UnsignedRightShift: outStream.Write(" >>>= "); break;
                case AssignmentOperator.XOr: outStream.Write(" ^= "); break;
            }

            expression.Right.Accept(this);
            outStream.Write(", \"{0}\")", TempName);

            //int currentTempCounter = tempCounter++;
            //outStream.Write("{0}{1} = ", tempVarName, currentTempCounter);
            //expression.Right.Accept(this);
            //outStream.WriteLine(";");

            //outStream.WriteLine("{0}{1};\nprint({0}{1});", tempVarName, currentTempCounter, tempVarName, currentTempCounter);            
        }
开发者ID:reshadi2,项目名称:mcjs,代码行数:31,代码来源:JSIntrumentor.cs

示例7: VisitAssignmentExpression

			public override void VisitAssignmentExpression (AssignmentExpression assignmentExpression)
			{
				base.VisitAssignmentExpression (assignmentExpression);

				if (assignmentExpression.Operator != AssignmentOperatorType.Assign)
					return;
				if (!(assignmentExpression.Left is IdentifierExpression) && 
					!(assignmentExpression.Left is MemberReferenceExpression))
					return;

				var resolveResult = ctx.Resolve (assignmentExpression.Left);
				var memberResolveResult = resolveResult as MemberResolveResult;
				if (memberResolveResult != null) {
					var memberResolveResult2 = ctx.Resolve (assignmentExpression.Right) as MemberResolveResult;
					if (memberResolveResult2 == null || !AreEquivalent(memberResolveResult, memberResolveResult2))
						return;
				} else if (resolveResult is LocalResolveResult) {
					if (!assignmentExpression.Left.Match (assignmentExpression.Right).Success)
						return;
				} else {
					return;
				}

				AstNode node;
				Action<Script> action;
				if (assignmentExpression.Parent is ExpressionStatement) {
					node = assignmentExpression.Parent;
					action = script => script.Remove (assignmentExpression.Parent);
				} else {
					node = assignmentExpression;
					action = script => script.Replace (assignmentExpression, assignmentExpression.Left.Clone ());
				}
				AddIssue (node, ctx.TranslateString ("CS1717:Assignment made to same variable"),
					new [] { new CodeAction (ctx.TranslateString ("Remove assignment"), action) });
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:35,代码来源:AssignmentMadeToSameVariableIssue.cs

示例8: GetNewEqualityTestCode

		private static string GetNewEqualityTestCode(AssignmentExpression assignmentExpression)
		{
			RelationalOperation relationalOperation = new RelationalOperation(assignmentExpression.LeftSide.Clone() as Expression,
																												RelationalOperator.Equality,
																												assignmentExpression.RightSide.Clone() as Expression);
			string newEqualityTest = CodeRush.Language.GenerateElement(relationalOperation);
			return newEqualityTest;
		}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:8,代码来源:PlugIn1.cs

示例9: ArgumentsInfo

        public ArgumentsInfo(IEmitter emitter, AssignmentExpression assignmentExpression, OperatorResolveResult operatorResolveResult, IMethod method)
        {
            this.Emitter = emitter;
            this.Expression = assignmentExpression;
            this.OperatorResolveResult = operatorResolveResult;

            this.BuildOperatorArgumentsList(new Expression[] { assignmentExpression.Left, assignmentExpression.Right }, operatorResolveResult.UserDefinedOperatorMethod ?? method);
            this.BuildOperatorTypedArguments();
        }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:9,代码来源:ArgumentsInfo.cs

示例10: VisitAssignmentExpression

 public override void VisitAssignmentExpression(AssignmentExpression assignmentExpression)
 {
     // assignment is right-associative
     ParenthesizeIfRequired(assignmentExpression.Left, Assignment + 1);
     if (InsertParenthesesForReadability) {
         ParenthesizeIfRequired(assignmentExpression.Right, RelationalAndTypeTesting + 1);
     } else {
         ParenthesizeIfRequired(assignmentExpression.Right, Assignment);
     }
     base.VisitAssignmentExpression(assignmentExpression);
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:11,代码来源:InsertParenthesesVisitor.cs

示例11: VisitAssignmentExpression

            public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
            {
                var ns = assignmentExpression.GetCurrentNamespace();
                var variable = assignmentExpression.Left.GetIdentifier();
                var fullVariableName = ns + "." + variable;

                if(_codebaseDeclarations.Any(a => a.FullName == fullVariableName && a.DeclarationClassType == TypeDeclarationKind.Event) && assignmentExpression.Operator == AssignmentOperatorType.Add)
                {
                    UnlockWith(assignmentExpression);
                }

                return base.VisitAssignmentExpression(assignmentExpression, data);
            }
开发者ID:jonasswiatek,项目名称:strokes,代码行数:13,代码来源:SubscribeToEventAchievement.cs

示例12: VisitAssignmentExpression

 public override Expression VisitAssignmentExpression(AssignmentExpression assign) {
   AssignmentStatement stat = assign.AssignmentStatement as AssignmentStatement;
   if (stat != null) {
     stat.Target = this.VisitExpression(stat.Target);
     stat.Source = this.VisitExpression(stat.Source);
   }
   this.composers.Clear();
   if (stat != null) {
     this.composers.Add(this.GetComposer(stat.Target));
     this.composers.Add(this.GetComposer(stat.Source));
   }
   return (Expression) this.Compose(assign, this.composers);
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:13,代码来源:Partitioner.cs

示例13: EqualityInAssignment

		public void EqualityInAssignment()
		{
			Expression expr = new AssignmentExpression(
				new IdentifierExpression("cond"),
				new BinaryOperatorExpression(
					new IdentifierExpression("a"),
					BinaryOperatorType.Equality,
					new IdentifierExpression("b")
				)
			);
			
			Assert.AreEqual("cond = a == b", InsertRequired(expr));
			Assert.AreEqual("cond = (a == b)", InsertReadable(expr));
		}
开发者ID:qjlee,项目名称:ILSpy,代码行数:14,代码来源:InsertParenthesesVisitorTests.cs

示例14: VisitAssignmentExpression

            public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
            {
                if (assignmentExpression.Right is PrimitiveExpression)
                {
                    PrimitiveExpression prim = (PrimitiveExpression)assignmentExpression.Right;

                    int number;
                    if (int.TryParse(prim.LiteralValue, out number))
                    {
                        if (number == 666)
                            UnlockWith(assignmentExpression);
                    }
                }
                return base.VisitAssignmentExpression(assignmentExpression, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:15,代码来源:BeastNumberAchievement.cs

示例15: ConvertToInitializer

		public AssignmentExpression ConvertToInitializer(AssignmentExpression assignmentExpression, ref IList<AstNode> statements)
		{
			if (assignmentExpression == null)
				throw new ArgumentNullException("assignmentExpression");
			if (statements == null)
				throw new ArgumentNullException("statements");
			if (!(assignmentExpression.Right is ObjectCreateExpression))
				throw new ArgumentException("assignmentExpression.Right must be an ObjectCreateExpression", "assignmentExpression");

			Initialize(assignmentExpression.Left);
			accessPaths [mainAccessPath] = assignmentExpression.Right.Clone();

			Convert(statements);
			statements = ReplacementNodeHelper.GetReplacedNodes(accessPaths [mainAccessPath]);
			return new AssignmentExpression(new IdentifierExpression(mainAccessPath.RootName), accessPaths [mainAccessPath]);
		}
开发者ID:FloodProject,项目名称:ICSharpCode.NRefactory,代码行数:16,代码来源:StatementsToInitializerConverter.cs


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