Пример #1
0
        internal void InvokeStateDeactivated(AppStateEventArgs args)
        {
            try
            {
                StateDeactivated?.Invoke(this, args);
            }
            catch (Exception e)
            {
                _console.TraceData(TraceEventType.Error, 0, e);
            }

            _parentStateManager?.InvokeStateDeactivated(args);
        }
Пример #2
0
        internal AppState(AppStateManager parentStateManager, IAppState owner, Type controllerType, object args)
        {
            Debug.Assert(parentStateManager != null);
            Debug.Assert(controllerType != null);

            _parentStateManager = parentStateManager;
            _parentState        = parentStateManager.ParentState;
            _ownerState         = owner;
            _stateArgs          = args;
            _eventArgs          = new AppStateEventArgs(this);
            _console            = parentStateManager.TraceSource;
            _stack = parentStateManager.StatesEx;

            if (Attribute.GetCustomAttribute(controllerType, typeof(AppStateControllerAttribute)) is AppStateControllerAttribute paramsAttr)
            {
                if (string.IsNullOrEmpty(paramsAttr.Name))
                {
                    _name = GetStateNameSimple(controllerType);
                }
                else
                {
                    _name = paramsAttr.Name;
                }

                _flags = paramsAttr.Flags;
                _layer = paramsAttr.Layer;
            }
            else
            {
                _name = GetStateNameSimple(controllerType);
            }

            // Force AppStateFlags.Popup flag for child states.
            if (_parentState != null)
            {
                _flags |= AppStateFlags.Popup;
            }

            _fullName         = _parentState?.FullName + '.' + _name ?? _name;
            _controller       = parentStateManager.CreateStateController(this, controllerType);
            _controllerEvents = _controller as IAppStateEvents;
        }