예제 #1
0
        private static void GenerateMethod()
        {
            Method method = new Method();
            method.Name = "MyNewProc";
            method.MethodType = MethodTypeEnum.Void;
            Param newParam = new Param();
            TypeReferenceExpression newTypeReferenceExpression = new TypeReferenceExpression();
            newTypeReferenceExpression.Name = CodeRush.Language.GetSimpleTypeName("System.Int32");
            newParam.MemberTypeReference = newTypeReferenceExpression;
            newParam.Name = "MyKillerParameter";

            method.Parameters.Add(newParam);

            MethodCall statement = new MethodCall();
            statement.Name = "Start";
            //UnaryIncrement newUnaryIncrement = new UnaryIncrement();
            //ElementReferenceExpression elementReferenceExpression = new ElementReferenceExpression(newParam.Name);
            //newUnaryIncrement.Expression = elementReferenceExpression;
            //statement.AddDetailNode(newUnaryIncrement);
            //int MyKillerParameter = 0;
            //MyKillerParameter++;

            method.AddNode(statement);
            string newCode = CodeRush.Language.GenerateElement(method);
            TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
            if (activeTextDocument == null)
                return;

            activeTextDocument.InsertText(activeTextDocument.ActiveView.Caret.SourcePoint, newCode);
        }