예제 #1
0
 /// <summary>
 /// Applies <see cref="Binding"/>s to make a set of <see cref="Dependency"/>s available.
 /// </summary>
 /// <param name="dependencyContainer">The list of <see cref="Dependency"/>s to follow.</param>
 /// <param name="startInfo">The process launch environment to apply the <see cref="Binding"/>s to.</param>
 /// <exception cref="KeyNotFoundException"><see cref="Selections"/> contains <see cref="Dependency"/>s pointing to interfaces without selections.</exception>
 /// <exception cref="ImplementationNotFoundException">An <see cref="Implementation"/> is not cached yet.</exception>
 /// <exception cref="ExecutorException">A <see cref="Command"/> contained invalid data.</exception>
 /// <exception cref="IOException">A problem occurred while writing a file.</exception>
 /// <exception cref="UnauthorizedAccessException">Write access to a file is not permitted.</exception>
 private void ApplyDependencyBindings(IDependencyContainer dependencyContainer, ProcessStartInfo startInfo)
 {
     foreach (var dependency in dependencyContainer.Dependencies
              .Where(x => x.Importance == Importance.Essential || Selections.ContainsImplementation(x.InterfaceUri)))
     {
         ApplyBindings(dependency, Selections[dependency.InterfaceUri], startInfo);
     }
 }
예제 #2
0
        /// <summary>
        /// Shows a list of changes found by the update process.
        /// </summary>
        protected override ExitCode ShowOutput()
        {
            var builder = new StringBuilder();

            foreach (var oldImplementation in _oldSelections.Implementations)
            {
                var interfaceUri = oldImplementation.InterfaceUri;

                var newImplementation = Selections.GetImplementation(interfaceUri);
                if (newImplementation == null)
                { // Implementation removed
                    builder.AppendLine(Resources.NoLongerUsed + interfaceUri);
                }
                else if (oldImplementation.Version != newImplementation.Version)
                { // Implementation updated
                    builder.AppendLine(interfaceUri + ": " + oldImplementation.Version + " -> " + newImplementation.Version);
                }
            }
            foreach (var newImplementation in Selections.Implementations)
            {
                var interfaceUri = newImplementation.InterfaceUri;
                if (!_oldSelections.ContainsImplementation(interfaceUri))
                { // Implementation added
                    builder.AppendLine(interfaceUri + ": new -> " + newImplementation.Version);
                }
            }

            // Detect replaced feeds
            try
            {
                var feed = FeedCache.GetFeed(Requirements.InterfaceUri);
                if (feed.ReplacedBy != null)
                {
                    builder.AppendLine(string.Format(Resources.FeedReplaced, Requirements.InterfaceUri, feed.ReplacedBy.Target));
                }
            }
            catch (KeyNotFoundException)
            {
            }

            if (builder.Length == 0)
            {
                Handler.OutputLow(Resources.NoUpdatesFound, Resources.NoUpdatesFound);
                return(ExitCode.NoChanges);
            }
            else
            {
                Handler.Output(Resources.ChangesFound, builder.ToString());
                return(ExitCode.OK);
            }
        }
예제 #3
0
    /// <inheritdoc/>
    public IEnumerable <SelectionsDiffNode> GetDiff(Selections oldSelections, Selections newSelections)
    {
        #region Sanity checks
        if (oldSelections == null)
        {
            throw new ArgumentNullException(nameof(oldSelections));
        }
        if (newSelections == null)
        {
            throw new ArgumentNullException(nameof(newSelections));
        }
        #endregion

        foreach (var newImplementation in newSelections.Implementations)
        {
            var interfaceUri = newImplementation.InterfaceUri;
            if (!oldSelections.ContainsImplementation(interfaceUri))
            { // Implementation added
                yield return(new(interfaceUri, newVersion : newImplementation.Version));
            }
        }

        foreach (var oldImplementation in oldSelections.Implementations)
        {
            var interfaceUri = oldImplementation.InterfaceUri;

            var newImplementation = newSelections.GetImplementation(interfaceUri);
            if (newImplementation == null)
            { // Implementation removed
                yield return(new(interfaceUri, oldVersion : oldImplementation.Version));
            }
            else if (oldImplementation.Version != newImplementation.Version)
            { // Implementation updated
                yield return(new(interfaceUri, oldVersion : oldImplementation.Version, newVersion : newImplementation.Version));
            }
        }
    }