private static bool StoreChildValue(string propertyName, MethodInfo getter, IInterceptableType interceptable) { var newChild = getter.Invoke(interceptable, null); var existingChild = interceptable.GetChild(propertyName); interceptable.SetChild(propertyName, newChild); return(newChild != existingChild); }
/// <summary>Gets tags on a given item.</summary> /// <param name="item"></param> /// <param name="tagGroup"></param> /// <returns></returns> public static IEnumerable <string> GetTagsFromValues(IInterceptableType item, string tagGroup) { return(((item as IInterceptableType).GetValues(tagGroup) ?? new string[0]).OfType <string>()); }
private static bool StoreDetailCollectionValues(string propertyName, MethodInfo getter, IInterceptableType interceptable) { IEnumerable propertyValue = (IEnumerable)getter.Invoke(interceptable, null); var collectionValues = interceptable.GetValues(propertyName); if (propertyValue == null && collectionValues == null) return false; interceptable.SetValues(propertyName, collectionValues); return true; }
private static bool StoreDetailValue(Type propertyType, string propertyName, MethodInfo getter, IInterceptableType interceptable) { object propertyValue = getter.Invoke(interceptable, null); object detailValue = interceptable.GetValue(propertyName); if (propertyValue == null && detailValue == null) return false; if (propertyValue != null && propertyValue.Equals(detailValue)) return false; interceptable.SetValue(propertyName, propertyValue, propertyType); return true; }
private static bool StoreChildValue(string propertyName, MethodInfo getter, IInterceptableType interceptable) { var newChild = getter.Invoke(interceptable, null); var existingChild = interceptable.GetChild(propertyName); interceptable.SetChild(propertyName, newChild); return newChild != existingChild; }
private static bool StoreChildrenValue(string propertyName, MethodInfo getter, IInterceptableType interceptable) { var newChildren = getter.Invoke(interceptable, null) as IEnumerable; var existingChildren = interceptable.GetChildren(propertyName); interceptable.SetChildren(propertyName, newChildren); return (newChildren == null && existingChildren == null) && !(newChildren == null && existingChildren != null) && !(newChildren != null && existingChildren == null) && Enumerable.SequenceEqual(newChildren.OfType<object>(), existingChildren.OfType<object>()); }
private bool StoreValueAccessorValue(PropertyInfo property, MethodInfo getter, MethodInfo setter, IValueAccessor accessor, IInterceptableType interceptable) { var value = getter.Invoke(interceptable, null); var context = new ValueAccessorContext { Instance = interceptable, Property = property, BackingPropertyGetter = () => { throw new NotSupportedException("Getting property not supported while setting"); }, BackingPropertySetter = (v) => setter.Invoke(interceptable, new[] { v }) }; return accessor.SetValue(context, property.Name, value); }
/// <summary>Gets tags on a given item.</summary> /// <param name="item"></param> /// <param name="tagGroup"></param> /// <returns></returns> public static IEnumerable<string> GetTagsFromValues(IInterceptableType item, string tagGroup) { return ((item as IInterceptableType).GetValues(tagGroup) ?? new string[0]).OfType<string>(); }
private static bool StoreDetailCollectionValues(string propertyName, MethodInfo getter, IInterceptableType interceptable) { IEnumerable propertyValue = (IEnumerable)getter.Invoke(interceptable, null); var collectionValues = interceptable.GetValues(propertyName); if (propertyValue == null && collectionValues == null) { return(false); } interceptable.SetValues(propertyName, collectionValues); return(true); }
private static bool StoreDetailValue(Type propertyType, string propertyName, MethodInfo getter, IInterceptableType interceptable) { object propertyValue = getter.Invoke(interceptable, null); object detailValue = interceptable.GetValue(propertyName); if (propertyValue == null && detailValue == null) { return(false); } if (propertyValue != null && propertyValue.Equals(detailValue)) { return(false); } interceptable.SetValue(propertyName, propertyValue, propertyType); return(true); }
private static bool StoreChildrenValue(string propertyName, MethodInfo getter, IInterceptableType interceptable) { var newChildren = getter.Invoke(interceptable, null) as IEnumerable; var existingChildren = interceptable.GetChildren(propertyName); interceptable.SetChildren(propertyName, newChildren); return((newChildren == null && existingChildren == null) && !(newChildren == null && existingChildren != null) && !(newChildren != null && existingChildren == null) && Enumerable.SequenceEqual(newChildren.OfType <object>(), existingChildren.OfType <object>())); }
private bool StoreValueAccessorValue(PropertyInfo property, MethodInfo getter, MethodInfo setter, IValueAccessor accessor, IInterceptableType interceptable) { var value = getter.Invoke(interceptable, null); var context = new ValueAccessorContext { Instance = interceptable, Property = property, BackingPropertyGetter = () => { throw new NotSupportedException("Getting property not supported while setting"); }, BackingPropertySetter = (v) => setter.Invoke(interceptable, new[] { v }) }; return(accessor.SetValue(context, property.Name, value)); }