Popular Posts
Export list schema from sharepoint http:// YOUR_SERVER_URL / PATH_TO_SITE_CONTAINING_LIST /_vti_bin/owssvr.dll?Cmd=ExportList&List= {YOUR_LIST_GUID} JSRequest, Get parameters from querystring with javascript in SharePoint Provides method to parse query string, filename, and pathname from URL // Initialize first JSRequest.EnsureSetup(); // Get the current fil... ROBOCOPY: Robust File Copy for Windows -------------------------------------------------------------------------------    ROBOCOPY     ::     Robust File Copy for Windows --------...
Stats
Linq: Loop extension
using System;
using System.Collections.Generic;
using System.Text;

namespace System.Linq
{
    public static class GenericEachExtension
    {
        public static IEnumerable<T> Each<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (T t in source)
            {
                action.Invoke(t);
            }
            return source;
        }

        public static IEnumerable<T> Each<T>(this IEnumerable<T> source, Func<T, bool> action)
        {
            foreach (T t in source)
            {
                if (!action.Invoke(t)) break;
            }
            return source;
        }

        public static IEnumerable<T> Each<T>(this IEnumerable<T> source, Action<T, int> action)
        {
            int i = 0;
            foreach (T t in source)
            {
                action.Invoke(t, i);
                i++;
            }
            return source;
        }

        public static IEnumerable<T> Each<T>(this IEnumerable<T> source, Func<T, int, bool> action)
        {
            int i = 0;
            foreach (T t in source)
            {
                if (!action.Invoke(t, i)) break;
                i++;
            }
            return source;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Collections
{
    public static class EachExtension
    {
        public static IEnumerable Each<T>(this IEnumerable source, Action<T> action)
        {
            foreach (T t in source)
            {
                action.Invoke(t);
            }
            return source;
        }

        public static IEnumerable Each<T>(this IEnumerable source, Func<T, bool> action)
        {
            foreach (T t in source)
            {
                if (!action.Invoke(t)) break;
            }
            return source;
        }

        public static IEnumerable Each<T>(this IEnumerable source, Action<T, int> action)
        {
            int i = 0;
            foreach (T t in source)
            {
                action.Invoke(t, i);
                i++;
            }
            return source;
        }

        public static IEnumerable Each<T>(this IEnumerable source, Func<T, int, bool> action)
        {
            int i = 0;
            foreach (T t in source)
            {
                if (!action.Invoke(t, i)) break;
                i++;
            }
            return source;
        }

        public static IEnumerable Each(this IEnumerable source, Action<object> action)
        {
            foreach (object t in source)
            {
                action.Invoke(t);
            }
            return source;
        }

        public static IEnumerable Each(this IEnumerable source, Func<object, bool> action)
        {
            foreach (object t in source)
            {
                if (!action.Invoke(t)) break;
            }
            return source;
        }

        public static IEnumerable Each(this IEnumerable source, Action<object, int> action)
        {
            int i = 0;
            foreach (object t in source)
            {
                action.Invoke(t, i);
                i++;
            }
            return source;
        }

        public static IEnumerable Each(this IEnumerable source, Func<object, int, bool> action)
        {
            int i = 0;
            foreach (object t in source)
            {
                if (!action.Invoke(t, i)) break;
                i++;
            }
            return source;
        }
    }
}
View mobile version