Exemplo n.º 1
0
        /// <summary>
        /// Gets the type generator class from an enum element with the <c>ImportExportTypeAttribute</c> set.
        /// </summary>
        /// <param name="value">The enum value.</param>
        /// <returns>The title string.</returns>
        public static Type GetGeneratorClass(this Enum value)
        {
            FieldInfo field;

            if (GetFieldInfo(value, out field))
            {
                return(null);
            }

            ImportExportTypeAttribute attr =
                Attribute.GetCustomAttribute(field, typeof(ImportExportTypeAttribute)) as ImportExportTypeAttribute;

            return(attr?.GeneratorClass);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the title string from an enum element with the <c>ImportExportTypeAttribute</c> set.
        /// </summary>
        /// <param name="value">The enum value.</param>
        /// <returns>The title string.</returns>
        public static string GetTitle(this Enum value)
        {
            FieldInfo field;

            if (GetFieldInfo(value, out field))
            {
                return(null);
            }

            ImportExportTypeAttribute attr =
                Attribute.GetCustomAttribute(field, typeof(ImportExportTypeAttribute)) as ImportExportTypeAttribute;

            return(attr?.Title);
        }