Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Inputter  inputter  = new Inputter(args);
            Rotator   rotator   = new Rotator();
            Indexor   indexor   = new Indexor();
            Outputter outputter = new Outputter();

            Bus.Register("start", delegate(object data) {
                Bus.Fire("input-completed", inputter.Input());
            });

            Bus.Register("input-completed", delegate(object data) {
                Bus.Fire("rotate-completed", rotator.Rotate((LinkedList <string>)data));
            });

            Bus.Register("rotate-completed", delegate(object data) {
                Bus.Fire("index-completed", indexor.Index((LinkedList <string>)data));
            });

            Bus.Register("index-completed", delegate(object data) {
                outputter.Output((List <string>)data);

                Bus.Fire("output-completed");
            });

            Bus.Fire("start");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Inputter  input  = new Inputter(args);
            Rotator   rot    = new Rotator();
            Indexor   idx    = new Indexor();
            Outputter output = new Outputter(args);

            output.Output(idx.Index(rot.Rotate(input.Input())));
            //disadvantage have to know the signatures to all methods otherwise cant do this^.
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Inputter input;

            // If there is no input specified, or there is a single argument, load the input from a file.
            if (args.Length <= 2)
            {
                input = new Inputter(args);
            }

            // Otherwise the input is specified as a string, with a prefix "string", so skip the first argument and load the rest.
            else
            {
                input = new StringInputter(args.Skip(1).ToArray());
            }

            Rotator   rot    = new Rotator();
            Indexor   idx    = new Indexor();
            Outputter output = new Outputter(args);

            output.Output(idx.Index(rot.Rotate(input.Input())));
            //disadvantage have to know the signatures to all methods otherwise cant do this^.
        }