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


C# Byte.UnpackTemplate方法代码示例

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


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

示例1: OpenXMLConnector

        /// <summary>
        /// OpenXMLConnector constructor. Allows to manage a .PNP OpenXML package file through a supporting persistence connector.
        /// </summary>
        /// <param name="packageFileName">The name of the .PNP package file. If the .PNP extension is missing, it will be added</param>
        /// <param name="persistenceConnector">The FileConnector object that will be used for physical persistence of the file</param>
        /// <param name="author">The Author of the .PNP package file, if any. Optional</param>
        /// <param name="signingCertificate">The X.509 certificate to use for digital signature of the template, optional</param>
        public OpenXMLConnector(string packageFileName,
            FileConnectorBase persistenceConnector, 
            String author = null,
            X509Certificate2 signingCertificate = null)
            : base()
        {
            if (String.IsNullOrEmpty(packageFileName))
            {
                throw new ArgumentException("packageFileName");
            }
            else if (!packageFileName.EndsWith(".pnp", StringComparison.InvariantCultureIgnoreCase))
            {
                // Check for file extension
                packageFileName = packageFileName.EndsWith(".") ?
                    (packageFileName + "pnp") : (packageFileName + ".pnp");
            }

            this.packageFileName = packageFileName;

            if (persistenceConnector == null)
            {
                throw new ArgumentException("persistenceConnector");
            }

            this.persistenceConnector = persistenceConnector;

            // Try to load the .PNP package file
            var packageStream = persistenceConnector.GetFileStream(packageFileName);
            if (packageStream != null)
            {
                // If the .PNP package exists unpack it into PnP OpenXML package info object
                using (StreamReader sr = new StreamReader(packageStream))
                {
                    Byte[] buffer = new Byte[packageStream.Length];

                    // TODO: Handle large files with chunking
                    packageStream.Read(buffer, 0, (Int32)packageStream.Length);

                    this.pnpInfo = buffer.UnpackTemplate();
                }
            }
            else
            {
                // Otherwsie initialize a fresh new PnP OpenXML package info object
                this.pnpInfo = new PnPInfo()
                {
                    Manifest = new PnPManifest()
                    {
                        Type = PackageType.Full
                    },
                    Properties = new PnPProperties()
                    {
                        Generator = PnPCoreUtilities.PnPCoreVersionTag,
                        Author = !String.IsNullOrEmpty(author) ? author : String.Empty,
                    },
                };
            }
        }
开发者ID:rroman81,项目名称:PnP-Sites-Core,代码行数:65,代码来源:OpenXMLConnector.cs


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