SHARE
TWEET

Untitled

a guest Dec 11th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     interface IFilter<I,O>
  2.     {
  3.         void OnInput(object sender, I args);
  4.     }
  5.  
  6.     class AbstractFilter<I,O> : IFilter<I,O>
  7.     {
  8.         public delegate void InputEventHandler(I args);
  9.         public delegate void OutputEventHandler(O args);
  10.  
  11.         public event OutputEventHandler Processed;
  12.  
  13.         public void OnInput(object sender, I args)
  14.         {
  15.             throw new NotImplementedException();
  16.         }
  17.     }
  18.  
  19.     class IntToDoubleFilter : AbstractFilter<Int32,Double>
  20.     {
  21.         public event AbstractFilter<int, double>.OutputEventHandler Processed;
  22.  
  23.         public void OnInput(int args)
  24.         {
  25.             Double dbl = Convert.ToDouble(args);
  26.             Processed(args);
  27.         }
  28.     }
  29.  
  30.     class DoubleToStringFilter : AbstractFilter<Double,String>
  31.     {
  32.         public event AbstractFilter<double, string>.OutputEventHandler Processed;
  33.  
  34.         public void OnInput(double args)
  35.         {
  36.             String s = args.ToString();
  37.             Processed(s);
  38.         }
  39.     }
  40.  
  41.     private void button1_Click(object sender, EventArgs e)
  42.     {
  43.         int i = 100000;
  44.  
  45.         IntToDoubleFilter f1 = new IntToDoubleFilter();
  46.         DoubleToStringFilter f2 = new DoubleToStringFilter();
  47.  
  48.         f1.Processed += f2.OnInput;
  49.         f2.Processed += ShowString;
  50.  
  51.         f1.OnInput(i);
  52.      }
  53.  
  54.      private void ShowString(String str) {
  55.             MessageBox.Show(str);
  56.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top