コード例 #1
0
        protected override async Task ApplyAsync(IProjectVersionedValue <ImmutableList <string> > value)
        {
            await JoinableFactory.SwitchToMainThreadAsync();

            IProjectVersionedValue <ImmutableList <string> >?previous = AppliedValue;

            AppliedValue = value;

            // To avoid callers seeing an inconsistent state where there are no Imports,
            // we use BlockInitializeOnFirstAppliedValue to block on the first value
            // being applied.
            //
            // Due to that, and to avoid a deadlock when event handlers call back into us
            // while we're still initializing, we avoid firing the events the first time
            // a value is applied.
            if (previous != null)
            {
                VisualBasicVSImports   imports       = VSImports.Value;
                ImmutableList <string> currentValue  = value.Value;
                ImmutableList <string> previousValue = previous.Value;

                foreach (string import in previousValue.Except(currentValue))
                {
                    imports.OnImportRemoved(import);
                }

                foreach (string import in currentValue.Except(previousValue))
                {
                    imports.OnImportAdded(import);
                }
            }
        }
        protected override async Task ApplyAsync(IProjectVersionedValue <ImmutableList <string> > value)
        {
            await JoinableFactory.SwitchToMainThreadAsync();

            ImmutableList <string> current = AppliedValue?.Value ?? ImmutableList <string> .Empty;
            ImmutableList <string> input   = value.Value;

            IEnumerable <string> removed = current.Except(input);
            IEnumerable <string> added   = input.Except(current);

            AppliedValue = value;

            VisualBasicVSImports?imports = VSImports?.Value;

            if (imports != null)
            {
                foreach (string import in removed)
                {
                    imports.OnImportRemoved(import);
                }

                foreach (string import in added)
                {
                    imports.OnImportAdded(import);
                }
            }
        }
コード例 #3
0
        public void LearnColorFor(CardColor proposedColor, IEnumerable <ushort> cardIndexes)
        {
            cardIndexes = cardIndexes.ToList();
            //save actual color for cards with given indexes
            foreach (var cardIndex in cardIndexes)
            {
                _colorKnowledges[cardIndex][proposedColor] = true;
                foreach (var otherColor in CardUtils.CardColors.Except(new[] { proposedColor }))
                {
                    _colorKnowledges[cardIndex][otherColor] = false;
                }
            }

            //now we know that other card's colors are not such
            foreach (var otherCardIndex in AllCardIndexes.Except(cardIndexes))
            {
                _colorKnowledges[otherCardIndex][proposedColor] = false;
            }
        }
コード例 #4
0
ファイル: ItemCollection.cs プロジェクト: zcf7822/monodevelop
        public void SetItems(IEnumerable <T> items)
        {
            AssertCanWrite();
            items = ReuseExistingItems(items);
            var newItems     = items.Except(list);
            var removedItems = list.Except(items);

            list = ImmutableList <T> .Empty.AddRange(items);

            if (newItems.Any())
            {
                OnItemsAdded(newItems);
            }
            if (removedItems.Any())
            {
                OnItemsRemoved(removedItems);
            }
        }
コード例 #5
0
        private async System.Threading.Tasks.Task <ImmutableList <string> > PruneUpstream(GitRef original, ImmutableList <GitRef> allUpstream, ImmutableList <BranchGroup> configured, ImmutableList <GitRef> allRemotes)
        {
            var configuredLatest = configured.ToDictionary(branch => branch.GroupName, branch => branchIteration.GetLatestBranchNameIteration(branch.GroupName, allRemotes.Select(b => b.Name)));

            allUpstream = allUpstream.Where(maybeHasNewer =>
                                            !configured.Any(c => branchIteration.IsBranchIteration(c.GroupName, maybeHasNewer.Name) && maybeHasNewer.Name != configuredLatest[c.GroupName])
                                            ).ToImmutableList();

            for (var i = 0; i < allUpstream.Count; i++)
            {
                var upstream        = allUpstream[i];
                var isConfigured    = configuredLatest.Values.Contains(upstream.Name);
                var furtherUpstream = (from branchGroup in (await branchSettings.GetAllUpstreamBranches(upstream.Name).FirstOrDefaultAsync())
                                       let latest = configuredLatest[branchGroup.GroupName]
                                                    where allRemotes.Find(b => b.Name == latest).Commit != upstream.Commit
                                                    select latest)
                                      .ToImmutableHashSet();
                var oldLength = allUpstream.Count;
                allUpstream = allUpstream.Where(maybeMatch => !furtherUpstream.Contains(maybeMatch.Name)).ToImmutableList();
                if (oldLength != allUpstream.Count)
                {
                    i = -1;
                }
            }

            // TODO - this could be much smarter
            for (var i = 0; i < allUpstream.Count; i++)
            {
                var upstream        = allUpstream[i];
                var furtherUpstream = await repositoryState.DetectUpstream(upstream.Name, false);

                if (allUpstream.Intersect(furtherUpstream).Any())
                {
                    allUpstream = allUpstream.Except(furtherUpstream).ToImmutableList();
                    i           = -1;
                }
            }

            return(allUpstream.Select(b => b.Name).ToImmutableList());
        }
コード例 #6
0
 public Hand RemoveCard(Card card)
 {
     return(new Hand(_cards.Except(new[] { card })));
 }