Esempio n. 1
0
        public static T GetAttribute <T>(this global::System.Enum enumValue, bool inherit = false) where T : Attribute
        {
            Type enumType = enumValue.GetType();

            MemberInfo[] memInfo    = enumType.GetMember(enumValue.ToString());
            object[]     attributes = memInfo.First().GetCustomAttributes(typeof(T), inherit);

            if (!attributes.Any())
            {
                return(null);
            }

            return((T)attributes.First());
        }
        /// <summary>
        ///     An object extension method that gets description attribute.
        /// </summary>
        /// <param name="value">The value to act on.</param>
        /// <returns>The description attribute.</returns>
        public static string GetCustomAttributeDescription(this global::System.Enum value)
        {
            var attr = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() as DescriptionAttribute;

            return(attr.Description);
        }
Esempio n. 3
0
 private static global::net.sf.jni4net.utils.JniHandle ToString28(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle format)
 {
     // (Ljava/lang/String;)Ljava/lang/String;
     // (LSystem/String;)LSystem/String;
     global::net.sf.jni4net.jni.JNIEnv      @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle);
     try {
         global::System.Enum @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.Enum>(@__env, @__obj);
         @__return = global::net.sf.jni4net.utils.Convertor.StrongC2JString(@__env, @__real.ToString(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, format)));
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }