Line | |
---|
1 | using System.IO;
|
---|
2 | using System.Runtime.Serialization;
|
---|
3 |
|
---|
4 | namespace Netron.Diagramming.Core {
|
---|
5 | /// <summary>
|
---|
6 | /// Generic implementation of the <see cref="IGenericFormatter"/> interface.
|
---|
7 | /// </summary>
|
---|
8 | /// <typeparam name="F"></typeparam>
|
---|
9 | public class GenericFormatter<F> : IGenericFormatter where F : IFormatter, new() {
|
---|
10 | IFormatter m_Formatter = new F();
|
---|
11 |
|
---|
12 | /// <summary>
|
---|
13 | /// Deserializes the specified serialization stream.
|
---|
14 | /// </summary>
|
---|
15 | /// <param name="serializationStream">The serialization stream.</param>
|
---|
16 | /// <returns></returns>
|
---|
17 | public T Deserialize<T>(Stream serializationStream) {
|
---|
18 | return (T)m_Formatter.Deserialize(serializationStream);
|
---|
19 | }
|
---|
20 | /// <summary>
|
---|
21 | /// Serializes the specified serialization stream.
|
---|
22 | /// </summary>
|
---|
23 | /// <param name="serializationStream">The serialization stream.</param>
|
---|
24 | /// <param name="graph">A parameter of the generics Type T</param>
|
---|
25 | public void Serialize<T>(Stream serializationStream, T graph) {
|
---|
26 | m_Formatter.Serialize(serializationStream, graph);
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.