public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            DateTime? commitTimeStamp = PackagePipelineHelpers.GetCommitTimeStamp(context);
            Guid? commitId = PackagePipelineHelpers.GetCommitId(context);

            IGraph graph = new Graph();

            INode resource = graph.CreateUriNode(context.Uri);

            if (commitTimeStamp != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp),
                    graph.CreateLiteralNode(commitTimeStamp.Value.ToString("O"), Schema.DataTypes.DateTime));
            }

            if (commitId != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogCommitId),
                    graph.CreateLiteralNode(commitId.Value.ToString()));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
 public static XDocument GetXmlZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     using (Stream stream = GetZipArchiveEntry(package, context, entryName))
     {
         return XDocument.Load(stream);
     }
 }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            DateTime?commitTimeStamp = PackagePipelineHelpers.GetCommitTimeStamp(context);
            Guid?    commitId        = PackagePipelineHelpers.GetCommitId(context);

            IGraph graph = new Graph();

            INode resource = graph.CreateUriNode(context.Uri);

            if (commitTimeStamp != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp),
                    graph.CreateLiteralNode(commitTimeStamp.Value.ToString("O"), Schema.DataTypes.DateTime));
            }

            if (commitId != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogCommitId),
                    graph.CreateLiteralNode(commitId.Value.ToString()));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
Exemplo n.º 4
0
        public static Stream GetZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
        {
            ZipArchive      zipArchive = GetZipArchive(package, context);
            ZipArchiveEntry entry      = zipArchive.GetEntry(entryName);

            return(entry.Open());
        }
Exemplo n.º 5
0
 public static XDocument GetXmlZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     using (Stream stream = GetZipArchiveEntry(package, context, entryName))
     {
         return(XDocument.Load(stream));
     }
 }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument document = PackagePipelineHelpers.GetXmlZipArchiveEntry(package, context, _entryName);



            return true;
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument document = PackagePipelineHelpers.GetXmlZipArchiveEntry(package, context, _entryName);



            return(true);
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);

            JToken token = PackagePipelineHelpers.GetContext("");

            Console.WriteLine(token);

            return true;
        }
Exemplo n.º 9
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);

            JToken token = PackagePipelineHelpers.GetContext("");

            Console.WriteLine(token);

            return(true);
        }
 public override bool Execute(PipelinePackage package, PackagePipelineContext context)
 {
     JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);
     string id = packageSpec["id"].ToString();
     string version = packageSpec["version"].ToString();
     string relativeAddress = string.Format("{0}/{1}", id, version);
     context.Uri = new Uri(context.BaseAddress, relativeAddress.ToLowerInvariant());
     packageSpec["@id"] = context.Uri.AbsoluteUri;
     return true;
 }
