Пример #1
0
 public StreamConverter(
     string toExtension,
     AsyncConversion <Stream> conversion)
 {
     ToExtension = toExtension;
     Conversion  = conversion;
 }
Пример #2
0
 public TypeConverter(
     AsyncConversion conversion,
     CanConvert canConvert)
 {
     Conversion = conversion;
     CanConvert = canConvert;
 }
Пример #3
0
 public static void RegisterFileConverter(
     string fromExtension,
     AsyncConversion <Stream> conversion)
 {
     Guard.AgainstNull(conversion, nameof(conversion));
     Guard.AgainstBadExtension(fromExtension, nameof(fromExtension));
     extensionConverters[fromExtension] = conversion;
 }
Пример #4
0
 public TypeConverter(
     string toExtension,
     AsyncConversion conversion,
     CanConvert canConvert)
 {
     ToExtension = toExtension;
     Conversion  = conversion;
     CanConvert  = canConvert;
 }
Пример #5
0
        public static void RegisterFileConverter <T>(
            AsyncConversion <T> conversion,
            CanConvert <T>?canConvert = null)
        {
            Guard.AgainstNull(conversion, nameof(conversion));
            var converter = new TypeConverter(
                (o, settings) => conversion((T)o, settings),
                DefaultCanConvert(canConvert));

            typedConverters.Add(converter);
        }
Пример #6
0
        public static void RegisterFileConverter(
            AsyncConversion conversion,
            CanConvert canConvert)
        {
            Guard.AgainstNull(conversion, nameof(conversion));
            Guard.AgainstNull(canConvert, nameof(canConvert));
            var converter = new TypeConverter(
                conversion,
                canConvert);

            typedConverters.Add(converter);
        }
Пример #7
0
 internal static bool TryGetExtensionConverter(string extension, [NotNullWhen(true)] out AsyncConversion <Stream>?converter)
 {
     return(extensionConverters.TryGetValue(extension, out converter));
 }