oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
131 stars 48 forks source link

Use C# 7 enum generic constraint? #73

Closed ziriax closed 4 years ago

ziriax commented 4 years ago

Just an idea here.

It seems that the code doesn't make use yet of the Enum constraint of C# 7

The ExifEnumProperty could get such a constraint, it would make the code more type-safe?

Also, one could for example have the following method on the exif collection class:

        /// <summary>
        /// Adds an <see cref="ExifEnumProperty{T}"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Add<TEnum>(ExifTag key, TEnum value) where TEnum : Enum
        {
            AddItem(new ExifEnumProperty<TEnum>(key, value));
        }