Пример #1
0
        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);
        }
Пример #2
0
 /// <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>());
 }
Пример #3
0
        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;
        }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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>());
        }
Пример #7
0
 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);
 }
Пример #8
0
 /// <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>();
 }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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>()));
        }
Пример #12
0
        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));
        }