Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/IO/GenericFormatter.cs @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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