Example #1
0
        /// <inheritdoc/>
        public ExternalImplementation Lookup(ImplementationSelection selection)
        {
            #region Sanity checks
            if (selection == null)
            {
                throw new ArgumentNullException("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
        }
Example #2
0
 private static void CopyValues(Element from, ExternalImplementation to)
 {
     to.Commands.AddRange(from.Commands);
     to.Bindings.AddRange(from.Bindings);
 }