Exemplo n.º 1
0
 /// <summary>
 /// Invokes procedure.
 /// </summary>
 /// <typeparam name="T">The type of the explicit <c>this</c> argument.</typeparam>
 /// <param name="procedure">The procedure to be invoked.</param>
 /// <param name="instance">Explicit <c>this</c> argument.</param>
 public static void Invoke <T>(this Procedure <T, ValueTuple> procedure, in T instance)
Exemplo n.º 2
0
 /// <summary>
 /// Converts <see cref="Procedure{T, A}"/> into <see cref="Procedure{A}"/> through
 /// capturing of the first argument of <see cref="Procedure{T, A}"/> delegate.
 /// </summary>
 /// <typeparam name="T">Type of instance to be passed into underlying method.</typeparam>
 /// <typeparam name="A">Type of structure with procedure arguments allocated on the stack.</typeparam>
 /// <param name="procedure">The procedure to be converted.</param>
 /// <param name="this">The first argument to be captured.</param>
 /// <returns>The procedure instance.</returns>
 public static Procedure <A> Capture <T, A>(this Procedure <T, A> procedure, T @this) where A : struct => new Closure <T, A>(procedure, @this).Invoke;
Exemplo n.º 3
0
 /// <summary>
 /// Allocates list of arguments on the stack.
 /// </summary>
 /// <typeparam name="T">Type of explicit <c>this</c> argument.</typeparam>
 /// <typeparam name="A">The type representing list of arguments.</typeparam>
 /// <param name="procedure">The procedure instance.</param>
 /// <returns>Allocated list of arguments.</returns>
 public static A ArgList <T, A>(this Procedure <T, A> procedure)
     where A : struct
 => new A();
Exemplo n.º 4
0
 internal Closure(Procedure <T, A> procedure, T target)
 {
     this.procedure = procedure;
     this.target    = target;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Invokes procedure.
 /// </summary>
 /// <typeparam name="T">The type of the explicit <c>this</c> argument.</typeparam>
 /// <param name="procedure">The procedure to be invoked.</param>
 /// <param name="instance">Explicit <c>this</c> argument.</param>
 public static void Invoke <T>(this Procedure <T, ValueTuple> procedure, [DisallowNull] in T instance)
Exemplo n.º 6
0
 /// <summary>
 /// Allocates list of arguments on the stack.
 /// </summary>
 /// <typeparam name="T">Type of explicit <c>this</c> argument.</typeparam>
 /// <typeparam name="TArgs">The type representing list of arguments.</typeparam>
 /// <param name="procedure">The procedure instance.</param>
 /// <returns>Allocated list of arguments.</returns>
 public static TArgs ArgList <T, TArgs>(this Procedure <T, TArgs> procedure)
     where TArgs : struct
 => new TArgs();
Exemplo n.º 7
0
 /// <summary>
 /// Converts <see cref="Procedure{T, A}"/> into <see cref="Procedure{A}"/> through
 /// capturing of the first argument of <see cref="Procedure{T, A}"/> delegate.
 /// </summary>
 /// <typeparam name="T">Type of instance to be passed into underlying method.</typeparam>
 /// <typeparam name="TArgs">Type of structure with procedure arguments allocated on the stack.</typeparam>
 /// <param name="procedure">The procedure to be converted.</param>
 /// <param name="this">The first argument to be captured.</param>
 /// <returns>The procedure instance.</returns>
 public static Procedure <TArgs> Bind <T, TArgs>(this Procedure <T, TArgs> procedure, [DisallowNull] T @this)
     where TArgs : struct
 => new Closure <T, TArgs>(procedure, @this).Invoke;
Exemplo n.º 8
0
 internal Closure(Procedure <T, TArgs> procedure, [DisallowNull] T target)
 {
     this.procedure = procedure;
     this.target    = target;
 }