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; }
/// <summary> /// Initializes a new instance of the <see cref="AppStateControllerAttribute"/> class. /// </summary> public AppStateControllerAttribute(string name, AppStateFlags flags = AppStateFlags.None, int layer = 0) { Name = name; Flags = flags; Layer = layer < 0 ? 0 : layer; }