CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
NetDataContractSerializerWrapper.cs
Go to the documentation of this file.
1#if !NETSTANDARD2_0 && !NET5_0 && !NET6_0
2//-----------------------------------------------------------------------
3// <copyright file="NetDataContractSerializerWrapper.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>Wraps the <see cref="NetDataContractSerializer"/></summary>
8//-----------------------------------------------------------------------
9using System.IO;
10using System.Runtime.Serialization;
11
12namespace Csla.Serialization
13{
20 {
21 private readonly NetDataContractSerializer _formatter =
22 new NetDataContractSerializer();
23
31 public object Deserialize(System.IO.Stream serializationStream)
32 {
33 return _formatter.Deserialize(serializationStream);
34 }
35
43 public object Deserialize(byte[] buffer)
44 {
45 using var serializationStream = new MemoryStream(buffer);
46 return _formatter.Deserialize(serializationStream);
47 }
48
55 public void Serialize(System.IO.Stream serializationStream, object graph)
56 {
57 _formatter.Serialize(serializationStream, graph);
58 }
59
64 public byte[] Serialize(object graph)
65 {
66 using var buffer = new MemoryStream();
67 _formatter.Serialize(buffer, graph);
68 buffer.Position = 0;
69 return buffer.ToArray();
70 }
71
77 public NetDataContractSerializer Formatter
78 {
79 get
80 {
81 return _formatter;
82 }
83 }
84 }
85}
86#endif
Wraps the NetDataContractSerializer in the ISerializationFormatter interface so it can be used in a s...
object Deserialize(byte[] buffer)
Converts a serialization stream into an object graph.
void Serialize(System.IO.Stream serializationStream, object graph)
Converts an object graph into a byte stream.
NetDataContractSerializer Formatter
Gets a reference to the underlying NetDataContractSerializer object.
object Deserialize(System.IO.Stream serializationStream)
Converts a serialization stream into an object graph.
byte[] Serialize(object graph)
Converts an object graph into a byte stream.
Defines an object that can serialize and deserialize object graphs.