示例#1
0
        /// <summary>
        /// Tries to create an instance of a chunk type that has specified ID.
        /// </summary>
        /// <param name="chunkId">ID of the chunk that need to be created.</param>
        /// <param name="chunksTypes">Collection of the chunks types to search for the one with
        /// <paramref name="chunkId"/> ID.</param>
        /// <returns>An instance of the chunk type with the specified ID or null if <paramref name="chunksTypes"/>
        /// doesn't contain chunk type with it.</returns>
        private static MidiChunk TryCreateChunk(string chunkId, ChunkTypesCollection chunksTypes)
        {
            Type type = null;

            return(chunksTypes?.TryGetType(chunkId, out type) == true && IsChunkType(type)
                ? (MidiChunk)Activator.CreateInstance(type)
                : null);
        }
示例#2
0
        private static void ValidateCustomChunksIds(ChunkTypesCollection customChunkTypesCollection)
        {
            if (customChunkTypesCollection == null)
            {
                return;
            }

            ValidateCustomChunksIds(customChunkTypesCollection.Select(t => t.Id));
        }