/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="exclusion">An <see cref="PolicyExclusion"/> to compare.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> public override int CompareTo(PolicyExclusion exclusion) { WorkItemIdExclusion item = (WorkItemIdExclusion)exclusion; if (item != null) { return(this.WorkItemId.CompareTo(item.WorkItemId)); } return(-1); }
/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="exclusion">An <see cref="PolicyExclusion"/> to compare.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> public override int CompareTo(PolicyExclusion exclusion) { PathPolicyExclusion item = (PathPolicyExclusion)exclusion; if (item != null) { return(string.Compare(this.Path, item.Path, true, CultureInfo.CurrentCulture)); } return(-1); }
/// <summary> /// Initializes the analysis process. /// </summary> /// <param name="context">An <see cref="Context"/> containing contextual information for the analysis process.</param> /// <exception cref="System.ArgumentNullException"><paramref name="context"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception> public void Initialize(EvaluationContext context) { if (context == null) { ThrowHelper.ThrowArgumentNullException("context"); } this.cache = new Dictionary <string, Collection <Violation> >(); if (!string.IsNullOrEmpty(context.Settings.StyleCopSettings)) { // The policy has its own settings, write them to a temp file so they can be used. this.settingsFilePath = Path.GetTempFileName(); File.WriteAllText(this.settingsFilePath, context.Settings.StyleCopSettings); } this.exclusions = new Dictionary <PolicyExclusionType, Collection <PolicyExclusion> >(); if (context.Settings.Exclusions != null && context.Settings.Exclusions.Count > 0) { foreach (PolicyExclusionConfigInfo exclusionConfig in context.Settings.Exclusions) { Collection <PolicyExclusion> tempCollection = null; if (this.exclusions.ContainsKey(exclusionConfig.ExclusionType)) { tempCollection = this.exclusions[exclusionConfig.ExclusionType]; } else { tempCollection = new Collection <PolicyExclusion>(); this.exclusions.Add(exclusionConfig.ExclusionType, tempCollection); } PolicyExclusion exclusion = PolicyExclusionFactory.Instance.Create(exclusionConfig); if (exclusion != null) { tempCollection.Add(exclusion); } } } this.console = new StyleCopConsole(this.settingsFilePath, context.Settings); this.console.ViolationEncountered += new EventHandler <ViolationEventArgs>(this.ViolationEncounteredCallback); this.Context = context; }
/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="exclusion">An <see cref="PolicyExclusion"/> to compare.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> public override int CompareTo(PolicyExclusion exclusion) { int retval = 0; WorkItemFieldExclusion item = (WorkItemFieldExclusion)exclusion; if (item != null && item.FieldName != null) { retval = string.Compare(this.FieldName, item.FieldName, StringComparison.CurrentCulture); if (retval == 0) { retval = string.Compare(this.FieldValue, item.FieldValue, StringComparison.CurrentCulture); } } return(retval); }