internal bool GetIsValidReferenceGetValue(object obj) { if (!GetReferenceValidCompiled.Value.ContainsKey(obj.GetType())) { var list = new List <Tuple <Type, PropertyInfo> >(); var propertyPaths = AccessorPath.Split('.'); var type = obj.GetType(); foreach (var path in propertyPaths) { PropertyInfo property = null; // Loop until we found a base type supporting the property path while (type != null) { property = type.GetProperty(path, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { break; } type = type.BaseType; } if (property == null) { throw new Exception("Property could not be resolved: " + path + " FullName:" + propertyPaths); } list.Add(new Tuple <Type, PropertyInfo>(type, property)); type = property.PropertyType; } GetValueAccessorCount = list.Count; if (list.Count == 1) { return(true); } GetReferenceValidCompiled.Value[obj.GetType()] = Utility.CreateGetReferenceValidFunc(list); } var fastGet = GetReferenceValidCompiled.Value[obj.GetType()]; return(fastGet(obj)); }
internal void SetValueFastSet(object obj, object valueItem) { if (!SetValueFastSets.Value.ContainsKey(obj.GetType())) { var list = new List <Tuple <Type, PropertyInfo> >(); var propertyPaths = AccessorPath.Split('.'); var type = obj.GetType(); foreach (var path in propertyPaths) { PropertyInfo property = null; // Loop until we found a base type supporting the property path while (type != null) { property = type.GetProperty(path, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (property != null) { break; } type = type.BaseType; } if (property == null) { throw new Exception("Property could not be resolved: " + path + " FullName:" + propertyPaths); } list.Add(new Tuple <Type, PropertyInfo>(type, property)); type = property.PropertyType; } SetValueFastSets.Value[obj.GetType()] = Utility.CreateSetFunc(list); } var fastSet = SetValueFastSets.Value[obj.GetType()]; fastSet(obj, valueItem); }