예제 #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);
        }
예제 #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);
        }
예제 #3
0
 public virtual void Remove(PropertyPathPoint value)
 {
     List.Remove(value);
 }
예제 #4
0
 public void Insert(int index, PropertyPathPoint value)
 {
     List.Insert(index, value);
 }
예제 #5
0
 public int IndexOf(PropertyPathPoint value)
 {
     return(List.IndexOf(value));
 }
예제 #6
0
 public bool Contains(PropertyPathPoint value)
 {
     return(List.Contains(value));
 }
예제 #7
0
 public virtual int Add(PropertyPathPoint value)
 {
     return(List.Add(value));
 }