private void HandleRemovedTanks(IXQueryable[] removedTanks)
        {
            foreach (var tank in removedTanks)
            {
                var item = new RemovedItem(PatchnoteGeneratorDocumenVM.GetTankName(tank), tank);
                item.ItemName.AddModifier(this.GetTankTypeModifier(tank));
                _removedTanks.Add(item);

                ++_processedTankTaskCount;
                this.GenerationProgress = (double)_processedTankTaskCount / _tankTaskCount;
            }
        }
        private IEnumerable <ItemName> AnalyseModuleCollectionCollisionChanges(IXQueryable oldTank, IXQueryable newTank, string xpath, string moduleName)
        {
            var oldModules = oldTank.QueryMany(xpath).Distinct(KeyEqualityComparer <IXQueryable> .Instance);
            var newModules = newTank.QueryMany(xpath).Distinct(KeyEqualityComparer <IXQueryable> .Instance);

            foreach (var sharedItem in oldModules.Diff(newModules, KeyEqualityComparer <IXQueryable> .Instance).Shared)
            {
                if (!this.ModelFileEquals(sharedItem.Source, sharedItem.Target, "hitTester/collisionModel"))
                {
                    var name = new ItemName(PatchnoteGeneratorDocumenVM.GetTankName(sharedItem.Source));
                    name.AddModifier(new TypeModifier(moduleName));
                    yield return(name);
                }
            }
        }
        public ICreateDocumentTask CreateCreateDocumentTask(Uri uri, Guid guid, string persistentInfo)
        {
            var targetRepositoryId = uri.LocalPath;
            var refMatch           = Regex.Match(uri.Query, @"\?ref\=(.+)");

            if (!refMatch.Success)
            {
                this.LogWarning("invalid patchnote Uri format: {0}", uri);
                return(null);
            }

            var referenceRepositoryId = Uri.UnescapeDataString(refMatch.Groups[1].Value);

            var targetRepository = RepositoryManager.Instance[targetRepositoryId];

            if (targetRepository == null)
            {
                this.LogWarning("invalid target repository: {0}", targetRepositoryId);
                return(null);
            }

            var referenceRepository = RepositoryManager.Instance[referenceRepositoryId];

            if (referenceRepository == null)
            {
                this.LogWarning("invalid reference repository: {0}", referenceRepositoryId);
                return(null);
            }

            return(CreateDocumentTask.FromFactory(() =>
            {
                var view = new PatchnoteGeneratorDocumentView();
                var vm = new PatchnoteGeneratorDocumenVM(view.CommandBindings, targetRepository, referenceRepository, persistentInfo);
                view.ViewModel = vm;

                var docInfo = new DocumentInfo(guid: guid,
                                               repositoryId: targetRepositoryId,
                                               uri: uri,
                                               title: this.L("patchnote_generator", "document_title"),
                                               content: view,
                                               persistentInfoProvider: vm.PersistentInfo);

                return docInfo;
            }));
        }
        private void AnalyseCollisionChanges(IXQueryable oldTank, IXQueryable newTank)
        {
            var changedParts = new List <ItemName>();

            if (!this.ModelFileEquals(oldTank, newTank, "hull/hitTester/collisionModel"))
            {
                changedParts.Add(new ItemName("hull", false));
            }

            changedParts.AddRange(this.AnalyseModuleCollectionCollisionChanges(oldTank, newTank, "chassis/chassis", "chassis"));
            changedParts.AddRange(this.AnalyseModuleCollectionCollisionChanges(oldTank, newTank, "turrets/turret", "turret"));
            changedParts.AddRange(this.AnalyseModuleCollectionCollisionChanges(oldTank, newTank, "turrets/turret/guns/gun", "gun"));

            if (changedParts.Count > 0)
            {
                _potentialCollisionChanges.Add(new PotentialModelChangedItem(PatchnoteGeneratorDocumenVM.GetTankName(oldTank), changedParts.ToArray()));
            }
        }
        private void HandleSharedTanks(SharedPair <IXQueryable>[] sharedTanks)
        {
            foreach (var sharedTank in sharedTanks)
            {
                _statChanges.AddIfNotNull(TankDataItemHandler.Instance.CreateReportItem(PatchnoteGeneratorDocumenVM.GetTankName(sharedTank.Source),
                                                                                        sharedTank.Source,
                                                                                        sharedTank.Target,
                                                                                        false,
                                                                                        false,
                                                                                        false));
                if (_checkPotentialCollisionChanges)
                {
                    this.AnalyseCollisionChanges(sharedTank.Source, sharedTank.Target);
                }

                ++_processedTankTaskCount;
                this.GenerationProgress = (double)_processedTankTaskCount / _tankTaskCount;
            }
        }