/Serialization/XmlSerializerCache.cs |
@@ -18,9 +18,12 @@ |
{ |
public static class XmlSerializerCache |
{ |
private static readonly ReaderWriterLockSlim SerializerCacheLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
private static readonly Dictionary<string, XmlSerializer> SerializerCache = new Dictionary<string, XmlSerializer>(); |
private static readonly ReaderWriterLockSlim SerializerCacheLock = |
new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
private static readonly Dictionary<string, XmlSerializer> SerializerCache = |
new Dictionary<string, XmlSerializer>(); |
|
public static XmlSerializer GetSerializer<T>() |
{ |
return GetSerializer<T>(null); |
@@ -40,9 +43,7 @@ |
{ |
var Signature = MainTypeForSerialization.FullName; |
if (ExtraTypes != null) |
{ |
Signature = ExtraTypes.Aggregate(Signature, (current, tp) => current + ("-" + tp.FullName)); |
} |
Signature = ExtraTypes.Aggregate(Signature, (current, tp) => current + "-" + tp.FullName); |
|
SerializerCacheLock.EnterReadLock(); |
XmlSerializer XmlEventSerializer; |
@@ -93,9 +94,9 @@ |
{ |
try |
{ |
using (MemoryStream memoryStream = new MemoryStream()) |
using (var memoryStream = new MemoryStream()) |
{ |
using (StreamWriter streamWriter = new StreamWriter(memoryStream)) |
using (var streamWriter = new StreamWriter(memoryStream)) |
{ |
streamWriter.Write(XmlData); |
streamWriter.Flush(); |
@@ -114,9 +115,9 @@ |
{ |
try |
{ |
using (MemoryStream memoryStream = new MemoryStream()) |
using (var memoryStream = new MemoryStream()) |
{ |
using (StreamReader streamReader = new StreamReader(memoryStream)) |
using (var streamReader = new StreamReader(memoryStream)) |
{ |
using (var xmlWriter = XmlWriter.Create(memoryStream, new XmlWriterSettings { Indent = true })) |
{ |