diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs index d9f80c2..d32468e 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs @@ -30,4 +30,54 @@ public class PropertyChangedXEventArgs : EventArgs OldValue = oldValue; NewValue = newValue; } + +#if NETCOREAPP2_0_OR_GREATER + /// + /// 获取值 + /// + /// 类型 + /// (旧值, 新值) + public (T oldValue, T newValye) GetValue() + { + return ((T)OldValue!, (T)NewValue!)!; + } +#else + /// + /// 获取值 + /// + /// 类型 + /// (旧值, 新值) + public ValueInfo GetValue() + { + return new((T)OldValue!, (T)NewValue!)!; + } +#endif } + +#if !NETCOREAPP2_0_OR_GREATER +/// +/// 值信息 +/// +/// 值类型 +public struct ValueInfo +{ + /// + /// 旧值 + /// + public T OldValue { get; set; } + + /// + /// 新值 + /// + public T NewValue { get; set; } + + /// + /// 旧值 + /// 新值 + public ValueInfo(T oldValue, T newValue) + { + OldValue = oldValue; + NewValue = newValue; + } +} +#endif diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs index bbd6eed..3a67123 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs @@ -32,4 +32,26 @@ public class PropertyChangingXEventArgs : CancelEventArgs OldValue = oldValue; NewValue = newValue; } + +#if NETCOREAPP2_0_OR_GREATER + /// + /// 获取值 + /// + /// 类型 + /// (旧值, 新值) + public (T oldValue, T newValye) GetValue() + { + return ((T)OldValue!, (T)NewValue!)!; + } +#else + /// + /// 获取值 + /// + /// 类型 + /// (旧值, 新值) + public ValueInfo GetValue() + { + return new((T)OldValue!, (T)NewValue!)!; + } +#endif }