当前位置: 首页>>代码示例>>C#>>正文


C# Package.GetRelationshipsByType方法代码示例

本文整理汇总了C#中System.IO.Packaging.Package.GetRelationshipsByType方法的典型用法代码示例。如果您正苦于以下问题:C# Package.GetRelationshipsByType方法的具体用法?C# Package.GetRelationshipsByType怎么用?C# Package.GetRelationshipsByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Packaging.Package的用法示例。


在下文中一共展示了Package.GetRelationshipsByType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadPackageManifest

        public static PackageDefinition ReadPackageManifest(Package package)
        {
            var manifestPart = package.GetPart(
                package.GetRelationshipsByType(CtpFormatPackageDefinitionRelationshipType).Single().TargetUri);

            using (var manifestStream = manifestPart.GetStream())
            using (var xmlReader = XmlReader.Create(manifestStream, XmlUtils.DtdSafeReaderSettings))
            {
               return new PackageDefinition(XDocument.Load(xmlReader).Root);
            }
        }
开发者ID:merbla,项目名称:Calamari,代码行数:11,代码来源:AzureCloudServiceConventions.cs

示例2: ProcessManifest

        PackageMetadata ProcessManifest(Package package)
        {
            var packageRelationship =
                package.GetRelationshipsByType("http://schemas.microsoft.com/packaging/2010/07/manifest")
                .SingleOrDefault();

            if (packageRelationship == null)
            {
                throw new InvalidOperationException("Package does not contain a manifest");
            }

            var part = package.GetPart(packageRelationship.TargetUri);

            return ReadManifestStream(part.GetStream());
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:15,代码来源:LightweightPackageExtractor.cs

示例3: SignAllParts

        private void SignAllParts(Package package, X509Certificate2 certificate)
        {
            var partsToSign = new List<Uri>();
            var relationshipsToSign = new List<PackageRelationshipSelector>();

            foreach (var relationship in package.GetRelationshipsByType(RtOfficeDocument))
            {
                AddSignableItems(relationship, partsToSign, relationshipsToSign);
            }

            var mgr = new PackageDigitalSignatureManager(package)
            {
                CertificateOption = CertificateEmbeddingOption.InSignaturePart
            };

            var officeObject = CreateOfficeObject(SignatureID, ManifestHashAlgorithm);
            var officeObjectReference = new Reference("#" + OfficeObjectID);
            mgr.Sign(partsToSign,
                     certificate,
                     relationshipsToSign,
                     SignatureID,
                     new[] { officeObject },
                     new[] { officeObjectReference });
            package.Close();
        }
开发者ID:wpq0,项目名称:Document-Signer,代码行数:25,代码来源:OfficeOpenXmlSigner.cs

示例4: Select

        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        /// This method returns the list of selected PackageRelationships as per the
        /// given criteria, from a part in the Package provided
        /// </summary>
        /// <param name="package">Package object from which we get the relationsips</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">If package parameter is null</exception>
        public List<PackageRelationship> Select(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            List<PackageRelationship> relationships = new List<PackageRelationship>(0);

            switch (SelectorType)
            {
                case PackageRelationshipSelectorType.Id:
                    if (SourceUri.Equals(PackUriHelper.PackageRootUri))
                    {
                        if (package.RelationshipExists(SelectionCriteria))
                            relationships.Add(package.GetRelationship(SelectionCriteria));
                    }
                    else
                    {
                        if (package.PartExists(SourceUri))
                        {
                            PackagePart part = package.GetPart(SourceUri);
                            if (part.RelationshipExists(SelectionCriteria))
                                relationships.Add(part.GetRelationship(SelectionCriteria));
                        }
                    }
                    break;

                case PackageRelationshipSelectorType.Type:
                    if (SourceUri.Equals(PackUriHelper.PackageRootUri))
                    {
                        foreach (PackageRelationship r in package.GetRelationshipsByType(SelectionCriteria))
                            relationships.Add(r);
                    }
                    else
                    {
                        if (package.PartExists(SourceUri))
                        {
                            foreach (PackageRelationship r in package.GetPart(SourceUri).GetRelationshipsByType(SelectionCriteria))
                                relationships.Add(r);
                        }
                    }
                    break;

                default:
                    //Debug.Assert is fine here since the parameters have already been validated. And all the properties are 
                    //readonly
                    Debug.Assert(false, "This option should never be called");
                    break;
            }

            return relationships;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:68,代码来源:PackageRelationshipSelector.cs

示例5: CopyDecks

 internal void CopyDecks(Package package)
 {
     string path = Path.Combine(basePath, "Decks");
     var decks = package.GetRelationshipsByType("http://schemas.octgn.org/set/deck");
     byte[] buffer = new byte[0x1000];
     foreach(var deckRel in decks)
     {
         var deck = package.GetPart(deckRel.TargetUri);
         string deckFilename = Path.Combine(path, Path.GetFileName(deck.Uri.ToString()));
         using(var deckStream = deck.GetStream(FileMode.Open, FileAccess.Read))
         using(var targetStream = File.Open(deckFilename, FileMode.Create, FileAccess.Write))
         {
             int read;
             while(true)
             {
                 read = deckStream.Read(buffer, 0, buffer.Length);
                 if(read == 0) break;
                 targetStream.Write(buffer, 0, read);
             }
         }
     }
 }
开发者ID:YoshiEnVerde,项目名称:OCTGN,代码行数:22,代码来源:Game.cs

示例6: CopyDecks

 internal void CopyDecks(Package package)
 {
     string path = Path.Combine(GamesRepository.BasePath, "Decks");
     PackageRelationshipCollection decks = package.GetRelationshipsByType("http://schemas.octgn.org/set/deck");
     var buffer = new byte[0x1000];
     foreach (PackageRelationship deckRel in decks)
     {
         PackagePart deck = package.GetPart(deckRel.TargetUri);
         string deckuri = Path.GetFileName(deck.Uri.ToString());
         if (deckuri == null) continue;
         string deckFilename = Path.Combine(path, deckuri);
         using (Stream deckStream = deck.GetStream(FileMode.Open, FileAccess.Read))
         using (
             FileStream targetStream = File.Open(deckFilename, FileMode.Create, FileAccess.Write, FileShare.Read)
             )
         {
             while (true)
             {
                 int read = deckStream.Read(buffer, 0, buffer.Length);
                 if (read == 0) break;
                 targetStream.Write(buffer, 0, read);
             }
         }
     }
 }
开发者ID:Zhevranacci,项目名称:OCTGN,代码行数:25,代码来源:Game.cs

示例7: GetDocumentPart

 public static PackagePart GetDocumentPart(Package package)
 {
     PackageRelationship relationship = package.GetRelationshipsByType(OfficeDocumentRelType).FirstOrDefault();
     Uri docUri = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), relationship.TargetUri);
     return package.GetPart(docUri);
 }
开发者ID:koZZZdya,项目名称:TsSoft.Docx.TemplateEngine,代码行数:6,代码来源:DocxPartResolver.cs


注:本文中的System.IO.Packaging.Package.GetRelationshipsByType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。