Esempio n. 1
0
        private void InvokeMissedPageLifeCycleEvents(LifeCycleEventType targetEventType, bool isMissingInvoke)
        {
            // just a quick check to save GetValue call
            if (lastLifeCycleEvent >= targetEventType || parent.LifecycleRequirements == ControlLifecycleRequirements.None)
            {
                return;
            }

            var context = (IDotvvmRequestContext?)parent.GetValue(Internal.RequestContextProperty);

            if (context == null)
            {
                throw new DotvvmControlException(parent, "InvokeMissedPageLifeCycleEvents must be called on a control rooted in a view.");
            }

            DotvvmControl lastProcessedControl = parent;

            try
            {
                InvokeMissedPageLifeCycleEvent(context, targetEventType, isMissingInvoke, ref lastProcessedControl);
            }
            catch (DotvvmInterruptRequestExecutionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DotvvmControlException(lastProcessedControl, "Unhandled exception occurred while executing page lifecycle event.", ex);
            }
        }
Esempio n. 2
0
 private void SetLastLifeCycleEvent(LifeCycleEventType eventType)
 {
     if (lastLifeCycleEvent < eventType)
     {
         lastLifeCycleEvent = eventType;
     }
 }
Esempio n. 3
0
        private void InvokeMissedPageLifeCycleEvent(IDotvvmRequestContext context, LifeCycleEventType targetEventType, bool isMissingInvoke, ref DotvvmControl lastProcessedControl)
        {
            ValidateParentsLifecycleEvents();

            isInvokingEvent = true;
            for (var eventType = lastLifeCycleEvent + 1; eventType <= targetEventType; eventType++)
            {
                // get ControlLifecycleRequirements flag for the event
                var reqflag = (1 << ((int)eventType - 1));
                if (isMissingInvoke)
                {
                    reqflag = reqflag << 5;
                }
                // abort when control does not require that
                if ((parent.LifecycleRequirements & (ControlLifecycleRequirements)reqflag) == 0)
                {
                    continue;
                }

                lastProcessedControl = parent;
                switch (eventType)
                {
                case LifeCycleEventType.PreInit:
                    parent.OnPreInit(context);
                    break;

                case LifeCycleEventType.Init:
                    parent.OnInit(context);
                    break;

                case LifeCycleEventType.Load:
                    parent.OnLoad(context);
                    break;

                case LifeCycleEventType.PreRender:
                    parent.OnPreRender(context);
                    break;

                case LifeCycleEventType.PreRenderComplete:
                    parent.OnPreRenderComplete(context);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(eventType), eventType, null);
                }

                lastLifeCycleEvent = eventType;

                foreach (var child in controls)
                {
                    child.Children.InvokeMissedPageLifeCycleEvent(context, eventType, isMissingInvoke && eventType == targetEventType, ref lastProcessedControl);
                }
            }
            isInvokingEvent = false;
        }
        private void InvokeMissedPageLifeCycleEvent(IDotvvmRequestContext context, LifeCycleEventType targetEventType, ref DotvvmControl lastProcessedControl)
        {
            for (var eventType = lastLifeCycleEvent + 1; eventType <= targetEventType; eventType++)
            {
                var action = GetPageLifeCycleEventAction(eventType, context);
                lastProcessedControl = parent;
                action(parent);

                foreach (var child in controls)
                {
                    child.Children.InvokeMissedPageLifeCycleEvent(context, eventType, ref lastProcessedControl);
                }
                lastLifeCycleEvent = eventType;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Invokes missed page life cycle events on the control.
        /// </summary>
        private void InvokeMissedPageLifeCycleEvents(LifeCycleEventType targetEventType)
        {
            var           context = (IDotvvmRequestContext)parent.GetValue(Internal.RequestContextProperty);
            DotvvmControl lastProcessedControl = parent;

            try
            {
                InvokeMissedPageLifeCycleEvent(context, targetEventType, ref lastProcessedControl);
            }
            catch (DotvvmInterruptRequestExecutionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DotvvmControlException(lastProcessedControl, "Unhandled exception occured while executing page lifecycle event.", ex);
            }
        }
        private void Notify(DataProcessingRegistration dataProcessingRegistration, LifeCycleEventType changeType)
        {
            switch (changeType)
            {
            case LifeCycleEventType.Created:
                _domainEvents.Raise(new EntityCreatedEvent <DataProcessingRegistration>(dataProcessingRegistration));
                break;

            case LifeCycleEventType.Updated:
                _domainEvents.Raise(new EntityUpdatedEvent <DataProcessingRegistration>(dataProcessingRegistration));
                break;

            case LifeCycleEventType.Deleted:
                _domainEvents.Raise(new EntityDeletedEvent <DataProcessingRegistration>(dataProcessingRegistration));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(changeType), changeType, null);
            }
        }
Esempio n. 7
0
        private void InvokeMissedPageLifeCycleEvent(IDotvvmRequestContext context, LifeCycleEventType targetEventType, ref DotvvmControl lastProcessedControl)
        {
            for (var eventType = lastLifeCycleEvent + 1; eventType <= targetEventType; eventType++)
            {
                lastProcessedControl = parent;
                switch (eventType)
                {
                case LifeCycleEventType.PreInit:
                    parent.OnPreInit(context);
                    break;

                case LifeCycleEventType.Init:
                    parent.OnInit(context);
                    break;

                case LifeCycleEventType.Load:
                    parent.OnLoad(context);
                    break;

                case LifeCycleEventType.PreRender:
                    parent.OnPreRender(context);
                    break;

                case LifeCycleEventType.PreRenderComplete:
                    parent.OnPreRenderComplete(context);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(eventType), eventType, null);
                }

                lastLifeCycleEvent = eventType;

                foreach (var child in controls)
                {
                    child.Children.InvokeMissedPageLifeCycleEvent(context, eventType, ref lastProcessedControl);
                }
            }
        }
        private static Action <DotvvmControl> GetPageLifeCycleEventAction(LifeCycleEventType eventType, IDotvvmRequestContext context)
        {
            switch (eventType)
            {
            case LifeCycleEventType.PreInit:
                return(c => c.OnPreInit(context));

            case LifeCycleEventType.Init:
                return(c => c.OnInit(context));

            case LifeCycleEventType.Load:
                return(c => c.OnLoad(context));

            case LifeCycleEventType.PreRender:
                return(c => c.OnPreRender(context));

            case LifeCycleEventType.PreRenderComplete:
                return(c => c.OnPreRenderComplete(context));

            default:
                throw new ArgumentOutOfRangeException(nameof(eventType), eventType, null);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Invokes the specified method on all controls in the page control tree.
 /// </summary>
 internal static void InvokePageLifeCycleEventRecursive(DotvvmControl rootControl, LifeCycleEventType eventType)
 {
     rootControl.Children.InvokeMissedPageLifeCycleEvents(eventType);
 }
 private void VerifyLifeCycleEvent(DataProcessingRegistration dataProcessingRegistration, LifeCycleEventType lifeCycleEventType)
 {
     _domainEvents.Verify(x => x.Raise(It.Is <EntityLifeCycleEvent <DataProcessingRegistration> >(args =>
                                                                                                  args.ChangeType == lifeCycleEventType && args.Entity == dataProcessingRegistration)));
 }
Esempio n. 11
0
 public ControlLifeCycleEvent(ControlLifeCycleMock control, LifeCycleEventType eventType, bool isEntering)
 {
     Control = control;
     EventType = eventType;
     IsEntering = isEntering;
 }
Esempio n. 12
0
 protected EntityLifeCycleEvent(LifeCycleEventType changeType, TEntity entity)
 {
     ChangeType = changeType;
     Entity     = entity;
 }
Esempio n. 13
0
 public static void InvokePageLifeCycleEventRecursive(DotvvmControl rootControl, LifeCycleEventType eventType)
 {
     rootControl.Children.InvokeMissedPageLifeCycleEvents(eventType, isMissingInvoke: false);
 }
 public ControlLifeCycleEvent(ControlLifeCycleMock control, LifeCycleEventType eventType, bool isEntering)
 {
     Control    = control;
     EventType  = eventType;
     IsEntering = isEntering;
 }