Exemplo n.º 1
0
        /// <summary>
        /// Update the view model's raw set of code items based on the specified code items.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        private void UpdateViewModelRawCodeItems(SetCodeItems codeItems)
        {
            // Create a copy of the original collection, filtering out undesired items.
            var filteredCodeItems = new SetCodeItems(
                codeItems.Where(x => !(x is CodeItemUsingStatement || x is CodeItemNamespace)));

            _viewModel.RawCodeItems = filteredCodeItems;
            _viewModel.IsLoading    = false;
            _viewModel.IsRefreshing = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Organizes the specified code items by alpha sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByAlphaSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by name recursively.
                RecursivelySort(organizedCodeItems, new CodeItemNameComparer());
            }

            return(organizedCodeItems);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Organizes the specified code items by alpha sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByAlphaSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by name recursively.
                RecursivelySort(organizedCodeItems, new CodeItemNameComparer());
            }

            return organizedCodeItems;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update the view model's raw set of code items based on the specified code items.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        private void UpdateViewModelRawCodeItems(SetCodeItems codeItems)
        {
            // Create a copy of the original collection, filtering out undesired items.
            var filteredCodeItems = new SetCodeItems(
                codeItems.Where(x => !(x is CodeItemUsingStatement || x is CodeItemNamespace)));

            _viewModel.RawCodeItems = filteredCodeItems;
            _viewModel.IsLoading    = false;
            _viewModel.IsRefreshing = false;

            ////接口代码同步
            //if (Settings.Default.Digging_SynchronizeRealize&&filteredCodeItems[0].Kind==KindCodeItem.Class&&filteredCodeItems[0].Name.EndsWith("Service"))
            //{
            //    #region 接口同步代码实现
            //    //ITextTemplating vst4 = GetService(typeof(STextTemplating)) as ITextTemplating;
            //    //ITextTemplatingSessionHost host = vst4 as ITextTemplatingSessionHost;

            //    //host.Session = host.CreateSession();
            //    //host.Session["parameter1"] = "接口模板的实现:";
            //    //host.Session["parameter2"] = DateTime.Now;
            //    //string input = System.IO.File.ReadAllText("Interface.tt");
            //    //string output = vst4.ProcessTemplate("", input);
            //    System.Threading.Tasks.Task.Run(()=>{
            //            if (Package.ActiveDocument!=null)
            //            {
            //                ProjectItem curItem = Package.ActiveDocument.ProjectItem;
            //                if (curItem == null)
            //                {
            //                    return;
            //                }
            //                string strInterName = "I"+curItem.Name;
            //                //var s = curItem.ContainingProject.ProjectItems.Cast<ProjectItem>().ToList();
            //                if (!curItem.ContainingProject.ProjectItems.IsExists(strInterName))
            //                {
            //                    Solution3 sln = curItem.DTE.Solution as Solution3;
            //                    string strInterTemplateItemPath = sln.GetProjectItemTemplate("Interface.zip", "CSharp");
            //                    curItem.ProjectItems.AddFromTemplate(strInterTemplateItemPath,  strInterName);
            //                }
            //                addInterface(curItem);
            //            }
            //    });
            //    #endregion
            //}
        }
Exemplo n.º 5
0
        /// <summary>
        /// Organizes the specified code items by type sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByTypeSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by type recursively.
                RecursivelySort(organizedCodeItems, new CodeItemTypeComparer());

                // Group the list of code items by type recursively.
                foreach (var codeItem in organizedCodeItems.OfType <ICodeItemParent>())
                {
                    RecursivelyGroupByType(codeItem);
                }
            }

            return(organizedCodeItems);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Organizes the specified code items by type sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByTypeSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by type recursively.
                RecursivelySort(organizedCodeItems, new CodeItemTypeComparer());

                // Group the list of code items by type recursively.
                foreach (var codeItem in organizedCodeItems.OfType<ICodeItemParent>())
                {
                    RecursivelyGroupByType(codeItem);
                }
            }

            return organizedCodeItems;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Update the view model's raw set of code items based on the specified code items.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        private void UpdateViewModelRawCodeItems(SetCodeItems codeItems)
        {
            // Create a copy of the original collection, filtering out undesired items.
            var filteredCodeItems = new SetCodeItems(
                codeItems.Where(x => !(x is CodeItemUsingStatement || x is CodeItemNamespace)));

            _viewModel.RawCodeItems = filteredCodeItems;
            _viewModel.IsLoading = false;
            _viewModel.IsRefreshing = false;
        }