Ejemplo n.º 1
0
        public void Conventional_Configuration()
        {
            var graph = BehaviourGraph.GetPopulatedGraph();

            // all chains that talk to db need a session open and closed
            graph.WrapChainsConditionally<NHiberanteSessionBehavior>(chain => chain.Any(node => node.Type == typeof(RepositoryBehavior)));

            // Will take control of the chain and execute how it likes to
            graph.WrapChainsConditionally<ErrorHandlingBehaviour>(chain => chain.Any(node => node.Type == typeof(BrokenNode)));

            graph.EnrichChainsConditionally<GregzillaWarning>(chain => chain.Any(node => node.Type == typeof(Gregzilla)));

            // doesn't have to be just type - conventions can apply to anything - e.g. involving namespaces, output types, etc

            var runner = new Converter();
            Console.WriteLine("About to run chains....");
            foreach (var chain in graph.Chains)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("**********************************************************************");
                Console.WriteLine( );
                Console.WriteLine( );
                Console.WriteLine("About to execute chain...");
                Console.WriteLine();

                var behaviours = runner.ConvertBehaviourChainToBehaviours(chain);
                behaviours.Invoke();
            }
        }
Ejemplo n.º 2
0
        public void BehaviourChains_101()
        {
            var chain = new BehaviourChain();
            chain.Append(new BehaviourNode(typeof(Nick)));
            chain.Append(new BehaviourNode(typeof(Emily)));
            chain.Prepend(new BehaviourNode(typeof(Paul))); // wraps it
            chain.Prepend(new BehaviourNode(typeof(Gregzilla))); // wraps it

            var converter = new Converter();
            var behaviours = converter.ConvertBehaviourChainToBehaviours(chain);
            behaviours.Invoke();
        }