private CompositionContainer CreateCompositionContainer()
        {
            var factory        = new CompositionContainerFactory();
            var midiIOAssembly = typeof(MTrkChunkHandler).Assembly;

            // add basic file handlers
            factory.AddMarkedTypesInAssembly(null, typeof(IFileChunkHandler));

            // add midi file handlers
            factory.AddMarkedTypesInAssembly(midiIOAssembly, typeof(IFileChunkHandler));

            // note that Midi files use big endian.
            // and the chunks are not aligned.
            factory.AddTypes(
                typeof(BigEndianNumberWriter),
                typeof(SizePrefixedStringWriter),
                typeof(ChunkTypeFactory),
                typeof(FileChunkHandlerManager));

            var container = factory.CreateNew();

            var chunkFactory = container.GetService <ChunkTypeFactory>();

            // add midi chunks
            chunkFactory.AddChunksFrom(midiIOAssembly, true);

            return(container);
        }
Example #2
0
        public static CompositionContainer CreateCompositionContextForReading()
        {
            var factory = new CompositionContainerFactory();

            factory.AddMarkedTypesInAssembly(null, typeof(IFileChunkHandler));
            // add midi exports
            factory.AddMarkedTypesInAssembly(typeof(MTrkChunkHandler).Assembly, typeof(IFileChunkHandler));

            // note that Midi files use big endian.
            // and the chunks are not aligned.
            factory.AddTypes(
                typeof(BigEndianNumberReader),
                typeof(SizePrefixedStringReader),
                typeof(ChunkTypeFactory),
                typeof(FileChunkHandlerManager));

            var container = factory.CreateNew();

            var chunkFactory = container.GetService <ChunkTypeFactory>();

            // add midi chunks
            chunkFactory.AddChunksFrom(typeof(MTrkChunkHandler).Assembly, true);

            return(container);
        }
Example #3
0
        private static CompositionContainer CreateCompositionContextForReading()
        {
            var factory = new CompositionContainerFactory();

            factory.AddMarkedTypesInAssembly(null, typeof(IFileChunkHandler));

            factory.AddMarkedTypesInAssembly(typeof(MTrkChunkHandler).Assembly, typeof(IFileChunkHandler));

            factory.AddTypes(
                typeof(BigEndianNumberReader),
                typeof(SizePrefixedStringReader),
                typeof(ChunkTypeFactory),
                typeof(FileChunkHandlerManager));

            var container = factory.CreateNew();

            var chunkFactory = container.GetService <ChunkTypeFactory>();

            chunkFactory.AddChunksFrom(typeof(MTrkChunkHandler).Assembly, true);

            return(container);
        }
Example #4
0
        public static CompositionContainer CreateCompositionContext(bool littleEndian)
        {
            var factory = new CompositionContainerFactory();

            factory.AddMarkedTypesInAssembly(null, typeof(IFileChunkHandler));

            factory.AddTypes(
                littleEndian ? typeof(LittleEndianNumberReader) : typeof(BigEndianNumberReader),
                littleEndian ? typeof(LittleEndianNumberWriter) : typeof(BigEndianNumberWriter),
                typeof(SizePrefixedStringReader),
                typeof(SizePrefixedStringWriter),
                typeof(StreamNavigator),
                typeof(ChunkTypeFactory),
                typeof(FileChunkHandlerManager));

            var container = factory.CreateNew();

            var chunkFactory = container.GetService <ChunkTypeFactory>();

            // add test chunks
            chunkFactory.AddChunksFrom(typeof(WaveChunk).Assembly, true);

            return(container);
        }