Exemplo n.º 11
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec     = PackagePipelineHelpers.GetPackageSpec(package, context);
            string id              = packageSpec["id"].ToString();
            string version         = packageSpec["version"].ToString();
            string relativeAddress = string.Format("{0}/{1}", id, version);

            context.Uri        = new Uri(context.BaseAddress, relativeAddress.ToLowerInvariant());
            packageSpec["@id"] = context.Uri.AbsoluteUri;
            return(true);
        }
 public static ZipArchive GetZipArchive(PipelinePackage package, PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.ZipArchivePropertyName, out obj))
     {
         return (ZipArchive)obj;
     }
     else
     {
         ZipArchive zipArchive = new ZipArchive(package.Stream, ZipArchiveMode.Read, true);
         context.Shelf.Add(PackagePipelinePropertyNames.ZipArchivePropertyName, zipArchive);
         return zipArchive;
     }
 }
 public static XDocument GetNuspec(PipelinePackage package, PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.NuspecPropertyName, out obj))
     {
         return (XDocument)obj;
     }
     else
     {
         ZipArchive zipArchive = GetZipArchive(package, context);
         XDocument nuspec = Utils.GetNuspec(zipArchive);
         context.Shelf.Add(PackagePipelinePropertyNames.NuspecPropertyName, nuspec);
         return nuspec;
     }
 }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            string hash = GetHash(package.Stream);
            long size = GetSize(package.Stream);

            IGraph graph = new Graph();
            INode subject = graph.CreateUriNode(context.Uri);
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHashAlgorithm), graph.CreateLiteralNode("SHA512"));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHash), graph.CreateLiteralNode(hash));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageSize), graph.CreateLiteralNode(size.ToString(), Schema.DataTypes.Integer));

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
Exemplo n.º 15
0
        public static ZipArchive GetZipArchive(PipelinePackage package, PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.ZipArchivePropertyName, out obj))
            {
                return((ZipArchive)obj);
            }
            else
            {
                ZipArchive zipArchive = new ZipArchive(package.Stream, ZipArchiveMode.Read, true);
                context.Shelf.Add(PackagePipelinePropertyNames.ZipArchivePropertyName, zipArchive);
                return(zipArchive);
            }
        }
        public static void Test0()
        {
            PackagePipeline pipeline = PackagePipelineFactory.Create2();

            Stream stream = new FileStream(@"C:\data\ema\nupkgs\BasicAppPackage.1.0.0.nupkg", FileMode.Open);

            PipelinePackage package = new PipelinePackage(stream);

            PackagePipelineContext context = new PackagePipelineContext(new Uri("http://azure.com/siena/package"));

            pipeline.Execute(package, context);

            PackageMetadataBase result = context.Result;

            Console.WriteLine(result.ToContent());
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            string hash = GetHash(package.Stream);
            long   size = GetSize(package.Stream);

            IGraph graph   = new Graph();
            INode  subject = graph.CreateUriNode(context.Uri);

            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHashAlgorithm), graph.CreateLiteralNode("SHA512"));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHash), graph.CreateLiteralNode(hash));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageSize), graph.CreateLiteralNode(size.ToString(), Schema.DataTypes.Integer));

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
Exemplo n.º 18
0
        public static XDocument GetNuspec(PipelinePackage package, PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.NuspecPropertyName, out obj))
            {
                return((XDocument)obj);
            }
            else
            {
                ZipArchive zipArchive = GetZipArchive(package, context);
                XDocument  nuspec     = Utils.GetNuspec(zipArchive);
                context.Shelf.Add(PackagePipelinePropertyNames.NuspecPropertyName, nuspec);
                return(nuspec);
            }
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument nuspec = PackagePipelineHelpers.GetNuspec(package, context);

            IGraph graph = Utils.CreateNuspecGraph(nuspec, context.BaseAddress.AbsoluteUri);

            INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

            Triple resource = graph.GetTriplesWithPredicateObject(rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails)).First();
            graph.Assert(resource.Subject, rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.Permalink));

            IGraph pageGraph = CreatePageGraph(resource.Subject, graph);

            context.Uri = ((UriNode)resource.Subject).Uri;

            context.StageResults.Add(new GraphPackageMetadata(graph));

            context.StagePageResults.Add(new GraphPackageMetadata(pageGraph));

            return true;
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            ZipArchive zipArchive = PackagePipelineHelpers.GetZipArchive(package, context);

            IEnumerable <PackageEntry> entries = GetEntries(zipArchive);

            IGraph graph = new Graph();

            if (entries != null)
            {
                INode packageEntryPredicate     = graph.CreateUriNode(Schema.Predicates.PackageEntry);
                INode packageEntryType          = graph.CreateUriNode(Schema.DataTypes.PackageEntry);
                INode fullNamePredicate         = graph.CreateUriNode(Schema.Predicates.FullName);
                INode namePredicate             = graph.CreateUriNode(Schema.Predicates.Name);
                INode lengthPredicate           = graph.CreateUriNode(Schema.Predicates.Length);
                INode compressedLengthPredicate = graph.CreateUriNode(Schema.Predicates.CompressedLength);
                INode rdfTypePredicate          = graph.CreateUriNode(Schema.Predicates.Type);

                INode resource = graph.CreateUriNode(context.Uri);

                foreach (PackageEntry entry in entries)
                {
                    Uri entryUri = new Uri(context.Uri.AbsoluteUri + "#" + entry.FullName);

                    INode entryNode = graph.CreateUriNode(entryUri);

                    graph.Assert(resource, packageEntryPredicate, entryNode);
                    graph.Assert(entryNode, rdfTypePredicate, packageEntryType);
                    graph.Assert(entryNode, fullNamePredicate, graph.CreateLiteralNode(entry.FullName));
                    graph.Assert(entryNode, namePredicate, graph.CreateLiteralNode(entry.Name));
                    graph.Assert(entryNode, lengthPredicate, graph.CreateLiteralNode(entry.Length.ToString(), Schema.DataTypes.Integer));
                    graph.Assert(entryNode, compressedLengthPredicate, graph.CreateLiteralNode(entry.CompressedLength.ToString(), Schema.DataTypes.Integer));
                }
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            ZipArchive zipArchive = PackagePipelineHelpers.GetZipArchive(package, context);

            IEnumerable<PackageEntry> entries = GetEntries(zipArchive);

            IGraph graph = new Graph();

            if (entries != null)
            {
                INode packageEntryPredicate = graph.CreateUriNode(Schema.Predicates.PackageEntry);
                INode packageEntryType = graph.CreateUriNode(Schema.DataTypes.PackageEntry);
                INode fullNamePredicate = graph.CreateUriNode(Schema.Predicates.FullName);
                INode namePredicate = graph.CreateUriNode(Schema.Predicates.Name);
                INode lengthPredicate = graph.CreateUriNode(Schema.Predicates.Length);
                INode compressedLengthPredicate = graph.CreateUriNode(Schema.Predicates.CompressedLength);
                INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

                INode resource = graph.CreateUriNode(context.Uri);

                foreach (PackageEntry entry in entries)
                {
                    Uri entryUri = new Uri(context.Uri.AbsoluteUri + "#" + entry.FullName);

                    INode entryNode = graph.CreateUriNode(entryUri);

                    graph.Assert(resource, packageEntryPredicate, entryNode);
                    graph.Assert(entryNode, rdfTypePredicate, packageEntryType);
                    graph.Assert(entryNode, fullNamePredicate, graph.CreateLiteralNode(entry.FullName));
                    graph.Assert(entryNode, namePredicate, graph.CreateLiteralNode(entry.Name));
                    graph.Assert(entryNode, lengthPredicate, graph.CreateLiteralNode(entry.Length.ToString(), Schema.DataTypes.Integer));
                    graph.Assert(entryNode, compressedLengthPredicate, graph.CreateLiteralNode(entry.CompressedLength.ToString(), Schema.DataTypes.Integer));
                }
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
Exemplo n.º 22
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument nuspec = PackagePipelineHelpers.GetNuspec(package, context);

            IGraph graph = Utils.CreateNuspecGraph(nuspec, context.BaseAddress.AbsoluteUri);

            INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

            Triple resource = graph.GetTriplesWithPredicateObject(rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails)).First();

            graph.Assert(resource.Subject, rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.Permalink));

            IGraph pageGraph = CreatePageGraph(resource.Subject, graph);

            context.Uri = ((UriNode)resource.Subject).Uri;

            context.StageResults.Add(new GraphPackageMetadata(graph));

            context.StagePageResults.Add(new GraphPackageMetadata(pageGraph));

            return(true);
        }
        public bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            if (!package.Stream.CanSeek)
            {
                throw new ArgumentException("package stream must be seekable");
            }

            bool f = true;

            foreach (PackagePipelineStage stage in _stages)
            {
                package.Stream.Seek(0, SeekOrigin.Begin);

                f = stage.Execute(package, context);
                if (!f)
                {
                    break;
                }
            }

            context.MergeStageResults();
            return f;
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            IGraph graph = new Graph();

            INode subject = graph.CreateUriNode(context.Uri);

            graph.Assert(
                subject,
                graph.CreateUriNode(Schema.Predicates.Published), 
                graph.CreateLiteralNode(package.Published.ToString("O"), Schema.DataTypes.DateTime));

            if (package.Owner != null)
            {
                graph.Assert(
                    subject,
                    graph.CreateUriNode(Schema.Predicates.Owner),
                    graph.CreateLiteralNode(package.Owner));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
Exemplo n.º 25
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            IGraph graph = new Graph();

            INode subject = graph.CreateUriNode(context.Uri);

            graph.Assert(
                subject,
                graph.CreateUriNode(Schema.Predicates.Published),
                graph.CreateLiteralNode(package.Published.ToString("O"), Schema.DataTypes.DateTime));

            if (package.Owner != null)
            {
                graph.Assert(
                    subject,
                    graph.CreateUriNode(Schema.Predicates.Owner),
                    graph.CreateLiteralNode(package.Owner));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
Exemplo n.º 26
0
        public bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            if (!package.Stream.CanSeek)
            {
                throw new ArgumentException("package stream must be seekable");
            }

            bool f = true;

            foreach (PackagePipelineStage stage in _stages)
            {
                package.Stream.Seek(0, SeekOrigin.Begin);

                f = stage.Execute(package, context);
                if (!f)
                {
                    break;
                }
            }

            context.MergeStageResults();
            return(f);
        }
 public PackagePipelineCatalogItem(PackagePipeline pipeline, Uri itemType, Stream stream, DateTime published, string owner)
 {
     _pipeline = pipeline;
     _itemType = itemType;
     _pipelinePackage = new PipelinePackage(stream, published, owner);
 }
Exemplo n.º 28
0
 public PackagePipelineCatalogItem(PackagePipeline pipeline, Uri itemType, Stream stream, DateTime published, string owner)
 {
     _pipeline        = pipeline;
     _itemType        = itemType;
     _pipelinePackage = new PipelinePackage(stream, published, owner);
 }
 public static Stream GetZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     ZipArchive zipArchive = GetZipArchive(package, context);
     ZipArchiveEntry entry = zipArchive.GetEntry(entryName);
     return entry.Open();
 }