示例#1
0
        public virtual List <MsgTemplateParmater> GetParmaterList()
        {
            Type type = GetType();
            var  ps   = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            List <MsgTemplateParmater> list = new List <MsgTemplateParmater>(4);

            foreach (var p in ps)
            {
                var desca = p.GetCustomAttribute(typeof(MsgTemplateParameterDescriptionAttribute));
                if (desca != null)
                {
                    MsgTemplateParameterDescriptionAttribute desc = desca as MsgTemplateParameterDescriptionAttribute;
                    object v = p.GetValue(this);
                    list.Add(new MsgTemplateParmater
                    {
                        Name        = string.IsNullOrWhiteSpace(desc.Name) ? p.Name : desc.Name,
                        Index       = desc.Index,
                        Value       = v == null ? "" : v.ToString(),
                        Color       = desc.Color,
                        DisplayName = desc.DisplayName
                    });
                }
            }
            return(list);
        }
示例#2
0
        /// <summary>
        /// 模版参数
        /// </summary>
        /// <returns></returns>
        public virtual Dictionary <string, string> GetParmaters()
        {
            Type type = GetType();
            var  ps   = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            Dictionary <string, string> list = new Dictionary <string, string>();

            foreach (var p in ps)
            {
                var desca = p.GetCustomAttribute(typeof(MsgTemplateParameterDescriptionAttribute));
                if (desca != null)
                {
                    object v = p.GetValue(this);
                    MsgTemplateParameterDescriptionAttribute desc = desca as MsgTemplateParameterDescriptionAttribute;
                    string n = string.IsNullOrWhiteSpace(desc.Name) ? p.Name : desc.Name;
                    list.Add("{" + p.Name + "}", v == null ? "" : v.ToString());
                }
            }
            return(list);
        }