用属性来传值

定义:   

[Serializable]
    [System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple = true)]
    public class ParameterMappingAttribute : System.Attribute
    {
        private string mstrVariableName = "";

        public ParameterMappingAttribute()
        {
        }

        public ParameterMappingAttribute(string pstrVariableName)
        {
            mstrVariableName = pstrVariableName;
        }

        public string VariableName
        {
            get { return this.mstrVariableName; }
            set { this.mstrVariableName = value; }
        }
    }

使用:
private string mEv;

[ParameterMapping("xxxxxx")]
        public string Ev
        {
            set { this.mEv = value; }
            get { return this.mEv; }
        }

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页