Task IHandle <AfterReadState> .Handle(AfterReadState message) { // 如果为 null 需要初始化状态 if (State == null) { AttachedObject.SetLocalValue(StateProperty, (T)Activator.CreateInstance(typeof(T), InitializeStateMark.Default)); } AfterReadState?.Invoke(this, EventArgs.Empty); return(Task.CompletedTask); }
async Task IHandle <AfterReadState> .Handle(AfterReadState message) { // 如果为 null 需要初始化状态 if (State == null) { AttachedObject.SetLocalValue(StateProperty, (T)Activator.CreateInstance(typeof(T), InitializeStateMark.Default)); if (SetDefaultState != null) { await SetDefaultState.InvokeSerial(this, EventArgs.Empty); } } AfterReadState?.Invoke(this, EventArgs.Empty); }