Example #1
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public void BuildSequence(IRevertableSequenceBuilder sequence)
            {
                sequence.Once().OnPerform(FindLifecycleComponents);

                sequence.ForEach(() => OwnerHost.LifecycleComponents)
                .OnPerform((component, index, isLast) =>
                           CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceLoading, component.MicroserviceLoading))
                .OnRevert((component, index, isLast) =>
                          CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceUnloaded, component.MicroserviceMaybeUnloaded));

                sequence.ForEach(() => OwnerHost.LifecycleComponents)
                .OnPerform((component, index, isLast) =>
                           CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceLoad, component.Load))
                .OnRevert((component, index, isLast) =>
                          CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceUnload, component.MayUnload));

                sequence.ForEach(() => OwnerHost.LifecycleComponents)
                .OnPerform((component, index, isLast) =>
                           CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceLoaded, component.MicroserviceLoaded))
                .OnRevert((component, index, isLast) =>
                          CallComponentsLifecycleStep(component, OwnerHost.Logger.MicroserviceUnloading, component.MicroserviceMaybeUnloading));

                /*sequence.Once().OnPerform(JoinSystemSession).OnRevert(LeaveSystemSession);
                *  ...
                *  sequence.Once().OnPerform(LeaveSystemSession).OnRevert(JoinSystemSession);*/
            }
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            void IRevertableSequenceCodeBehind.BuildSequence(IRevertableSequenceBuilder sequence)
            {
                sequence.Once().OnPerform(PerformOne).OnRevert(RevertOne);
                sequence.Once().OnPerform(PerformTwo).OnRevert(RevertTwo);
                sequence.Once().OnPerform(PerformThree);
                sequence.Once().OnRevert(RevertFour);

                if (_fiveItems != null)
                {
                    sequence.ForEach(() => _fiveItems).OnPerform(PerformFiveItem).OnRevert(RevertFiveItem);
                }

                if (_sixItems != null)
                {
                    sequence.ForEach(() => _sixItems).OnPerform(PerformSixItem);
                }

                if (_sevenItems != null)
                {
                    sequence.ForEach(() => _sevenItems).OnRevert(RevertSevenItem);
                }
            }
            //-------------------------------------------------------------------------------------------------------------------------------------------------
            void IRevertableSequenceCodeBehind.BuildSequence(IRevertableSequenceBuilder sequence)
            {
                sequence.Once().OnPerform(PerformOne).OnRevert(RevertOne);
                sequence.Once().OnPerform(PerformTwo).OnRevert(RevertTwo);
                sequence.Once().OnPerform(PerformThree);
                sequence.Once().OnRevert(RevertFour);

                if ( _fiveItems != null )
                {
                    sequence.ForEach(() => _fiveItems).OnPerform(PerformFiveItem).OnRevert(RevertFiveItem);
                }

                if ( _sixItems != null )
                {
                    sequence.ForEach(() => _sixItems).OnPerform(PerformSixItem);
                }

                if ( _sevenItems != null )
                {
                    sequence.ForEach(() => _sevenItems).OnRevert(RevertSevenItem);
                }
            }