/// <summary>
        /// Determines the local path of an implementation.
        /// </summary>
        /// <param name="implementationStore">The store to get the implementation from.</param>
        /// <param name="implementation">The implementation to be located.</param>
        /// <returns>A fully qualified path to the directory containing the implementation.</returns>
        /// <exception cref="ImplementationNotFoundException">The <paramref name="implementation"/> is not cached yet.</exception>
        /// <exception cref="UnauthorizedAccessException">Read access to the store is not permitted.</exception>
        public static string GetPath(this IImplementationStore implementationStore, ImplementationBase implementation)
        {
            #region Sanity checks
            if (implementationStore == null)
            {
                throw new ArgumentNullException(nameof(implementationStore));
            }
            if (implementation == null)
            {
                throw new ArgumentNullException(nameof(implementation));
            }
            #endregion

            if (string.IsNullOrEmpty(implementation.LocalPath))
            {
                string?path = implementationStore.GetPath(implementation.ManifestDigest);
                if (path == null)
                {
                    throw new ImplementationNotFoundException(implementation.ManifestDigest);
                }
                return(path);
            }
            else
            {
                return(implementation.LocalPath);
            }
        }
            protected override bool IsEqual(ImplementationBase implementation)
            {
                if (implementation is SafFile otherFile)
                {
                    var path      = _directoryDocument.Uri?.ToString() ?? string.Empty;
                    var otherPath = otherFile._directoryDocument.Uri?.ToString() ?? string.Empty;
                    return(path.Equals(otherPath, StringComparison.InvariantCulture));
                }

                return(false);
            }
Esempio n. 3
0
        /// <summary>
        /// Determines the local path of an implementation.
        /// </summary>
        /// <param name="implementation">The implementation to be located.</param>
        /// <returns>A fully qualified path to the directory containing the implementation; <c>null</c> if the requested implementation could not be found in the store or is a package implementation.</returns>
        protected string?GetPathSafe(ImplementationBase implementation)
        {
            #region Sanity checks
            if (implementation == null)
            {
                throw new ArgumentNullException(nameof(implementation));
            }
            #endregion

            if (implementation.ID.StartsWith(ExternalImplementation.PackagePrefix))
            {
                return(null);
            }

            _implementationStore.Flush();
            return(_implementationStore.GetPath(implementation.ManifestDigest));
        }
Esempio n. 4
0
 protected override bool IsEqual(ImplementationBase impl)
 => impl is Local other && Path.Equals(other.Path);
Esempio n. 5
0
 protected override bool IsEqual(ImplementationBase implementation) =>
 implementation is SecurityScopedFile file && file._nsUrl.FilePathUrl.Path == _nsUrl.FilePathUrl.Path;
Esempio n. 6
0
 private StorageFile(ImplementationBase implementation)
 {
     Implementation = implementation;
     Implementation.InitOwner(this);
 }
Esempio n. 7
0
 protected abstract bool IsEqual(ImplementationBase impl);
Esempio n. 8
0
 private StorageFolder(ImplementationBase implementation)
 {
     _implementation = implementation;
     _implementation.InitOwner(this);
 }
 protected override bool IsEqual(ImplementationBase implementation) => throw NotSupported();
Esempio n. 10
0
 private FileRandomAccessStream(ImplementationBase implementation)
 {
     _implementation = implementation;
 }
Esempio n. 11
0
        private void Yield([NotNull] Requirements requirements, [CanBeNull] Feed feed = null, [CanBeNull] ImplementationBase implementation = null)
        {
            if (implementation == null)
            {
                var selections = Solver.TrySolve(requirements);
                if (selections != null)
                {
                    implementation = selections.Implementations[0];
                }
            }
            if (feed == null)
            {
                feed = FeedManager.GetFeed(requirements.InterfaceUri);
            }

            var sourceUri = feed.CatalogUri ?? feed.Uri;

            _request.YieldSoftwareIdentity(
                fastPath: requirements.ToJsonString(),
                name: feed.Name,
                version: (implementation == null || implementation.Version == null) ? null : implementation.Version.ToString(),
                versionScheme: null,
                summary: feed.Summaries.GetBestLanguage(CultureInfo.CurrentUICulture),
                source: (sourceUri == null) ? null : sourceUri.ToStringRfc(),
                searchKey: feed.Name,
                fullPath: null,
                packageFileName: feed.Name);
        }
Esempio n. 12
0
 protected override bool IsEqual(ImplementationBase implementation) =>
 implementation is SecurityScopedFolder otherFolder && otherFolder._nsUrl.FilePathUrl.Path == _nsUrl.FilePathUrl.Path;
Esempio n. 13
0
 private StorageFile(ImplementationBase impl)
 {
     _impl = impl;
     _impl.InitOwner(this);
 }