Beispiel #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)
                                 .FirstOrDefault(x => x.Version == referenceImpl.Version &&
                                                 x.Architecture == referenceImpl.Architecture);

            if (implementation != null)
            {
                CopyValues(from: selection, to: implementation);
            }

            return(implementation);
        }
        catch (FormatException)
        {
            return(null);
        }
    }
    /// <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
    }