在类的实例中缺少属性

时间:2016-11-03 10:29:12

标签: c# android xamarin reflection

我在Android应用程序中编写通用方法,我遇到了缺少属性的问题。 我的班级有7个公共属性,但是当我想要获得所有属性时,我得到一个属性的列表。
这是我的代码:

T item = (T)Activator.CreateInstance(typeof(T));
var properties = item.GetType().GetProperties();

所有课程都会出现问题 我在iOS的类似应用程序中有相同的代码(也是相同的类),一切正常。

以下是示例类:

public partial class DB_USER {

        private int iD_USERField;

        private int iD_ACTORField;

        private System.Nullable<long> iD_DISTRIBUTORField;

        private string lOGINField;

        private string pASSWORDField;

        private bool iS_BLOCKEDField;

        private string dESCRIPTIONField;

        /// <remarks/>
        public int ID_USER {
            get {
                return this.iD_OPERATORField;
            }
            set {
                this.iD_OPERATORField = value;
            }
        }

        /// <remarks/>
        public int ID_ACTOR {
            get {
                return this.iD_ACTORField;
            }
            set {
                this.iD_ACTORField = value;
            }
        }

          /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public System.Nullable<long> ID_DISTRIBUTOR {
            get {
                return this.iD_DISTRIBUTORField;
            }
            set {
                this.iD_DISTRIBUTORField = value;
            }
        }

        /// <remarks/>
        public string LOGIN {
            get {
                return this.lOGINField;
            }
            set {
                this.lOGINField = value;
            }
        }

        /// <remarks/>
        public string PASSWORD {
            get {
                return this.pASSWORDField;
            }
            set {
                this.pASSWORDField = value;
            }
        }

        /// <remarks/>
        public bool IS_BLOCKED {
            get {
                return this.iS_BLOCKEDField;
            }
            set {
                this.iS_BLOCKEDField = value;
            }
        }

        /// <remarks/>
        public string DESCRIPTION {
            get {
                return this.dESCRIPTIONField;
            }
            set {
                this.dESCRIPTIONField = value;
            }
        }
    }

0 个答案:

没有答案