2using System.Collections.Generic;
3using System.Runtime.Serialization;
11 public static class CslaReaderWriterFactory
13 private static Type _readerType;
14 private static Type _writerType;
21 public static DataContractSerializer GetDataContractSerializer()
23 return new DataContractSerializer(
24 typeof(List<SerializationInfo>),
25 new Type[] { typeof(List<int>), typeof(
byte[]), typeof(DateTimeOffset), typeof(
char[]) });
32 public static void SetCslaWriterType(Type writerType)
34 _writerType = writerType;
41 public static void SetCslaReaderType(Type readerType)
43 _readerType = readerType;
50 public static ICslaWriter GetCslaWriter()
52 if (_writerType ==
null)
55 if (
string.IsNullOrEmpty(writerType))
57 _writerType = typeof(CslaBinaryWriter);
61 _writerType = Type.GetType(writerType);
64 return (ICslaWriter)Reflection.MethodCaller.CreateInstance(_writerType);
71 public static ICslaReader GetCslaReader()
73 if (_readerType ==
null)
76 if (
string.IsNullOrEmpty(readerType))
78 _readerType = typeof(CslaBinaryReader);
82 _readerType = Type.GetType(readerType);
85 return (ICslaReader)Reflection.MethodCaller.CreateInstance(_readerType);