|
| 1 | +using System; |
| 2 | +using Riok.Mapperly.Abstractions; |
| 3 | +using YMouseButtonControl.Core.ViewModels.Models; |
| 4 | +using YMouseButtonControl.DataAccess.Models; |
| 5 | + |
| 6 | +namespace YMouseButtonControl.Core.Mappings; |
| 7 | + |
| 8 | +[Mapper] |
| 9 | +public static partial class ButtonMappingMapper |
| 10 | +{ |
| 11 | + [MapDerivedType<DisabledMapping, DisabledMappingVm>] |
| 12 | + [MapDerivedType<NothingMapping, NothingMappingVm>] |
| 13 | + [MapDerivedType<SimulatedKeystroke, SimulatedKeystrokeVm>] |
| 14 | + [MapDerivedType<RightClick, RightClickVm>] |
| 15 | + public static partial BaseButtonMappingVm Map(ButtonMapping? buttonMapping); |
| 16 | + |
| 17 | + [MapDerivedType<DisabledMappingVm, DisabledMapping>] |
| 18 | + [MapDerivedType<NothingMappingVm, NothingMapping>] |
| 19 | + [MapDerivedType<SimulatedKeystrokeVm, SimulatedKeystroke>] |
| 20 | + [MapDerivedType<RightClickVm, RightClick>] |
| 21 | + public static partial ButtonMapping Map(BaseButtonMappingVm buttonMapping); |
| 22 | + |
| 23 | + [MapDerivedType<DisabledMappingVm, DisabledMapping>] |
| 24 | + [MapDerivedType<NothingMappingVm, NothingMapping>] |
| 25 | + [MapDerivedType<SimulatedKeystrokeVm, SimulatedKeystroke>] |
| 26 | + [MapDerivedType<RightClickVm, RightClick>] |
| 27 | + public static partial void Map(BaseButtonMappingVm src, ButtonMapping dst); |
| 28 | + |
| 29 | + public static BaseSimulatedKeystrokeTypeVm MapSimulatedKeystrokeType( |
| 30 | + SimulatedKeystrokeType simulatedKeystrokeType |
| 31 | + ) => |
| 32 | + simulatedKeystrokeType switch |
| 33 | + { |
| 34 | + SimulatedKeystrokeType.AsMousePressedAndReleasedActionType => |
| 35 | + new AsMousePressedAndReleasedActionTypeVm(), |
| 36 | + SimulatedKeystrokeType.DuringMouseActionType => new DuringMouseActionTypeVm(), |
| 37 | + SimulatedKeystrokeType.InAnotherThreadPressedActionType => |
| 38 | + new InAnotherThreadPressedActionTypeVm(), |
| 39 | + SimulatedKeystrokeType.InAnotherThreadReleasedActionType => |
| 40 | + new InAnotherThreadReleasedActionTypeVm(), |
| 41 | + SimulatedKeystrokeType.MouseButtonPressedActionType => |
| 42 | + new MouseButtonPressedActionTypeVm(), |
| 43 | + SimulatedKeystrokeType.MouseButtonReleasedActionType => |
| 44 | + new MouseButtonReleasedActionTypeVm(), |
| 45 | + SimulatedKeystrokeType.RepeatedlyWhileButtonDownActionType => |
| 46 | + new RepeatedlyWhileButtonDownActionTypeVm(), |
| 47 | + SimulatedKeystrokeType.StickyHoldActionType => new StickyHoldActionTypeVm(), |
| 48 | + SimulatedKeystrokeType.StickyRepeatActionType => new StickyRepeatActionTypeVm(), |
| 49 | + _ => throw new ArgumentOutOfRangeException( |
| 50 | + nameof(simulatedKeystrokeType), |
| 51 | + simulatedKeystrokeType, |
| 52 | + null |
| 53 | + ), |
| 54 | + }; |
| 55 | + |
| 56 | + public static SimulatedKeystrokeType? MapSimulatedKeystrokeTypeVm( |
| 57 | + BaseSimulatedKeystrokeTypeVm? baseSimulatedKeystrokeVm |
| 58 | + ) => |
| 59 | + baseSimulatedKeystrokeVm switch |
| 60 | + { |
| 61 | + null => null, |
| 62 | + AsMousePressedAndReleasedActionTypeVm => |
| 63 | + SimulatedKeystrokeType.AsMousePressedAndReleasedActionType, |
| 64 | + DuringMouseActionTypeVm => SimulatedKeystrokeType.DuringMouseActionType, |
| 65 | + InAnotherThreadPressedActionTypeVm => |
| 66 | + SimulatedKeystrokeType.InAnotherThreadPressedActionType, |
| 67 | + InAnotherThreadReleasedActionTypeVm => |
| 68 | + SimulatedKeystrokeType.InAnotherThreadReleasedActionType, |
| 69 | + MouseButtonPressedActionTypeVm => SimulatedKeystrokeType.MouseButtonPressedActionType, |
| 70 | + MouseButtonReleasedActionTypeVm => SimulatedKeystrokeType.MouseButtonReleasedActionType, |
| 71 | + RepeatedlyWhileButtonDownActionTypeVm => |
| 72 | + SimulatedKeystrokeType.RepeatedlyWhileButtonDownActionType, |
| 73 | + StickyHoldActionTypeVm => SimulatedKeystrokeType.StickyHoldActionType, |
| 74 | + StickyRepeatActionTypeVm => SimulatedKeystrokeType.StickyRepeatActionType, |
| 75 | + _ => throw new ArgumentOutOfRangeException(), |
| 76 | + }; |
| 77 | +} |
0 commit comments