Exemple #1
0
                public Key(PixelTypes pixelType, string filePath, IImageDecoder customDecoder)
                {
                    Type customType = customDecoder?.GetType();

                    this.commonValues      = new Tuple <PixelTypes, string, Type>(pixelType, filePath, customType);
                    this.decoderParameters = GetDecoderParameters(customDecoder);
                }
Exemple #2
0
                public Key(PixelTypes pixelType, string filePath, int allocatorBufferCapacity, IImageDecoder customDecoder)
                {
                    Type customType = customDecoder?.GetType();

                    this.commonValues = new Tuple <PixelTypes, string, Type, int>(
                        pixelType,
                        filePath,
                        customType,
                        allocatorBufferCapacity);
                    this.decoderParameters = GetDecoderParameters(customDecoder);
                }
Exemple #3
0
                private static Dictionary <string, object> GetDecoderParameters(IImageDecoder customDecoder)
                {
                    Type type = customDecoder.GetType();

                    var data = new Dictionary <string, object>();

                    while (type != null && type != typeof(object))
                    {
                        PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                        foreach (PropertyInfo p in properties)
                        {
                            string key   = $"{type.FullName}.{p.Name}";
                            object value = p.GetValue(customDecoder);
                            data[key] = value;
                        }
                        type = type.GetTypeInfo().BaseType;
                    }
                    return(data);
                }
 public static void RegisterDecoder(string fileExtension, IImageDecoder decoder)
 {
     decoders.Add(fileExtension.ToUpperInvariant(), decoder.GetType());
 }