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


C# CodeStatementCollection.RemoveAt方法代码示例

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


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

示例1: CorrectStatements

        private void CorrectStatements(string name, CodeStatementCollection stmts, CodeTypeReference returnType)
        {
            _name = name;
            _referenceCount = 0;
            new CodeDomWalker(stmts).Walk(RenameReturnValue);
            _name = null;

            CodeObjectSource source = Utils.GetTypeReferenceSource(returnType);
            Type type = (source == null ? null : source.Target as Type);
            CodeExpression defaultExpr = (type != null && type.IsPrimitive
                                              ? (CodeExpression) new CodeDefaultValueExpression(returnType)
                                              : new CodePrimitiveExpression(null));
            CodeExpression returnExpr = null;

            if (_referenceCount > 0)
            {
                bool requiresDeclaration = true;
                CodeAssignStatement assignStmt = stmts[stmts.Count - 1] as CodeAssignStatement;

                if (assignStmt != null)
                {
                    CodeVariableReferenceExpression variableStmt = assignStmt.Left as CodeVariableReferenceExpression;

                    if (variableStmt != null && StringUtils.CaseInsensitiveEquals(variableStmt.VariableName, _returnVariableName))
                    {
                        stmts.RemoveAt(stmts.Count - 1);
                        returnExpr = assignStmt.Right;
                        requiresDeclaration = (_referenceCount > 1);
                    }
                }

                if (requiresDeclaration)
                {
                    CodeExpression initExpression = null;
                    assignStmt = stmts[0] as CodeAssignStatement;

                    if (assignStmt != null)
                    {
                        CodeVariableReferenceExpression variableStmt = assignStmt.Left as CodeVariableReferenceExpression;

                        if (variableStmt != null && StringUtils.CaseInsensitiveEquals(variableStmt.VariableName, _returnVariableName))
                        {
                            stmts.RemoveAt(0);
                            initExpression = assignStmt.Right;
                        }
                    }

                    if (initExpression == null)
                    {
                        initExpression = defaultExpr;
                    }

                    stmts.Insert(
                        0,
                        new CodeVariableDeclarationStatement(
                            returnType,
                            _returnVariableName,
                            initExpression));
                }

                if (returnExpr == null)
                {
                    returnExpr = new CodeVariableReferenceExpression(_returnVariableName);
                }
            }
            else
            {
                returnExpr = defaultExpr;
            }

            stmts.Add(new CodeMethodReturnStatement(returnExpr));
        }
开发者ID:Saleslogix,项目名称:SLXMigration,代码行数:72,代码来源:ReturnValueCorrector.cs

示例2: ExtractCtorStatement

		private CodeStatement ExtractCtorStatement (CodeStatementCollection statements)
		{
			CodeStatement result = null;
			CodeAssignStatement assignment = null;
			int toRemove = -1;

			for (int i=0; i < statements.Count; i++) {
				assignment = statements[i] as CodeAssignStatement;
				if (assignment != null && assignment.Right is CodeObjectCreateExpression) {
					result = assignment;
					toRemove = i;
				}
			}

			if (toRemove != -1)
				statements.RemoveAt (toRemove);

			return result;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:19,代码来源:RootCodeDomSerializer.cs

示例3: ExtractCtorStatement

		// Used to remove the ctor from the statement colletion in order for the ctor statement to be moved.
		//
		private CodeStatement ExtractCtorStatement (IDesignerSerializationManager manager, CodeStatementCollection statements, 
													object component)
		{
			CodeStatement result = null;
			CodeAssignStatement assignment = null;
			CodeObjectCreateExpression ctor = null;
			int toRemove = -1;

			for (int i=0; i < statements.Count; i++) {
				assignment = statements[i] as CodeAssignStatement;
				if (assignment != null) {
					ctor = assignment.Right as CodeObjectCreateExpression;
					if (ctor != null && manager.GetType (ctor.CreateType.BaseType) == component.GetType ()) {
						result = assignment;
						toRemove = i;
					}
				}
			}

			if (toRemove != -1)
				statements.RemoveAt (toRemove);

			return result;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:26,代码来源:RootCodeDomSerializer.cs


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