コード例 #1
0
        /// <summary>
        /// Gets a compressor for the given type.
        /// </summary>
        /// <typeparam name="T">The type to be compressed.</typeparam>
        /// <exception cref="Exception">Thrown if the required compressor cannot be found.</exception>
        public static ICompressor <T> GetRequiredCompressor <T>(this ICompressorFactory factory)
        {
            var result = factory.GetCompressor <T>();

            if (null == result)
            {
                CompressorNotFoundException.Throw(typeof(T));
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Gets a compressor for the given type.
        /// </summary>
        /// <param name="type">The type to be compressed.</param>
        /// <exception cref="Exception">Thrown if the required compressor cannot be found.</exception>
        public static ICompressor GetRequiredCompressor(this ICompressorFactory factory, Type type)
        {
            var result = factory.GetCompressor(type);

            if (null == result)
            {
                CompressorNotFoundException.Throw(type);
            }
            return(result);
        }