コード例 #1
0
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            if (element == null)
            {
                return;
            }

            IUsingList usingList = element.GetContainingNode(typeof(IUsingList), false) as IUsingList;

            if (usingList == null)
            {
                return;
            }

            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            // This violation will only run if there are some using statements and definately at least 1 namespace
            // so [0] index will always be OK.
            ICSharpNamespaceDeclaration firstNamespace = file.NamespaceDeclarations[0];

            foreach (IUsingDirective usingDirectiveNode in usingList.Imports)
            {
                firstNamespace.AddImportBefore(usingDirectiveNode, null);

                file.RemoveImport(usingDirectiveNode);
            }

            // Now sort the Usings into order.
            OrderUsingsBulbItem orderUsingsBulbItem = new OrderUsingsBulbItem();

            orderUsingsBulbItem.ExecuteTransactionInner(solution, textControl);
        }
コード例 #2
0
 private static IEnumerable <ITypeDeclaration> GetDeclarationsFromCSharpNamespace(ICSharpNamespaceDeclaration namespaceDeclaration)
 {
     foreach (var namespaceChild in namespaceDeclaration.Body.Children())
     {
         var classDeclaration = namespaceChild as IClassDeclaration;
         if (classDeclaration != null)
         {
             yield return(classDeclaration);
         }
         else
         {
             var childNamespace = namespaceChild as ICSharpNamespaceDeclaration;
             if (childNamespace != null)
             {
                 foreach (var declaration in GetDeclarationsFromCSharpNamespace(childNamespace))
                 {
                     yield return(declaration);
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: FileBase.cs プロジェクト: igor-toporet/TestFx
 public void RemoveNamespaceDeclaration(ICSharpNamespaceDeclaration param)
 {
     _file.RemoveNamespaceDeclaration(param);
 }
コード例 #4
0
ファイル: FileBase.cs プロジェクト: igor-toporet/TestFx
 public ICSharpNamespaceDeclaration AddNamespaceDeclarationAfter(ICSharpNamespaceDeclaration param, ICSharpNamespaceDeclaration anchor)
 {
     return(_file.AddNamespaceDeclarationAfter(param, anchor));
 }
コード例 #5
0
 public void RemoveNamespaceDeclaration(ICSharpNamespaceDeclaration param)
 {
     _file.RemoveNamespaceDeclaration(param);
 }
コード例 #6
0
 public ICSharpNamespaceDeclaration AddNamespaceDeclarationBefore(ICSharpNamespaceDeclaration param, ICSharpNamespaceDeclaration anchor)
 {
     return _file.AddNamespaceDeclarationBefore(param, anchor);
 }