Beispiel #1
0
        public void CreateNew_NeverReturnsNull()
        {
            var factory   = new CompositionContainerFactory();
            var container = factory.CreateNew();

            Assert.IsNotNull(container);
        }
        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);
        }
        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);
        }
Beispiel #4
0
        private static CompositionContainer CreateNewContainer()
        {
            var factory   = new CompositionContainerFactory();
            var container = factory.CreateNew();

            return(container);
        }
Beispiel #5
0
        public void AddTypes_TypeAdded_CanBeInstantiatedInContainer()
        {
            var factory = new CompositionContainerFactory();

            factory.AddTypes(typeof(ComposableTestClass));

            var container = factory.CreateNew();

            var instance = container.GetExport <ComposableTestClass>();

            Assert.IsNotNull(instance);
        }
        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);
        }
Beispiel #7
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);
        }