コード例 #1
0
        public static string GetSyncMode(this SyncMode value)
        {
            DescriptionAttribute[] attributes = (DescriptionAttribute[])value
                                                .GetType()
                                                .GetField(value.ToString())
                                                .GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
コード例 #2
0
        public static string GetDescription(this SyncMode mode)
        {
            FieldInfo fi   = mode.GetType().GetField(mode.ToString());
            var       desc = fi.GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];

            if (null != desc && desc.Length > 0)
            {
                return(desc[0].Description);
            }
            else
            {
                return(mode.ToString());
            }
        }