Beispiel #1
0
        static public bool InspectAdd(this IEnumerable item, object value)
        {
            if (item != null)
            {
                MethodInfoEX method = item.GetType().GetFilteredInstanceMethods(
                    Filterer_MethodInfo.IsNamed("Add"),
                    Filterer_MethodInfo.HasOneEffectiveParameter()
                    ).GetFirst();
                if (method != null)
                {
                    if (value == null)
                    {
                        value = method.GetEffectiveParameterType(0).GetDefaultValue();
                    }

                    method.Invoke(item, new object[] { value });
                    return(true);
                }

                return(item.InspectInsert(
                           item.InspectCount(),
                           value
                           ));
            }

            return(false);
        }
Beispiel #2
0
        static public bool InspectRemove(this IEnumerable item, object value)
        {
            if (item != null)
            {
                MethodInfoEX method = item.GetType().GetFilteredInstanceMethods(
                    Filterer_MethodInfo.IsNamed("Remove"),
                    Filterer_MethodInfo.HasOneEffectiveParameter()
                    ).GetFirst();
                if (method != null)
                {
                    method.Invoke(item, new object[] { value });
                    return(true);
                }
            }

            return(false);
        }