Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Security.Cryptography;
- namespace nucleardemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Func<string, string> pipeline = s => s
- .pipe(File.OpenRead)
- .pipe(MD5.Create().ComputeHash)
- .pipe(Convert.ToBase64String);
- Func<string> sink = Console.ReadLine;
- Action<string> drain = Console.WriteLine;
- sink.ring(drain, pipeline);
- }
- }
- public static class Ex
- {
- public static R pipe<T, R>(this T input, Func<T, R> transformer)
- {
- return transformer(input);
- }
- public static void pipe<T>(this T input, Action<T> mutator)
- {
- mutator(input);
- }
- public static void ring<T, R>(this Func<T> sink, Action<R> drain, Func<T, R> pipeline)
- {
- sink()
- .pipe(pipeline)
- .pipe(drain);
- sink.ring(drain, pipeline);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement