Example #1
0
    public static string ToEngFormat <T, T2>(this System.Collections.Generic.IEnumerable <T> collection, string word, System.Func <T, T2> select, System.Func <T2, bool> where, System.Func <T2, string> select2)
    {
        System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
        if (typeof(T).IsValueType)
        {
            using (System.Collections.Generic.IEnumerator <T> enumerator = collection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T      current = enumerator.Current;
                    T2     arg     = select(current);
                    string item;
                    if (where (arg) && !string.IsNullOrEmpty(item = select2(arg)))
                    {
                        list.Add(item);
                    }
                }
                goto IL_CE;
            }
        }
        foreach (T current2 in collection)
        {
            T2     arg;
            string item;
            if (current2 != null && (arg = select(current2)) != null && where (arg) && !string.IsNullOrEmpty(item = select2(arg)))
            {
                list.Add(item);
            }
        }
IL_CE:
        return(RCextensions.HandleEngFormat(word, list));
    }
Example #2
0
    public static string ToEngFormat <T>(this IEnumerable <T> collection, string word, Func <T, string> select)
    {
        List <string> list = new List <string>();

        if (typeof(T).IsValueType)
        {
            using (IEnumerator <T> enumerator = collection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T      arg = enumerator.Current;
                    string item;
                    if (!string.IsNullOrEmpty(item = select(arg)))
                    {
                        list.Add(item);
                    }
                }
                goto IL_A2;
            }
        }
        foreach (T t in collection)
        {
            string item2;
            if (t != null && !string.IsNullOrEmpty(item2 = select(t)))
            {
                list.Add(item2);
            }
        }
IL_A2:
        return(RCextensions.HandleEngFormat(word, list));
    }
Example #3
0
    public static string ToEngFormat <T>(this IEnumerable <T> collection, string word = "and")
    {
        Func <T, string> func = null;
        List <string>    list = new List <string>();

        if (typeof(T).IsValueType)
        {
            foreach (T current in collection)
            {
                string item3;
                if (!string.IsNullOrEmpty(item3 = current.ToString()))
                {
                    list.Add(item3);
                }
            }
            if (func == null)
            {
                func = ((T item) => item.ToString());
            }
            list = new List <string>(Enumerable.Select <T, string>(collection, func));
        }
        else
        {
            foreach (T current2 in collection)
            {
                string item2;
                if (current2 != null && !string.IsNullOrEmpty(item2 = current2.ToString()))
                {
                    list.Add(item2);
                }
            }
        }
        return(RCextensions.HandleEngFormat(word, list));
    }