Пример #1
0
        public static string GetDescription(ErrorType type)
        {
            FieldInfo            info = type.GetType().GetField(type.ToString());
            DescriptionAttribute attr = (DescriptionAttribute)info.GetCustomAttribute(typeof(DescriptionAttribute));

            return(attr != null ? attr.Description : "");
        }
Пример #2
0
        private async Task SendErrorMessage(ErrorType type, params string[] parameters)
        {
            var descriptionAttribute = type.GetType().GetField(type.ToString()).GetCustomAttribute <DescriptionAttribute>(false);
            var sendMessage          = string.Empty;

            if (descriptionAttribute == null)
            {
                sendMessage = type.ToString();
            }
            else
            {
                sendMessage = string.Format(descriptionAttribute.Description, parameters);
            }
            await m_userMessage.Channel.SendMessageAsync(sendMessage);
        }
Пример #3
0
        public static string GetEnumDescription(ErrorType value)
        {
            var fi = value.GetType().GetField(value.ToString());

            var attributes =
                (DescriptionAttribute[])fi.GetCustomAttributes(
                    typeof(DescriptionAttribute),
                    false);

            if (attributes != null &&
                attributes.Length > 0)
            {
                return(attributes[0].Description);
            }
            else
            {
                return(value.ToString());
            }
        }
Пример #4
0
    private static string GetErrorType(ErrorType errorType)
    {
        var da = (DescriptionAttribute[])(errorType.GetType().GetField(errorType.ToString())).GetCustomAttributes(typeof(DescriptionAttribute), false);

        return(da.Length > 0 ? da[0].Description : errorType.ToString());
    }