示例#1
0
        /// <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);
        }