/// <summary> /// Get the class instance of a field/property/method /// </summary> /// <param name="path"></param> /// <param name="property"></param> /// <returns></returns> private static object GetLocalProperty(IEnumerable <string> path, object property) { foreach (string segment in path) { Property propertyInfo = PathParser.BreakVariable(segment); property = Reflect.CallGeneric(property, propertyInfo.Name); // If there was a subscript get the data object if ((property is IList) && (propertyInfo.Index != null)) { if (property is IDictionary) { property = ((IDictionary)property)[propertyInfo.Index]; } else { property = ((IList)property)[(int)propertyInfo.Index]; } } } return(property); }
/// <summary> /// Get the static field/property/method of the class /// </summary> /// <param name="attribute"></param> /// <param name="path"></param> /// <returns></returns> private static object GetStaticProperty(DataListAttribute attribute, IList <string> path) { Type type; object property; string segment; int count = 0; type = ClassType.GetType(attribute.DllName, attribute.ClassName); segment = path[count++]; property = Reflect.GetStaticDataMember(type, segment); for ( ; count < path.Count; count++) { segment = path[count]; Property propertyInfo = PathParser.BreakVariable(segment); property = Reflect.GetDataMember(property, propertyInfo.Name); // If there was a subscript get the data object if (propertyInfo.Index != null) { if (property is IDictionary) { property = ((IDictionary)property)[propertyInfo.Index]; } else if (property is IList) { property = ((IList)property)[(int)propertyInfo.Index]; } } } return(property); }