private async Task OnProjectChangedAsync(
            IProjectSubscriptionUpdate projectUpdate,
            IProjectCatalogSnapshot catalogSnapshot,
            IProjectCapabilitiesSnapshot capabilities,
            ConfiguredProject configuredProject,
            RuleSource source)
        {
            if (IsDisposing || IsDisposed)
            {
                return;
            }

            // Ensure updates don't overlap and that we aren't disposed during the update without cleaning up properly
            await ExecuteUnderLockAsync(async token =>
            {
                // Ensure the project doesn't unload during the update
                await _tasksService.LoadedProjectAsync(async() =>
                {
                    // TODO pass _tasksService.UnloadCancellationToken into HandleAsync to reduce redundant work on unload

                    // Ensure the project's capabilities don't change during the update
                    using (ProjectCapabilitiesContext.CreateIsolatedContext(configuredProject, capabilities))
                    {
                        await HandleAsync(projectUpdate, catalogSnapshot, source);
                    }
                });
            });
        }
        private async Task HandleAsync(
            IProjectSubscriptionUpdate projectUpdate,
            IProjectCatalogSnapshot catalogSnapshot,
            RuleSource source)
        {
            AggregateCrossTargetProjectContext?currentAggregateContext = await _host !.GetCurrentAggregateProjectContextAsync();

            if (currentAggregateContext == null || _currentProjectContext != currentAggregateContext)
            {
                return;
            }

            // Get the inner workspace project context to update for this change.
            ITargetFramework?targetFrameworkToUpdate = currentAggregateContext.GetProjectFramework(projectUpdate.ProjectConfiguration);

            if (targetFrameworkToUpdate == null)
            {
                return;
            }

            // Broken design time builds sometimes cause updates with no project changes and sometimes
            // cause updates with a project change that has no difference.
            // We handle the former case here, and the latter case is handled in the CommandLineItemHandler.
            if (projectUpdate.ProjectChanges.Count == 0)
            {
                return;
            }

            if (!projectUpdate.ProjectChanges.Any(x => x.Value.Difference.AnyChanges))
            {
                return;
            }

            // Create an object to track dependency changes.
            var changesBuilder = new CrossTargetDependenciesChangesBuilder();

            // Give each handler a chance to register dependency changes.
            foreach (Lazy <IDependenciesRuleHandler, IOrderPrecedenceMetadataView> handler in _handlers)
            {
                handler.Value.Handle(projectUpdate.ProjectChanges, targetFrameworkToUpdate, changesBuilder);
            }

            ImmutableDictionary <ITargetFramework, IDependenciesChanges>?changes = changesBuilder.TryBuildChanges();

            if (changes != null)
            {
                // Notify subscribers of a change in dependency data
                DependenciesChanged?.Invoke(
                    this,
                    new DependencySubscriptionChangedEventArgs(
                        currentAggregateContext.TargetFrameworks,
                        currentAggregateContext.ActiveTargetFramework,
                        catalogSnapshot,
                        changes));
            }

            // record all the rules that have occurred
            _treeTelemetryService.ObserveTargetFrameworkRules(targetFrameworkToUpdate, projectUpdate.ProjectChanges.Keys);
        }
 public EquipmentItemData(string name, string category, double weight, int?averagePrice, RuleSource source)
 {
     _name         = name;
     _category     = category;
     _weight       = weight;
     _averagePrice = averagePrice;
     _source       = source;
 }
Exemplo n.º 4
0
 public SkillData(string name, bool specifiable, IList <string> specifictions, bool combatSkill, SkillType type, IList <SkillBonus> skillBonuses, RuleSource source)
 {
     Name          = name;
     Specifiable   = specifiable;
     Specifictions = specifictions;
     CombatSkill   = combatSkill;
     Type          = type;
     SkillBonuses  = skillBonuses;
     Source        = source;
 }
Exemplo n.º 5
0
        public AmmoData(string name, string category, double weight, int?averagePrice, RuleSource source, int?neededStrength, int attack, int damage, string damageType, int range)
        {
            _name         = name;
            _category     = category;
            _weight       = weight;
            _averagePrice = averagePrice;
            _source       = source;

            _neededStrength = neededStrength;
            _attack         = attack;
            _damage         = damage;
            _damageType     = damageType;
            _range          = range;
        }
Exemplo n.º 6
0
        public ArmorData(string name, string category, double weight, int?averagePrice, RuleSource source,
                         int?neededStrength, int restriction, int protection, bool isHelmet)
        {
            _name         = name;
            _category     = category;
            _weight       = weight;
            _averagePrice = averagePrice;
            _source       = source;

            _neededStrength = neededStrength;
            _restriction    = restriction;
            _protection     = protection;
            _isHelmet       = isHelmet;
        }
        private IReadOnlyCollection <string> GetRuleNames(RuleSource source)
        {
            var rules = new HashSet <string>(StringComparers.RuleNames);

            foreach (Lazy <IDependenciesRuleHandler, IOrderPrecedenceMetadataView> item in _handlers)
            {
                rules.Add(item.Value.EvaluatedRuleName);

                if (source == RuleSource.Joint)
                {
                    rules.Add(item.Value.ResolvedRuleName);
                }
            }

            return(rules);
        }
Exemplo n.º 8
0
        public ShieldData(string name, string category, double weight, int?averagePrice, RuleSource source,
                          string weaponCategory, int?neededStrength, int attack, int damage, string damageType, int block, int?restriction)
        {
            _name         = name;
            _category     = category;
            _weight       = weight;
            _averagePrice = averagePrice;
            _source       = source;

            _weaponCategory = weaponCategory;
            _neededStrength = neededStrength;
            _attack         = attack;
            _damage         = damage;
            _damageType     = damageType;
            _block          = block;
            _restriction    = restriction;
        }
        public MeleeWeaponData(string name, string category, double weight, int?averagePrice, RuleSource source,
                               string weaponCategory, int?neededStrength, int?length, int attack, int damage, string damageType, int block, bool isTwoHanded)
        {
            _name         = name;
            _category     = category;
            _weight       = weight;
            _averagePrice = averagePrice;
            _source       = source;

            _weaponCategory = weaponCategory;
            _neededStrength = neededStrength;
            _length         = length;
            _attack         = attack;
            _damage         = damage;
            _damageType     = damageType;
            _block          = block;
            _isTwoHanded    = isTwoHanded;
        }
Exemplo n.º 10
0
 public ValidationRule(RuleSource ruleSource)
 {
     RuleSource = ruleSource;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Create a New Validation Builder for Rules from a Specific Source.
 /// </summary>
 /// <param name="ruleSource">The Source of the Rules.</param>
 public ValidationBuilder(RuleSource ruleSource)
 {
     RuleSource = ruleSource;
 }