Commit e33c075
committed
Refactor ClipboardHelper for clarity and platform-agnosticism
Refactored the `CanPasteFromClipboard` method in the `ClipboardHelper` class to improve clarity, error handling, and functionality. Removed Windows-specific logic and legacy code, consolidating clipboard handling into a unified, platform-agnostic approach.
Key changes include:
- Ensured `_topLevel.Clipboard` is not null using `ArgumentNullException.ThrowIfNull`.
- Unified clipboard data retrieval using `_topLevel.Clipboard.TryGetDataAsync`.
- Added support for `ClipboardXmlFormatA` and plain text retrieval.
- Improved error handling with `try-catch` blocks and logging via `EditorLogger.Error`.
- Ensured clipboard operations are invoked on the UI thread using `Dispatcher.UIThread.InvokeAsync`.
- Simplified code by removing redundant and nested blocks.
This refactor improves maintainability, readability, and robustness of the clipboard handling logic.1 parent 56e6c47 commit e33c075
1 file changed
+22
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
95 | 96 | | |
96 | | - | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 99 | + | |
| 100 | + | |
104 | 101 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 102 | + | |
110 | 103 | | |
111 | 104 | | |
112 | 105 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 106 | + | |
132 | 107 | | |
133 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
134 | 113 | | |
135 | 114 | | |
136 | 115 | | |
137 | | - | |
| 116 | + | |
| 117 | + | |
138 | 118 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 119 | + | |
152 | 120 | | |
153 | 121 | | |
154 | 122 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
161 | 129 | | |
162 | 130 | | |
163 | 131 | | |
| |||
0 commit comments