CSLA 5 to 8 Stream property in Command object #4564
-
Hello, I am in the process of updating an application from CSLA 5 to 8 and I believe I've run into an issue with the retiring of the BinaryFormatter. I have a bunch of Command objects that have Stream properties to handle a file upload. public class CommandExample : CommandBase<CommandExample>
{
public string Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
public Stream FileData
{
get { return GetProperty(FileDataProperty); }
set { SetProperty(FileDataProperty, value); }
}
public static readonly PropertyInfo<Stream> FileDataProperty = RegisterProperty<Stream>(c => c.FileData);
[Execute]
protected async Task DataPortal_Execute()
{
// ... file upload logic here
}
} In CSLA 5, this was working fine, but with the update to CSLA 8 I am now getting Is there a way I can continue to support Stream properties on these commands? Or is the better solution to just convert to Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I'm surprised that ever worked. That's interesting to me. It must be that In any case, https://github.com/MarimerLLC/csla/blob/main/docs/serialization.md#mobileformatter-constraints In CSLA 9 you can create what's called a custom serializer and map it to a type, so you can write your own serializer for I assume that what they must have done is read the entire stream into a |
Beta Was this translation helpful? Give feedback.
I'm surprised that ever worked. That's interesting to me. It must be that
BinaryFormatter
had a way to serialize a stream? Wow!In any case,
BinaryFormatter
is now obsolete in .NET, and so we had to stop supporting or using it in CSLA as well. The only serializer in CSLA 8 isMobileFormatter
, and it has its own set of serialization rules.https://github.com/MarimerLLC/csla/blob/main/docs/serialization.md#mobileformatter-constraints
In CSLA 9 you can create what's called a custom serializer and map it to a type, so you can write your own serializer for
Stream
if you can figure out how such a thing would work.I assume that what they must have done is read the entire stream into a
MemoryStream