Example #1
0
        internal bool YieldFromSwidtag(Package pkg, string searchKey)
        {
            if (pkg == null)
            {
                return(!IsCanceled);
            }

            var provider       = pkg._swidtag;
            var targetFilename = provider.Links.Select(each => each.Attributes[Iso19770_2.Discovery.TargetFilename]).WhereNotNull().FirstOrDefault();
            var summary        = new MetadataIndexer(provider)[Iso19770_2.Attributes.Summary.LocalName].FirstOrDefault();

            var fastPackageReference = pkg.Location.AbsoluteUri;

            if (YieldSoftwareIdentity(fastPackageReference, provider.Name, provider.Version, provider.VersionScheme, summary, fastPackageReference, searchKey, null, targetFilename) != null)
            {
                // yield all the meta/attributes
                if (provider.Meta.Any(
                        m => {
                    var element = AddMeta(fastPackageReference);
                    var attributes = m.Attributes;
                    return(attributes.Keys.Any(key => {
                        var nspace = key.Namespace.ToString();
                        if (String.IsNullOrWhiteSpace(nspace))
                        {
                            return AddMetadata(element, key.LocalName, attributes[key]) == null;
                        }

                        return AddMetadata(element, new Uri(nspace), key.LocalName, attributes[key]) == null;
                    }));
                }))
                {
                    return(!IsCanceled);
                }

                if (provider.Links.Any(link => AddLink(link.HRef, link.Relationship, link.MediaType, link.Ownership, link.Use, link.Media, link.Artifact) == null))
                {
                    return(!IsCanceled);
                }

                if (provider.Entities.Any(entity => AddEntity(entity.Name, entity.RegId, entity.Role, entity.Thumbprint) == null))
                {
                    return(!IsCanceled);
                }

                //installing a package from bootstrap site needs to prompt a user. Only auto-boostrap is not prompted.
                var    pm = PackageManagementService as PackageManagementService;
                string isTrustedSource = pm.InternalPackageManagementInstallOnly ? "false" : "true";
                if (AddMetadata(fastPackageReference, "FromTrustedSource", isTrustedSource) == null)
                {
                    return(!IsCanceled);
                }
            }
            return(!IsCanceled);
        }
Example #2
0
        internal bool YieldFromSwidtag(Package pkg, string searchKey) {
            if (pkg == null) {
                return !IsCanceled;
            }

            var provider = pkg._swidtag;
            var fastPackageReference = LocalSource.Any() ? pkg.Location.LocalPath : pkg.Location.AbsoluteUri;
            var source = pkg.Source ?? fastPackageReference;

            var summary = pkg.Name;
            var targetFileName = pkg.Name;

            if (!LocalSource.Any()) {
                summary = new MetadataIndexer(provider)[Iso19770_2.Attributes.Summary.LocalName].FirstOrDefault();
                targetFileName = provider.Links.Select(each => each.Attributes[Iso19770_2.Discovery.TargetFilename]).WhereNotNull().FirstOrDefault();
            }

            if (YieldSoftwareIdentity(fastPackageReference, provider.Name, provider.Version, provider.VersionScheme, summary, source, searchKey, null, targetFileName) != null) {
                // yield all the meta/attributes
                if (provider.Meta.Any(
                    m => {
                        var element = AddMeta(fastPackageReference);
                        var attributes = m.Attributes;
                        return attributes.Keys.Any(key => {
                            var nspace = key.Namespace.ToString();
                            if (String.IsNullOrWhiteSpace(nspace)) {
                                return AddMetadata(element, key.LocalName, attributes[key]) == null;
                            }

                            return AddMetadata(element, new Uri(nspace), key.LocalName, attributes[key]) == null;
                        });
                    })) {
                    return !IsCanceled;
                }

                if (provider.Links.Any(link => AddLink(link.HRef, link.Relationship, link.MediaType, link.Ownership, link.Use, link.Media, link.Artifact) == null)) {
                    return !IsCanceled;
                }

                if (provider.Entities.Any(entity => AddEntity(entity.Name, entity.RegId, entity.Role, entity.Thumbprint) == null)) {
                    return !IsCanceled;
                }

                //installing a package from bootstrap site needs to prompt a user. Only auto-bootstrap is not prompted.
                var pm = PackageManagementService as PackageManagementService;
                string isTrustedSource = pm.InternalPackageManagementInstallOnly ? "false" : "true";
                if (AddMetadata(fastPackageReference, "FromTrustedSource", isTrustedSource) == null) {
                    return !IsCanceled;
                }
            }
            return !IsCanceled;
        }
 public IndexController(MetadataIndexer indexer, IErrorService errorService)
 {
     _indexer      = indexer;
     _errorService = errorService;
 }
Example #4
0
        internal bool YieldFromSwidtag(Package pkg, string searchKey)
        {
            if (pkg == null) {
                return !IsCanceled;
            }

            var provider = pkg._swidtag;
            var targetFilename = provider.Links.Select(each => each.Attributes[Iso19770_2.Discovery.TargetFilename]).WhereNotNull().FirstOrDefault();
            var summary = new MetadataIndexer(provider)[Iso19770_2.Attributes.Summary.LocalName].FirstOrDefault();

            var fastPackageReference = pkg.Location.AbsoluteUri;

            if (YieldSoftwareIdentity(fastPackageReference, provider.Name, provider.Version, provider.VersionScheme, summary, null, searchKey, null, targetFilename) != null) {
                // yield all the meta/attributes
                if (provider.Meta.Any(
                    m => {
                        var element = AddMeta(fastPackageReference);
                        var attributes = m.Attributes;
                        return attributes.Keys.Any(key => {
                            var nspace = key.Namespace.ToString();
                            if (String.IsNullOrWhiteSpace(nspace)) {
                                return AddMetadata(element, key.LocalName, attributes[key]) == null;
                            }

                            return AddMetadata(element, new Uri(nspace), key.LocalName, attributes[key]) == null;
                        });
                    })) {
                    return !IsCanceled;
                }

                if (provider.Links.Any(link => AddLink(link.HRef, link.Relationship, link.MediaType, link.Ownership, link.Use, link.Media, link.Artifact) == null)) {
                    return !IsCanceled;
                }

                if (provider.Entities.Any(entity => AddEntity(entity.Name, entity.RegId, entity.Role, entity.Thumbprint) == null)) {
                    return !IsCanceled;
                }

                if (AddMetadata(fastPackageReference, "FromTrustedSource", true.ToString()) == null) {
                    return !IsCanceled;
                }
            }
            return !IsCanceled;
        }