Exemple #1
0
        /// <summary>
        /// Returns all <see cref="ConflictData"/>s for a set of new <see cref="AccessPoint"/> candidates.
        /// </summary>
        /// <param name="accessPoints">The set of <see cref="AccessPoint"/>s candidates to build the list for.</param>
        /// <param name="appEntry">The <see cref="AppEntry"/> the <paramref name="accessPoints"/> are intended for.</param>
        /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns>
        /// <exception cref="ConflictException">There are inner conflicts within <paramref name="accessPoints"/>.</exception>
        /// <seealso cref="AccessPoint.GetConflictIDs"/>
        public static IDictionary <string, ConflictData> GetConflictData(this IEnumerable <AccessPoint> accessPoints, AppEntry appEntry)
        {
            #region Sanity checks
            if (accessPoints == null)
            {
                throw new ArgumentNullException(nameof(accessPoints));
            }
            if (appEntry == null)
            {
                throw new ArgumentNullException(nameof(appEntry));
            }
            #endregion

            var newConflictIDs = new Dictionary <string, ConflictData>();
            foreach (var accessPoint in accessPoints)
            {
                foreach (string conflictID in accessPoint.GetConflictIDs(appEntry))
                {
                    var conflictData = new ConflictData(accessPoint, appEntry);
                    try
                    {
                        newConflictIDs.Add(conflictID, conflictData);
                    }
                    #region Error handling
                    catch (ArgumentException)
                    {
                        throw ConflictException.InnerConflict(conflictData, newConflictIDs[conflictID]);
                    }
                    #endregion
                }
            }
            return(newConflictIDs);
        }
Exemple #2
0
        /// <summary>
        /// Checks new <see cref="AccessPoint"/> candidates for conflicts with existing ones.
        /// </summary>
        /// <param name="appList">The <see cref="AppList"/> containing the existing <see cref="AccessPoint"/>s.</param>
        /// <param name="accessPoints">The set of <see cref="AccessPoint"/>s candidates to check.</param>
        /// <param name="appEntry">The <see cref="AppEntry"/> the <paramref name="accessPoints"/> are intended for.</param>
        /// <exception cref="KeyNotFoundException">An <see cref="AccessPoint"/> reference to a <see cref="Store.Model.Capabilities.Capability"/> is invalid.</exception>
        /// <exception cref="ConflictException">One or more of the <paramref name="accessPoints"/> would cause a conflict with the existing <see cref="AccessPoint"/>s in <see cref="AppList"/>.</exception>
        public static void CheckForConflicts([NotNull] this AppList appList, [NotNull, ItemNotNull, InstantHandle] IEnumerable <AccessPoint> accessPoints, [NotNull] AppEntry appEntry)
        {
            #region Sanity checks
            if (appList == null)
            {
                throw new ArgumentNullException(nameof(appList));
            }
            if (accessPoints == null)
            {
                throw new ArgumentNullException(nameof(accessPoints));
            }
            if (appEntry == null)
            {
                throw new ArgumentNullException(nameof(appEntry));
            }
            #endregion

            var newConflictData      = accessPoints.GetConflictData(appEntry);
            var existingConflictData = appList.Entries.GetConflictData();

            foreach (var pair in newConflictData)
            {
                ConflictData existingEntry, newEntry = pair.Value;
                if (existingConflictData.TryGetValue(pair.Key, out existingEntry))
                {
                    // Ignore conflicts that are actually just re-applications of existing access points
                    if (existingEntry != newEntry)
                    {
                        throw ConflictException.NewConflict(existingEntry, newEntry);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Creates an exception indicating a new desktop integration conflict.
        /// </summary>
        /// <param name="existingEntry">The existing entry that is preventing <paramref name="newEntry"/> from being applied.</param>
        /// <param name="newEntry">The new entry that is in conflict with <paramref name="existingEntry"/>.</param>
        public static ConflictException NewConflict(ConflictData existingEntry, ConflictData newEntry)
        {
            string message = string.Format(Resources.AccessPointNewConflict, existingEntry, newEntry);

            return(new ConflictException(message)
            {
                Entries = new[] { existingEntry, newEntry }
            });
        }
Exemple #4
0
        /// <summary>
        /// Returns all <see cref="ConflictData"/>s for a set of existing <see cref="AppEntry"/>s.
        /// </summary>
        /// <param name="appEntries">The <see cref="AppEntry"/>s to build the list for.</param>
        /// <returns>A dictionary of <see cref="AccessPoint.GetConflictIDs"/> mapping to the according <see cref="ConflictData"/>.</returns>
        /// <exception cref="ConflictException">There are preexisting conflicts within <paramref name="appEntries"/>.</exception>
        /// <seealso cref="AccessPoint.GetConflictIDs"/>
        public static IDictionary <string, ConflictData> GetConflictData(this IEnumerable <AppEntry> appEntries)
        {
            #region Sanity checks
            if (appEntries == null)
            {
                throw new ArgumentNullException(nameof(appEntries));
            }
            #endregion

            var conflictIDs = new Dictionary <string, ConflictData>();
            foreach (var appEntry in appEntries)
            {
                if (appEntry.AccessPoints == null)
                {
                    continue;
                }
                foreach (var accessPoint in appEntry.AccessPoints.Entries)
                {
                    foreach (string conflictID in accessPoint.GetConflictIDs(appEntry))
                    {
                        var conflictData = new ConflictData(accessPoint, appEntry);
                        try
                        {
                            conflictIDs.Add(conflictID, conflictData);
                        }
                        #region Error handling
                        catch (ArgumentException)
                        {
                            throw ConflictException.ExistingConflict(conflictIDs[conflictID], conflictData);
                        }
                        #endregion
                    }
                }
            }
            return(conflictIDs);
        }