Changed the serialization method for copy/paste operations in the dra…#312
Changed the serialization method for copy/paste operations in the dra…#312davidebazzi wants to merge 1 commit into
Conversation
…wing, from the old BinaryFormatter to JsonSerialize.
|
|
||
| #region IUIService implementation | ||
| public override IUIService UIService => this; | ||
| GeoObjectList IUIService.GetDataPresent(object data) |
There was a problem hiding this comment.
I think you need to adjust this function as well. It still seems to rely on BinaryFormatter.
| @@ -291,22 +291,29 @@ | |||
| } | |||
| void IUIService.SetClipboardData(GeoObjectList objects, bool copy) | |||
There was a problem hiding this comment.
The current implementation has a few issues that could lead to resource leaks and unhandled exceptions:
Problems:
- MemoryStream is only disposed if no exception occurs—use using statement
- No error handling for serialization or clipboard operations
- Missing null validation for objects parameter
| return objects; | ||
| } | ||
| bool IUIService.HasClipboardData(Type typeOfdata) | ||
| bool IUIService.HasClipboardData() |
There was a problem hiding this comment.
The current implementation unnecessarily deserializes the entire clipboard data just to check if it exists:
- Performance: Deserializes full object graph just to return a boolean
- No error handling: Will throw if clipboard access fails or deserialization errors occur
|
Hi @davidebazzi , Thank you for your effort on migrating the clipboard operations from binary serialization to JSON! This is an important step toward modernizing the codebase. I've added detailed review comments on each line with suggested code fixes. |
…wing, from the old BinaryFormatter to JsonSerialize.