//-------------------------------------
        // Consumption helper methods.

        //---------------------------------
        // Function to consume the new music bundle.
        // Exposed through MusicBundle.h.
        //
        ///////////////////////////////////////////////////////////////////////////////
        // Description: Deserializes the contents of a music bundle package, displays text from the Track List, Lyrics, Album Website parts.
        // The method then serializes the contents of the parts to files in specified output directory.
        ///////////////////////////////////////////////////////////////////////////////
        private static void ConsumeMusicBundle(string inputPackageName, // Name of music bundle.
                                               string outputDirectory   // Directory into which music bundle parts are written as files.
                                               )
        {
            // Create a new factory.
            var opcFactory = new IOpcFactory();

            // Open a read-only stream over the input package.
            opcFactory.CreateStreamOnFile(inputPackageName, OPC_STREAM_IO_MODE.OPC_STREAM_IO_READ,             // Read-only.
Esempio n. 2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Description: Opens a stream to the path and file name specified, and deserializes the file's content as the content of the part.
        ///////////////////////////////////////////////////////////////////////////////
        private static void WriteFileContentToPart(IOpcFactory opcFactory,
                                                   string filePath, // Directory where the file is located.
                                                   string fileName, // Name of file whose content will be deserialized.
                                                   IOpcPart opcPart // Part into which the file content is deserialized.
                                                   )
        {
            // Get the full file name of the file.
            GetFullFileName(filePath, fileName, out var fullFileName);

            // Create a read-only stream over the file.
            opcFactory.CreateStreamOnFile(fullFileName, OPC_STREAM_IO_MODE.OPC_STREAM_IO_READ, default,
Esempio n. 3
0
        public void LoadTest()
        {
            Assert.That(factory.CreateStreamOnFile(TestCaseSources.WordDoc, OPC_STREAM_IO_MODE.OPC_STREAM_IO_READ, null, 0, out var sourceFileStream), ResultIs.Successful);
            using var psourceFileString = ComReleaserFactory.Create(sourceFileStream);

            Assert.That(factory.ReadPackageFromStream(sourceFileStream, OPC_READ_FLAGS.OPC_CACHE_ON_ACCESS, out var outPackage), ResultIs.Successful);
            using var poutPackage = ComReleaserFactory.Create(outPackage);

            IOpcPartSet pset = null;

            Assert.That(() => pset = outPackage.GetPartSet(), Throws.Nothing);
            using var ppset        = ComReleaserFactory.Create(pset);

            IOpcPartEnumerator penum = null;

            Assert.That(() => penum = pset.GetEnumerator(), Throws.Nothing);
            using var ppenum        = new OpcEnumerator <IOpcPartEnumerator, IOpcPart>(penum);

            while (ppenum.MoveNext())
            {
                TestContext.WriteLine($"{ppenum.Current.GetContentType()}, {ppenum.Current.GetCompressionOptions()}");
            }
            TestContext.WriteLine();

            IOpcRelationshipSet rset = null;

            Assert.That(() => rset = outPackage.GetRelationshipSet(), Throws.Nothing);
            using var prset        = ComReleaserFactory.Create(rset);

            IOpcRelationshipEnumerator renum = null;

            Assert.That(() => renum = rset.GetEnumerator(), Throws.Nothing);
            using var prenum        = new OpcEnumerator <IOpcRelationshipEnumerator, IOpcRelationship>(renum);

            while (prenum.MoveNext())
            {
                TestContext.WriteLine($"{prenum.Current.GetId()}, {prenum.Current.GetRelationshipType()}, {prenum.Current.GetTargetMode()}");
            }
            TestContext.WriteLine();
        }