Advertisement
Guest User

Untitled

a guest
May 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Security.Cryptography;
  4.  
  5. namespace nucleardemo
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Func<string, string> pipeline = s => s
  12. .pipe(File.OpenRead)
  13. .pipe(MD5.Create().ComputeHash)
  14. .pipe(Convert.ToBase64String);
  15.  
  16. Func<string> sink = Console.ReadLine;
  17. Action<string> drain = Console.WriteLine;
  18.  
  19. sink.ring(drain, pipeline);
  20. }
  21. }
  22.  
  23. public static class Ex
  24. {
  25. public static R pipe<T, R>(this T input, Func<T, R> transformer)
  26. {
  27. return transformer(input);
  28. }
  29.  
  30. public static void pipe<T>(this T input, Action<T> mutator)
  31. {
  32. mutator(input);
  33. }
  34.  
  35. public static void ring<T, R>(this Func<T> sink, Action<R> drain, Func<T, R> pipeline)
  36. {
  37. sink()
  38. .pipe(pipeline)
  39. .pipe(drain);
  40.  
  41. sink.ring(drain, pipeline);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement