Exemple #1
0
        /// <summary>
        /// Translates the ResourceImpactEnum for a single resource type into ImpactCategory,
        /// based on configuration or DefaultResourceImpactMap.
        /// </summary>
        private ImpactCategory TranslateResourceImpactToCategory(
            string resourceType,
            ResourceImpactEnum impact)
        {
            // Look up the default category in the map
            ImpactCategory defaultCategory;

            if (!DefaultResourceImpactMap.TryGetValue(GetDefaultResourceImpactMapKey(resourceType, impact), out defaultCategory))
            {
                // The default map is expected to contain a mapping for Unknown; fall back to that
                defaultCategory = DefaultResourceImpactMap[GetDefaultResourceImpactMapKey(resourceType, ResourceImpactEnum.Unknown)];
            }

            string configKey = String.Format(CultureInfo.InvariantCulture, ConfigKeyFormatResourceImpactMap, resourceType, impact);

            return(this.configSection.ReadConfigValue(configKey, defaultCategory));
        }
Exemple #2
0
        /// <summary>
        /// Escalates the impact category based on the impact to a particular resource type.
        /// </summary>
        /// <param name="oldCategory">The current impact category.</param>
        /// <param name="resourceType">The resource type name.</param>
        /// <param name="impact">The impact to the given resource.</param>
        /// <returns>The new impact category.</returns>
        private ImpactCategory ApplyResourceImpact(
            ImpactCategory oldCategory,
            string resourceType,
            ResourceImpactEnum impact)
        {
            ImpactCategory newCategory = TranslateResourceImpactToCategory(resourceType, impact);

            newCategory = EscalateImpactCategory(oldCategory, newCategory);

            if (oldCategory != newCategory)
            {
                Tracer.WriteNoise(
                    "Overall impact changed from {0} to {1} due to resource impact {2}={3}",
                    oldCategory,
                    newCategory,
                    resourceType,
                    impact);
            }

            return(newCategory);
        }
Exemple #3
0
 /// <summary>
 /// Gets the key used for lookups in DefaultResourceImpactMap.
 /// </summary>
 private static string GetDefaultResourceImpactMapKey(string resourceType, ResourceImpactEnum impact)
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", resourceType, impact));
 }