Exemplo n.º 1
0
        /// <inheritdoc/>
        public ExternalImplementation Lookup(ImplementationSelection selection)
        {
            #region Sanity checks
            if (selection == null)
            {
                throw new ArgumentNullException(nameof(selection));
            }
            #endregion

            try
            {
                var referenceImpl = ExternalImplementation.FromID(selection.ID);

                // Reference implementation from ID does not contain all required information.
                // Therefore, find the original implementation.
                var implementation = GetImplementations(referenceImpl.Package)
                                     .First(x => x.Version == referenceImpl.Version &&
                                            x.Architecture == referenceImpl.Architecture);

                CopyValues(from: selection, to: implementation);
                return(implementation);
            }
            #region Error handling
            catch (FormatException)
            {
                throw new ImplementationNotFoundException(string.Format(Resources.UnknownPackageID, selection.ID, DistributionName));
            }
            catch (InvalidOperationException)
            {
                throw new ImplementationNotFoundException(string.Format(Resources.UnknownPackageID, selection.ID, DistributionName));
            }
            #endregion
        }
Exemplo n.º 2
0
 private static void CopyValues(Element from, ExternalImplementation to)
 {
     to.Commands.AddRange(from.Commands);
     to.Bindings.AddRange(from.Bindings);
 }