예제 #1
0
        private void CreateChildren(object state)
        {
            IGraphContext context = (IGraphContext)state;

            using (GraphTransactionScope scope = new GraphTransactionScope())
            {
                foreach (var node in context.InputNodes.Where(n => n.HasCategory(CssGraphSchema.CssAtDirectivesParent)))
                {
                    CreateChild <AtDirective>(context, node, CssGraphSchema.CssAtDirectives);
                    context.ReportProgress(1, 3, null);
                }

                foreach (var node in context.InputNodes.Where(n => n.HasCategory(CssGraphSchema.CssIdSelectorParent)))
                {
                    CreateChild <IdSelector>(context, node, CssGraphSchema.CssIdSelector);
                    context.ReportProgress(2, 3, null);
                }

                foreach (var node in context.InputNodes.Where(n => n.HasCategory(CssGraphSchema.CssClassSelectorParent)))
                {
                    CreateChild <ClassSelector>(context, node, CssGraphSchema.CssClassSelector);
                    context.ReportProgress(3, 3, null);
                }

                scope.Complete();
            }

            context.OnCompleted();
        }
예제 #2
0
        private void CreateChildren(object state)
        {
            IGraphContext context = (IGraphContext)state;

            using (GraphTransactionScope scope = new GraphTransactionScope())
            {
                foreach (var node in context.InputNodes.Where(n => n.HasCategory(LessGraphSchema.LessMixinParent)))
                {
                    CreateChild <LessMixinDeclaration>(context, node, LessGraphSchema.LessMixin);
                    context.ReportProgress(1, 2, null);
                }

                foreach (var node in context.InputNodes.Where(n => n.HasCategory(LessGraphSchema.LessVariableParent)))
                {
                    CreateChild <LessVariableDeclaration>(context, node, LessGraphSchema.LessVariable);
                    context.ReportProgress(2, 2, null);
                }

                scope.Complete();
            }

            context.OnCompleted();
        }
        private void AddPackageNodes(IGraphContext context, Func <GraphNode> parentNode, IEnumerable <IVsPackageMetadata> installedPackages, bool removeUninstalledNodes = true)
        {
            var allPackages  = installedPackages.ToList();
            var installedIds = new HashSet <Tuple <string, string> >(allPackages.Select(x => Tuple.Create(x.Id, x.VersionString)));

            if (removeUninstalledNodes)
            {
                // Remove nodes that aren't installed anymore.
                var toRemove = from node in context.OutputNodes
                               where node.IsPackageNode()
                               let installed = node.GetValue <IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty)
                                               where installed != null && !installedIds.Contains(Tuple.Create(installed.Id, installed.VersionString))
                                               select node;

                if (toRemove.Any())
                {
                    using (var scope = new GraphTransactionScope())
                    {
                        toRemove.ToList().ForEach(node => node.Remove());
                        scope.Complete();
                    }
                }
            }

            var progress = 0;
            var count    = allPackages.Count;

            foreach (var nugetPackage in allPackages)
            {
                var node = GetOrCreatePackageNode(context, parentNode(), nugetPackage);
                context.ReportProgress(++progress, count, null);

                if (context.CancelToken.IsCancellationRequested)
                {
                    break;
                }

                context.CancelToken.ThrowIfCancellationRequested();
                System.Threading.Thread.Sleep(100);
            }
        }
        private void AddPackageNodes(IGraphContext context, Func <GraphNode> parentNode, IEnumerable <PaketMetadata> installedPackages)
        {
            var allPackages = installedPackages.ToList();

            for (int index = 0; index < allPackages.Count; index++)
            {
                PaketMetadata paketMetadata = allPackages[index];

                using (var scope = new GraphTransactionScope())
                {
                    CreateNode(context, parentNode(), paketMetadata);
                    scope.Complete();
                }

                context.ReportProgress(index, allPackages.Count, null);

                if (context.CancelToken.IsCancellationRequested)
                {
                    break;
                }
            }
        }
예제 #5
0
 public void ReportProgress(int current, int maximum)
 => _context.ReportProgress(current, maximum, null);