namespace Overboard.Linq {
using System;
using System.Linq.Expressions;
/// <summary>
/// Provides a set of <see langword="static"/> factory methods for creating instances of <see cref="ExpressionMethod{TDelegate}"/> while taking full advantage of type inference.
/// </summary>
public static class ExpressionMethod {
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="TResult">The type of the return value of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Func<TResult>> Create<TResult>(Expression<Func<TResult>> expression) {
return new ExpressionMethod<Func<TResult>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T">The type of the parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="TResult">The type of the return value of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<T, TResult> Create<T, TResult>(Expression<Func<T, TResult>> expression) {
return new ExpressionMethod<T, TResult>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="TResult">The type of the return value of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Func<T1, T2, TResult>> Create<T1, T2, TResult>(Expression<Func<T1, T2, TResult>> expression) {
return new ExpressionMethod<Func<T1, T2, TResult>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="TResult">The type of the return value of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Func<T1, T2, T3, TResult>> Create<T1, T2, T3, TResult>(Expression<Func<T1, T2, T3, TResult>> expression) {
return new ExpressionMethod<Func<T1, T2, T3, TResult>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="TResult">The type of the return value of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Func<T1, T2, T3, T4, TResult>> Create<T1, T2, T3, T4, TResult>(Expression<Func<T1, T2, T3, T4, TResult>> expression) {
return new ExpressionMethod<Func<T1, T2, T3, T4, TResult>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Action> Create(Expression<Action> expression) {
return new ExpressionMethod<Action>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T">The type of the parameter of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Action<T>> Create<T>(Expression<Action<T>> expression) {
return new ExpressionMethod<Action<T>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Action<T1, T2>> Create<T1, T2>(Expression<Action<T1, T2>> expression) {
return new ExpressionMethod<Action<T1, T2>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Action<T1, T2, T3>> Create<T1, T2, T3>(Expression<Action<T1, T2, T3>> expression) {
return new ExpressionMethod<Action<T1, T2, T3>>(expression);
}
/// <summary>
/// Create an instance of <see cref="ExpressionMethod{TDelegate}" /> from the underlying expression tree.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T3">The type of the third parameter of the expression to be encapsulated.</typeparam>
/// <typeparam name="T4">The type of the fourth parameter of the expression to be encapsulated.</typeparam>
/// <param name="expression">The expression to be encapsulated.</param>
/// <returns>An <see cref="ExpressionMethod{TDelegate}" /> which encapsulates an expression tree and its corresponding delegate.</returns>
public static ExpressionMethod<Action<T1, T2, T3, T4>> Create<T1, T2, T3, T4>(Expression<Action<T1, T2, T3, T4>> expression) {
return new ExpressionMethod<Action<T1, T2, T3, T4>>(expression);
}
}
}