/// <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); }
/// <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); }
public virtual void Remove(PropertyPathPoint value) { List.Remove(value); }
public void Insert(int index, PropertyPathPoint value) { List.Insert(index, value); }
public int IndexOf(PropertyPathPoint value) { return(List.IndexOf(value)); }
public bool Contains(PropertyPathPoint value) { return(List.Contains(value)); }
public virtual int Add(PropertyPathPoint value) { return(List.Add(value)); }