Esempio n. 1
0
        /// <summary>
        /// 向属性树的最前面加一个新的属性节点
        /// </summary>
        /// <param name="propertyInfo"></param>
        public void CombineToFore(PropertyInfo propertyInfo)
        {
            PropertyPathPoint pathPoint = new PropertyPathPoint(propertyInfo);

            if (this.ForePathPoint != null)
            {
                pathPoint.Next = this.ForePathPoint;
            }

            this.Insert(0, pathPoint);
        }
Esempio n. 2
0
        /// <summary>
        /// 取到指定路径节点的值
        /// </summary>
        /// <param name="pathPoint"></param>
        /// <returns></returns>
        public object GetValue(object obj, PropertyPathPoint point)
        {
            if (this.Count == 1 && this.ForePathPoint == point)
            {
                return(obj);
            }

            object       objTemp = obj;
            Type         type    = obj.GetType();
            PropertyInfo propertyInfo;

            foreach (PropertyPathPoint pathPoint in this)
            {
                propertyInfo = type.GetProperty(pathPoint.Property.Name, pathPoint.Property.PropertyType);
                if (propertyInfo == null)
                {
                    Debug.Assert(false);
                    return(null);
                }

                if (propertyInfo.PropertyType.IsEnum)
                {
                    objTemp = (int)Enum.Parse(propertyInfo.PropertyType, propertyInfo.GetValue(objTemp, null).ToString());
                }
                else
                {
                    objTemp = propertyInfo.GetValue(objTemp, null);
                }

                if (pathPoint == point)
                {
                    break;
                }

                type = propertyInfo.PropertyType;
            }

            return(objTemp);
        }
Esempio n. 3
0
 public virtual void Remove(PropertyPathPoint value)
 {
     List.Remove(value);
 }
Esempio n. 4
0
 public void Insert(int index, PropertyPathPoint value)
 {
     List.Insert(index, value);
 }
Esempio n. 5
0
 public int IndexOf(PropertyPathPoint value)
 {
     return(List.IndexOf(value));
 }
Esempio n. 6
0
 public bool Contains(PropertyPathPoint value)
 {
     return(List.Contains(value));
 }
Esempio n. 7
0
 public virtual int Add(PropertyPathPoint value)
 {
     return(List.Add(value));
 }