You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/10/28 09:42:37 UTC
[02/17] ignite git commit: IGNITE-1619: Reworked serialization of
generic collections.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index 6b5e20d..ff3fb85 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Impl.Portable
{
using System;
using System.Collections;
- using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
@@ -33,15 +32,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="obj">Object to write.</param>
internal delegate void PortableSystemWriteDelegate(PortableWriterImpl writer, object obj);
- /// <summary>
- /// Typed write delegate.
- /// </summary>
- /// <param name="stream">Stream.</param>
- /// <param name="obj">Object to write.</param>
- // ReSharper disable once TypeParameterCanBeVariant
- // Generic variance in a delegate causes performance hit
- internal delegate void PortableSystemTypedWriteDelegate<T>(IPortableStream stream, T obj);
-
/**
* <summary>Collection of predefined handlers for various system types.</summary>
*/
@@ -57,20 +47,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Read handlers. */
private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
- /** Write handler: collection. */
- public static readonly PortableSystemWriteDelegate WriteHndCollection = WriteCollection;
-
- /** Write handler: dictionary. */
- public static readonly PortableSystemWriteDelegate WriteHndDictionary = WriteDictionary;
-
- /** Write handler: generic collection. */
- public static readonly PortableSystemWriteDelegate WriteHndGenericCollection =
- WriteGenericCollection;
-
- /** Write handler: generic dictionary. */
- public static readonly PortableSystemWriteDelegate WriteHndGenericDictionary =
- WriteGenericDictionary;
-
/// <summary>
/// Initializes the <see cref="PortableSystemHandlers"/> class.
/// </summary>
@@ -132,21 +108,21 @@ namespace Apache.Ignite.Core.Impl.Portable
new PortableSystemReader<DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));
// 7. String array.
- ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemGenericArrayReader<string>();
+ ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemTypedArrayReader<string>();
// 8. Guid array.
- ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemGenericArrayReader<Guid?>();
+ ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemTypedArrayReader<Guid?>();
// 9. Array.
ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);
- // 12. Arbitrary collection.
+ // 11. Arbitrary collection.
ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);
// 13. Arbitrary dictionary.
ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);
- // 14. Map entry.
+ // 15. Map entry.
ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);
// 16. Enum.
@@ -168,17 +144,14 @@ namespace Apache.Ignite.Core.Impl.Portable
// Have we ever met this type?
if (writeHandlers0 != null && writeHandlers0.TryGetValue(type, out res))
return res;
- else
- {
- // Determine write handler for type and add it.
- res = FindWriteHandler(type);
- if (res != null)
- AddWriteHandler(type, res);
+ // Determine write handler for type and add it.
+ res = FindWriteHandler(type);
- return res;
- }
+ if (res != null)
+ AddWriteHandler(type, res);
+ return res;
}
/// <summary>
@@ -191,21 +164,21 @@ namespace Apache.Ignite.Core.Impl.Portable
// 1. Well-known types.
if (type == typeof (string))
return WriteString;
- else if (type == typeof(decimal))
+ if (type == typeof(decimal))
return WriteDecimal;
- else if (type == typeof(DateTime))
+ if (type == typeof(DateTime))
return WriteDate;
- else if (type == typeof(Guid))
+ if (type == typeof(Guid))
return WriteGuid;
- else if (type == typeof (PortableUserObject))
+ if (type == typeof (PortableUserObject))
return WritePortable;
- else if (type == typeof (ArrayList))
+ if (type == typeof (ArrayList))
return WriteArrayList;
- else if (type == typeof(Hashtable))
+ if (type == typeof(Hashtable))
return WriteHashtable;
- else if (type == typeof(DictionaryEntry))
+ if (type == typeof(DictionaryEntry))
return WriteMapEntry;
- else if (type.IsArray)
+ if (type.IsArray)
{
// We know how to write any array type.
Type elemType = type.GetElementType();
@@ -213,62 +186,56 @@ namespace Apache.Ignite.Core.Impl.Portable
// Primitives.
if (elemType == typeof (bool))
return WriteBoolArray;
- else if (elemType == typeof(byte))
+ if (elemType == typeof(byte))
return WriteByteArray;
- else if (elemType == typeof(short))
+ if (elemType == typeof(short))
return WriteShortArray;
- else if (elemType == typeof(char))
+ if (elemType == typeof(char))
return WriteCharArray;
- else if (elemType == typeof(int))
+ if (elemType == typeof(int))
return WriteIntArray;
- else if (elemType == typeof(long))
+ if (elemType == typeof(long))
return WriteLongArray;
- else if (elemType == typeof(float))
+ if (elemType == typeof(float))
return WriteFloatArray;
- else if (elemType == typeof(double))
+ if (elemType == typeof(double))
return WriteDoubleArray;
// Non-CLS primitives.
- else if (elemType == typeof(sbyte))
+ if (elemType == typeof(sbyte))
return WriteSbyteArray;
- else if (elemType == typeof(ushort))
+ if (elemType == typeof(ushort))
return WriteUshortArray;
- else if (elemType == typeof(uint))
+ if (elemType == typeof(uint))
return WriteUintArray;
- else if (elemType == typeof(ulong))
+ if (elemType == typeof(ulong))
return WriteUlongArray;
// Special types.
else if (elemType == typeof (decimal?))
return WriteDecimalArray;
- else if (elemType == typeof(string))
+ if (elemType == typeof(string))
return WriteStringArray;
// else if (elemType == typeof(DateTime))
// return WriteDateArray;
- else if (elemType == typeof(DateTime?))
+ if (elemType == typeof(DateTime?))
return WriteNullableDateArray;
// else if (elemType == typeof(Guid))
// return WriteGuidArray;
- else if (elemType == typeof(Guid?))
+ if (elemType == typeof(Guid?))
return WriteNullableGuidArray;
// Enums.
if (elemType.IsEnum)
return WriteEnumArray;
- // Regular array.
- return WriteArray;
+ // Object array.
+ if (elemType == typeof (object))
+ return WriteArray;
}
- else if (type.IsEnum)
+
+ if (type.IsEnum)
// We know how to write enums.
return WriteEnum;
- else
- {
- // We know how to write collections.
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- if (info.IsAny)
- return info.WriteHandler;
- return null;
- }
+ return null;
}
/// <summary>
@@ -584,7 +551,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeArrayEnum);
- PortableUtils.WriteArray((Array)obj, ctx, true);
+ PortableUtils.WriteArray((Array)obj, ctx);
}
/**
@@ -594,55 +561,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeArray);
- PortableUtils.WriteArray((Array)obj, ctx, true);
- }
-
- /**
- * <summary>Write collection.</summary>
- */
- private static void WriteCollection(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
- PortableUtils.WriteCollection((ICollection)obj, ctx);
- }
-
- /**
- * <summary>Write generic collection.</summary>
- */
- private static void WriteGenericCollection(PortableWriterImpl ctx, object obj)
- {
- PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
- Debug.Assert(info.IsGenericCollection, "Not generic collection: " + obj.GetType().FullName);
-
- ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
- info.WriteGeneric(ctx, obj);
- }
-
- /**
- * <summary>Write dictionary.</summary>
- */
- private static void WriteDictionary(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
- PortableUtils.WriteDictionary((IDictionary)obj, ctx);
- }
-
- /**
- * <summary>Write generic dictionary.</summary>
- */
- private static void WriteGenericDictionary(PortableWriterImpl ctx, object obj)
- {
- PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
- Debug.Assert(info.IsGenericDictionary, "Not generic dictionary: " + obj.GetType().FullName);
-
- ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
- info.WriteGeneric(ctx, obj);
+ PortableUtils.WriteArray((Array)obj, ctx);
}
/**
@@ -652,7 +571,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeCollection);
- PortableUtils.WriteTypedCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
+ PortableUtils.WriteCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
}
/**
@@ -662,7 +581,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
- PortableUtils.WriteTypedDictionary((IDictionary)obj, ctx, PortableUtils.MapHashMap);
+ PortableUtils.WriteDictionary((IDictionary)obj, ctx, PortableUtils.MapHashMap);
}
/**
@@ -700,7 +619,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadEnumArray(PortableReaderImpl ctx, Type type)
{
- return PortableUtils.ReadArray(ctx, true, type.GetElementType());
+ return PortableUtils.ReadTypedArray(ctx, true, type.GetElementType());
}
/**
@@ -710,7 +629,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
var elemType = type.IsArray ? type.GetElementType() : typeof(object);
- return PortableUtils.ReadArray(ctx, true, elemType);
+ return PortableUtils.ReadTypedArray(ctx, true, elemType);
}
/**
@@ -718,11 +637,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadCollection(PortableReaderImpl ctx, Type type)
{
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- return info.IsGenericCollection
- ? info.ReadGeneric(ctx)
- : PortableUtils.ReadCollection(ctx, null, null);
+ return PortableUtils.ReadCollection(ctx, null, null);
}
/**
@@ -730,11 +645,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadDictionary(PortableReaderImpl ctx, Type type)
{
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- return info.IsGenericDictionary
- ? info.ReadGeneric(ctx)
- : PortableUtils.ReadDictionary(ctx, null);
+ return PortableUtils.ReadDictionary(ctx, null);
}
/**
@@ -746,104 +657,10 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Create new ArrayList.</summary>
- * <param name="len">Length.</param>
- * <returns>ArrayList.</returns>
- */
- public static ICollection CreateArrayList(int len)
- {
- return new ArrayList(len);
- }
-
- /**
* <summary>Add element to array list.</summary>
* <param name="col">Array list.</param>
* <param name="elem">Element.</param>
*/
- public static void AddToArrayList(ICollection col, object elem)
- {
- ((ArrayList) col).Add(elem);
- }
-
- /**
- * <summary>Create new List.</summary>
- * <param name="len">Length.</param>
- * <returns>List.</returns>
- */
- public static ICollection<T> CreateList<T>(int len)
- {
- return new List<T>(len);
- }
-
- /**
- * <summary>Create new LinkedList.</summary>
- * <param name="len">Length.</param>
- * <returns>LinkedList.</returns>
- */
- public static ICollection<T> CreateLinkedList<T>(int len)
- {
- return new LinkedList<T>();
- }
-
- /**
- * <summary>Create new HashSet.</summary>
- * <param name="len">Length.</param>
- * <returns>HashSet.</returns>
- */
- public static ICollection<T> CreateHashSet<T>(int len)
- {
- return new HashSet<T>();
- }
-
- /**
- * <summary>Create new SortedSet.</summary>
- * <param name="len">Length.</param>
- * <returns>SortedSet.</returns>
- */
- public static ICollection<T> CreateSortedSet<T>(int len)
- {
- return new SortedSet<T>();
- }
-
- /**
- * <summary>Create new Hashtable.</summary>
- * <param name="len">Length.</param>
- * <returns>Hashtable.</returns>
- */
- public static IDictionary CreateHashtable(int len)
- {
- return new Hashtable(len);
- }
-
- /**
- * <summary>Create new Dictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>Dictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateDictionary<TK, TV>(int len)
- {
- return new Dictionary<TK, TV>(len);
- }
-
- /**
- * <summary>Create new SortedDictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>SortedDictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateSortedDictionary<TK, TV>(int len)
- {
- return new SortedDictionary<TK, TV>();
- }
-
- /**
- * <summary>Create new ConcurrentDictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>ConcurrentDictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateConcurrentDictionary<TK, TV>(int len)
- {
- return new ConcurrentDictionary<TK, TV>(Environment.ProcessorCount, len);
- }
/**
@@ -930,11 +747,11 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Reader without boxing.
/// </summary>
- private class PortableSystemGenericArrayReader<T> : IPortableSystemReader
+ private class PortableSystemTypedArrayReader<T> : IPortableSystemReader
{
public TResult Read<TResult>(PortableReaderImpl ctx)
{
- return TypeCaster<TResult>.Cast(PortableUtils.ReadGenericArray<T>(ctx, false));
+ return TypeCaster<TResult>.Cast(PortableUtils.ReadArray<T>(ctx, false));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index ed8d5e1..26cf5b5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -170,15 +170,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: native job result holder. */
public const byte TypePortableJobResHolder = 76;
- /** Type: .Net configuration. */
- public const byte TypeDotNetCfg = 202;
-
- /** Type: .Net portable configuration. */
- public const byte TypeDotNetPortableCfg = 203;
-
- /** Type: .Net portable type configuration. */
- public const byte TypeDotNetPortableTypCfg = 204;
-
/** Type: Ignite proxy. */
public const byte TypeIgniteProxy = 74;
@@ -212,9 +203,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: entry predicate holder. */
public const byte TypeCacheEntryPredicateHolder = 90;
- /** Type: product license. */
- public const byte TypeProductLicense = 78;
-
/** Type: message filter holder. */
public const byte TypeMessageListenerHolder = 92;
@@ -284,12 +272,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Dictionary type. */
public static readonly Type TypDictionary = typeof(IDictionary);
- /** Generic collection type. */
- public static readonly Type TypGenericCollection = typeof(ICollection<>);
-
- /** Generic dictionary type. */
- public static readonly Type TypGenericDictionary = typeof(IDictionary<,>);
-
/** Ticks for Java epoch. */
private static readonly long JavaDateTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks;
@@ -300,25 +282,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Default poratble marshaller. */
private static readonly PortableMarshaller Marsh = new PortableMarshaller(null);
- /** Method: WriteGenericCollection. */
- public static readonly MethodInfo MtdhWriteGenericCollection =
- typeof(PortableUtils).GetMethod("WriteGenericCollection", _bindFlagsStatic);
-
- /** Method: ReadGenericCollection. */
- public static readonly MethodInfo MtdhReadGenericCollection =
- typeof(PortableUtils).GetMethod("ReadGenericCollection", _bindFlagsStatic);
-
- /** Method: WriteGenericDictionary. */
- public static readonly MethodInfo MtdhWriteGenericDictionary =
- typeof(PortableUtils).GetMethod("WriteGenericDictionary", _bindFlagsStatic);
-
- /** Method: ReadGenericDictionary. */
- public static readonly MethodInfo MtdhReadGenericDictionary =
- typeof(PortableUtils).GetMethod("ReadGenericDictionary", _bindFlagsStatic);
-
- /** Method: ReadGenericArray. */
- public static readonly MethodInfo MtdhReadGenericArray =
- typeof(PortableUtils).GetMethod("ReadGenericArray", _bindFlagsStatic);
+ /** Method: ReadArray. */
+ public static readonly MethodInfo MtdhReadArray =
+ typeof(PortableUtils).GetMethod("ReadArray", _bindFlagsStatic);
/** Cached UTF8 encoding. */
private static readonly Encoding Utf8 = Encoding.UTF8;
@@ -1006,7 +972,7 @@ namespace Apache.Ignite.Core.Impl.Portable
var vals = new decimal?[len];
for (int i = 0; i < len; i++)
- vals[i] = stream.ReadByte() == HdrNull ? (decimal?) null : ReadDecimal(stream);
+ vals[i] = stream.ReadByte() == HdrNull ? null : ReadDecimal(stream);
return vals;
}
@@ -1098,19 +1064,17 @@ namespace Apache.Ignite.Core.Impl.Portable
return vals;
}
-
+
/// <summary>
/// Write array.
/// </summary>
/// <param name="val">Array.</param>
/// <param name="ctx">Write context.</param>
- /// <param name="typed">Typed flag.</param>
- public static void WriteArray(Array val, PortableWriterImpl ctx, bool typed)
+ public static void WriteArray(Array val, PortableWriterImpl ctx)
{
IPortableStream stream = ctx.Stream;
- if (typed)
- stream.WriteInt(ObjTypeId);
+ stream.WriteInt(ObjTypeId);
stream.WriteInt(val.Length);
@@ -1125,14 +1089,14 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="typed">Typed flag.</param>
/// <param name="elementType">Type of the element.</param>
/// <returns>Array.</returns>
- public static object ReadArray(PortableReaderImpl ctx, bool typed, Type elementType)
+ public static object ReadTypedArray(PortableReaderImpl ctx, bool typed, Type elementType)
{
Func<PortableReaderImpl, bool, object> result;
if (!ArrayReaders.TryGetValue(elementType, out result))
result = ArrayReaders.GetOrAdd(elementType, t =>
DelegateConverter.CompileFunc<Func<PortableReaderImpl, bool, object>>(null,
- MtdhReadGenericArray.MakeGenericMethod(t),
+ MtdhReadArray.MakeGenericMethod(t),
new[] {typeof (PortableReaderImpl), typeof (bool)}, new[] {false, false, true}));
return result(ctx, typed);
@@ -1144,9 +1108,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="ctx">Read context.</param>
/// <param name="typed">Typed flag.</param>
/// <returns>Array.</returns>
- public static T[] ReadGenericArray<T>(PortableReaderImpl ctx, bool typed)
+ public static T[] ReadArray<T>(PortableReaderImpl ctx, bool typed)
{
- IPortableStream stream = ctx.Stream;
+ var stream = ctx.Stream;
if (typed)
stream.ReadInt();
@@ -1186,9 +1150,29 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
public static void WriteCollection(ICollection val, PortableWriterImpl ctx)
{
- byte colType = val.GetType() == typeof(ArrayList) ? CollectionArrayList : CollectionCustom;
+ var valType = val.GetType();
+
+ byte colType;
- WriteTypedCollection(val, ctx, colType);
+ if (valType.IsGenericType)
+ {
+ var genType = valType.GetGenericTypeDefinition();
+
+ if (genType == typeof (List<>))
+ colType = CollectionArrayList;
+ else if (genType == typeof (LinkedList<>))
+ colType = CollectionLinkedList;
+ else if (genType == typeof (SortedSet<>))
+ colType = CollectionSortedSet;
+ else if (genType == typeof (ConcurrentBag<>))
+ colType = CollectionConcurrentBag;
+ else
+ colType = CollectionCustom;
+ }
+ else
+ colType = valType == typeof (ArrayList) ? CollectionArrayList : CollectionCustom;
+
+ WriteCollection(val, ctx, colType);
}
/**
@@ -1197,7 +1181,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="ctx">Write context.</param>
* <param name="colType">Collection type.</param>
*/
- public static void WriteTypedCollection(ICollection val, PortableWriterImpl ctx, byte colType)
+ public static void WriteCollection(ICollection val, PortableWriterImpl ctx, byte colType)
{
ctx.Stream.WriteInt(val.Count);
@@ -1217,19 +1201,30 @@ namespace Apache.Ignite.Core.Impl.Portable
public static ICollection ReadCollection(PortableReaderImpl ctx,
PortableCollectionFactory factory, PortableCollectionAdder adder)
{
- if (factory == null)
- factory = PortableSystemHandlers.CreateArrayList;
-
- if (adder == null)
- adder = PortableSystemHandlers.AddToArrayList;
-
IPortableStream stream = ctx.Stream;
int len = stream.ReadInt();
- ctx.Stream.Seek(1, SeekOrigin.Current);
+ byte colType = ctx.Stream.ReadByte();
- ICollection res = factory.Invoke(len);
+ ICollection res;
+
+ if (factory == null)
+ {
+ if (colType == CollectionLinkedList)
+ res = new LinkedList<object>();
+ else if (colType == CollectionSortedSet)
+ res = new SortedSet<object>();
+ else if (colType == CollectionConcurrentBag)
+ res = new ConcurrentBag<object>();
+ else
+ res = new ArrayList(len);
+ }
+ else
+ res = factory.Invoke(len);
+
+ if (adder == null)
+ adder = (col, elem) => { ((ArrayList) col).Add(elem); };
for (int i = 0; i < len; i++)
adder.Invoke(res, ctx.Deserialize<object>());
@@ -1238,95 +1233,33 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Write generic collection.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx)
- {
- Type type = val.GetType().GetGenericTypeDefinition();
-
- byte colType;
-
- if (type == typeof(List<>))
- colType = CollectionArrayList;
- else if (type == typeof(LinkedList<>))
- colType = CollectionLinkedList;
- else if (type == typeof(HashSet<>))
- colType = CollectionHashSet;
- else if (type == typeof(SortedSet<>))
- colType = CollectionSortedSet;
- else
- colType = CollectionCustom;
-
- WriteTypedGenericCollection(val, ctx, colType);
- }
-
- /**
- * <summary>Write generic non-null collection with known type.</summary>
+ * <summary>Write dictionary.</summary>
* <param name="val">Value.</param>
* <param name="ctx">Write context.</param>
- * <param name="colType">Collection type.</param>
*/
- public static void WriteTypedGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx,
- byte colType)
+ public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
{
- ctx.Stream.WriteInt(val.Count);
-
- ctx.Stream.WriteByte(colType);
+ var valType = val.GetType();
- foreach (T elem in val)
- ctx.Write(elem);
- }
-
- /**
- * <summary>Read generic collection.</summary>
- * <param name="ctx">Context.</param>
- * <param name="factory">Factory delegate.</param>
- * <returns>Collection.</returns>
- */
- public static ICollection<T> ReadGenericCollection<T>(PortableReaderImpl ctx,
- PortableGenericCollectionFactory<T> factory)
- {
- int len = ctx.Stream.ReadInt();
+ byte dictType;
- if (len >= 0)
+ if (valType.IsGenericType)
{
- byte colType = ctx.Stream.ReadByte();
-
- if (factory == null)
- {
- // Need to detect factory automatically.
- if (colType == CollectionLinkedList)
- factory = PortableSystemHandlers.CreateLinkedList<T>;
- else if (colType == CollectionHashSet)
- factory = PortableSystemHandlers.CreateHashSet<T>;
- else if (colType == CollectionSortedSet)
- factory = PortableSystemHandlers.CreateSortedSet<T>;
- else
- factory = PortableSystemHandlers.CreateList<T>;
- }
-
- ICollection<T> res = factory.Invoke(len);
-
- for (int i = 0; i < len; i++)
- res.Add(ctx.Deserialize<T>());
-
- return res;
+ var genType = valType.GetGenericTypeDefinition();
+
+ if (genType == typeof (Dictionary<,>))
+ dictType = MapHashMap;
+ else if (genType == typeof (SortedDictionary<,>))
+ dictType = MapSortedMap;
+ else if (genType == typeof (ConcurrentDictionary<,>))
+ dictType = MapConcurrentHashMap;
+ else
+ dictType = MapCustom;
}
- return null;
- }
-
- /**
- * <summary>Write dictionary.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
- {
- byte dictType = val.GetType() == typeof(Hashtable) ? MapHashMap : MapCustom;
+ else
+ dictType = valType == typeof (Hashtable) ? MapHashMap : MapCustom;
- WriteTypedDictionary(val, ctx, dictType);
+ WriteDictionary(val, ctx, dictType);
}
/**
@@ -1335,7 +1268,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="ctx">Write context.</param>
* <param name="dictType">Dictionary type.</param>
*/
- public static void WriteTypedDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
+ public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
{
ctx.Stream.WriteInt(val.Count);
@@ -1357,16 +1290,26 @@ namespace Apache.Ignite.Core.Impl.Portable
public static IDictionary ReadDictionary(PortableReaderImpl ctx,
PortableDictionaryFactory factory)
{
- if (factory == null)
- factory = PortableSystemHandlers.CreateHashtable;
-
IPortableStream stream = ctx.Stream;
int len = stream.ReadInt();
- ctx.Stream.Seek(1, SeekOrigin.Current);
+ byte colType = ctx.Stream.ReadByte();
+
+ IDictionary res;
+
+ if (factory == null)
+ {
+ if (colType == MapSortedMap)
+ res = new SortedDictionary<object, object>();
+ else if (colType == MapConcurrentHashMap)
+ res = new ConcurrentDictionary<object, object>(Environment.ProcessorCount, len);
+ else
+ res = new Hashtable(len);
+ }
+ else
+ res = factory.Invoke(len);
- IDictionary res = factory.Invoke(len);
for (int i = 0; i < len; i++)
{
@@ -1380,89 +1323,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Write generic dictionary.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val, PortableWriterImpl ctx)
- {
- Type type = val.GetType().GetGenericTypeDefinition();
-
- byte dictType;
-
- if (type == typeof(Dictionary<,>))
- dictType = MapHashMap;
- else if (type == typeof(SortedDictionary<,>))
- dictType = MapSortedMap;
- else if (type == typeof(ConcurrentDictionary<,>))
- dictType = MapConcurrentHashMap;
- else
- dictType = MapCustom;
-
- WriteTypedGenericDictionary(val, ctx, dictType);
- }
-
- /**
- * <summary>Write generic non-null dictionary with known type.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- * <param name="dictType">Dictionary type.</param>
- */
- public static void WriteTypedGenericDictionary<TK, TV>(IDictionary<TK, TV> val,
- PortableWriterImpl ctx, byte dictType)
- {
- ctx.Stream.WriteInt(val.Count);
-
- ctx.Stream.WriteByte(dictType);
-
- foreach (KeyValuePair<TK, TV> entry in val)
- {
- ctx.Write(entry.Key);
- ctx.Write(entry.Value);
- }
- }
-
- /**
- * <summary>Read generic dictionary.</summary>
- * <param name="ctx">Context.</param>
- * <param name="factory">Factory delegate.</param>
- * <returns>Collection.</returns>
- */
- public static IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableReaderImpl ctx,
- PortableGenericDictionaryFactory<TK, TV> factory)
- {
- int len = ctx.Stream.ReadInt();
-
- if (len >= 0)
- {
- byte colType = ctx.Stream.ReadByte();
-
- if (factory == null)
- {
- if (colType == MapSortedMap)
- factory = PortableSystemHandlers.CreateSortedDictionary<TK, TV>;
- else if (colType == MapConcurrentHashMap)
- factory = PortableSystemHandlers.CreateConcurrentDictionary<TK, TV>;
- else
- factory = PortableSystemHandlers.CreateDictionary<TK, TV>;
- }
-
- IDictionary<TK, TV> res = factory.Invoke(len);
-
- for (int i = 0; i < len; i++)
- {
- TK key = ctx.Deserialize<TK>();
- TV val = ctx.Deserialize<TV>();
-
- res[key] = val;
- }
-
- return res;
- }
- return null;
- }
-
- /**
* <summary>Write map entry.</summary>
* <param name="ctx">Write context.</param>
* <param name="val">Value.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index ffa475e..b75292f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -867,7 +867,7 @@ namespace Apache.Ignite.Core.Impl.Portable
int pos = SkipFieldLength();
_stream.WriteByte(PU.TypeArrayEnum);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
WriteFieldLength(_stream, pos);
}
@@ -885,7 +885,7 @@ namespace Apache.Ignite.Core.Impl.Portable
else
{
_stream.WriteByte(PU.TypeArrayEnum);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
}
}
@@ -924,10 +924,10 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write named object array.
/// </summary>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="T">Element type.</typeparam>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Object array.</param>
- public void WriteObjectArray<T>(string fieldName, T[] val)
+ public void WriteArray<T>(string fieldName, T[] val)
{
WriteFieldId(fieldName, PU.TypeArray);
@@ -938,7 +938,7 @@ namespace Apache.Ignite.Core.Impl.Portable
int pos = SkipFieldLength();
_stream.WriteByte(PU.TypeArray);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
WriteFieldLength(_stream, pos);
}
@@ -947,16 +947,16 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write object array.
/// </summary>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="T">Element type.</typeparam>
/// <param name="val">Object array.</param>
- public void WriteObjectArray<T>(T[] val)
+ public void WriteArray<T>(T[] val)
{
if (val == null)
WriteNullRawField();
else
{
_stream.WriteByte(PU.TypeArray);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
}
}
@@ -975,7 +975,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
int pos = SkipFieldLength();
- Write(val);
+ WriteCollection(val);
WriteFieldLength(_stream, pos);
}
@@ -987,39 +987,8 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="val">Collection.</param>
public void WriteCollection(ICollection val)
{
- Write(val);
- }
-
- /// <summary>
- /// Write named generic collection.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Collection.</param>
- public void WriteGenericCollection<T>(string fieldName, ICollection<T> val)
- {
- WriteFieldId(fieldName, PU.TypeCollection);
-
- if (val == null)
- WriteNullField();
- else
- {
- int pos = SkipFieldLength();
-
- Write(val);
-
- WriteFieldLength(_stream, pos);
- }
- }
-
- /// <summary>
- /// Write generic collection.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="val">Collection.</param>
- public void WriteGenericCollection<T>(ICollection<T> val)
- {
- Write(val);
+ WriteByte(PU.TypeCollection);
+ PU.WriteCollection(val, this);
}
/// <summary>
@@ -1037,7 +1006,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
int pos = SkipFieldLength();
- Write(val);
+ WriteDictionary(val);
WriteFieldLength(_stream, pos);
}
@@ -1049,37 +1018,8 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="val">Dictionary.</param>
public void WriteDictionary(IDictionary val)
{
- Write(val);
- }
-
- /// <summary>
- /// Write named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Dictionary.</param>
- public void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val)
- {
- WriteFieldId(fieldName, PU.TypeDictionary);
-
- if (val == null)
- WriteNullField();
- else
- {
- int pos = SkipFieldLength();
-
- Write(val);
-
- WriteFieldLength(_stream, pos);
- }
- }
-
- /// <summary>
- /// Write generic dictionary.
- /// </summary>
- /// <param name="val">Dictionary.</param>
- public void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val)
- {
- Write(val);
+ WriteByte(PU.TypeDictionary);
+ PU.WriteDictionary(val, this);
}
/// <summary>
@@ -1118,7 +1058,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="builder">Builder.</param>
/// <returns>Previous builder.</returns>
- internal PortableBuilderImpl Builder(PortableBuilderImpl builder)
+ internal PortableBuilderImpl SetBuilder(PortableBuilderImpl builder)
{
PortableBuilderImpl ret = _builder;
@@ -1239,11 +1179,10 @@ namespace Apache.Ignite.Core.Impl.Portable
handler.Invoke(this, obj);
else
{
- // Last chance: is object seializable?
if (type.IsSerializable)
Write(new SerializableObjectHolder(obj));
else
- // We did our best, object cannot be marshalled.
+ // We did our best, object cannot be marshalled.
throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
index a3e8dd5..f0408a8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Raw reader for portable objects.
@@ -206,10 +205,10 @@ namespace Apache.Ignite.Core.Portable
/// Read object array.
/// </summary>
/// <returns>Object array.</returns>
- T[] ReadObjectArray<T>();
+ T[] ReadArray<T>();
/// <summary>
- /// Read collection.
+ /// Read collection.
/// </summary>
/// <returns>Collection.</returns>
ICollection ReadCollection();
@@ -223,19 +222,6 @@ namespace Apache.Ignite.Core.Portable
ICollection ReadCollection(PortableCollectionFactory factory, PortableCollectionAdder adder);
/// <summary>
- /// Read generic collection.
- /// </summary>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>();
-
- /// <summary>
- /// Read generic collection.
- /// </summary>
- /// <param name="factory">Factory.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory);
-
- /// <summary>
/// Read dictionary.
/// </summary>
/// <returns>Dictionary.</returns>
@@ -247,18 +233,5 @@ namespace Apache.Ignite.Core.Portable
/// <param name="factory">Factory.</param>
/// <returns>Dictionary.</returns>
IDictionary ReadDictionary(PortableDictionaryFactory factory);
-
- /// <summary>
- /// Read generic dictionary.
- /// </summary>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>();
-
- /// <summary>
- /// Read generic dictionary.
- /// </summary>
- /// <param name="factory">Factory.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
index cc14f45..71b0c07 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Raw writer for portable objects.
@@ -192,30 +191,30 @@ namespace Apache.Ignite.Core.Portable
/// Write object array.
/// </summary>
/// <param name="val">Object array.</param>
- void WriteObjectArray<T>(T[] val);
+ void WriteArray<T>(T[] val);
/// <summary>
- /// Write collection.
+ /// Writes a collection in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read collection elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic collection type.
/// </summary>
/// <param name="val">Collection.</param>
void WriteCollection(ICollection val);
/// <summary>
- /// Write generic collection.
- /// </summary>
- /// <param name="val">Collection.</param>
- void WriteGenericCollection<T>(ICollection<T> val);
-
- /// <summary>
- /// Write dictionary.
+ /// Writes a dictionary in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read dictionary elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic dictionary type.
/// </summary>
/// <param name="val">Dictionary.</param>
void WriteDictionary(IDictionary val);
-
- /// <summary>
- /// Write generic dictionary.
- /// </summary>
- /// <param name="val">Dictionary.</param>
- void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
index ed86b7e..03702d3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Delegate for collection creation.
@@ -36,13 +35,6 @@ namespace Apache.Ignite.Core.Portable
public delegate void PortableCollectionAdder(ICollection col, object elem);
/// <summary>
- /// Delegate for generic collection creation.
- /// </summary>
- /// <param name="size">Collection size.</param>
- /// <returns>Collection.</returns>
- public delegate ICollection<T> PortableGenericCollectionFactory<T>(int size);
-
- /// <summary>
/// Delegate for dictionary creation.
/// </summary>
/// <param name="size">Dictionary size.</param>
@@ -50,13 +42,6 @@ namespace Apache.Ignite.Core.Portable
public delegate IDictionary PortableDictionaryFactory(int size);
/// <summary>
- /// Delegate for generic collection creation.
- /// </summary>
- /// <param name="size">Collection size.</param>
- /// <returns>Collection.</returns>
- public delegate IDictionary<TK, TV> PortableGenericDictionaryFactory<TK, TV>(int size);
-
- /// <summary>
/// Reader for portable objects.
/// </summary>
public interface IPortableReader
@@ -268,7 +253,7 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <returns>Object array.</returns>
- T[] ReadObjectArray<T>(string fieldName);
+ T[] ReadArray<T>(string fieldName);
/// <summary>
/// Read named collection.
@@ -287,21 +272,6 @@ namespace Apache.Ignite.Core.Portable
ICollection ReadCollection(string fieldName, PortableCollectionFactory factory, PortableCollectionAdder adder);
/// <summary>
- /// Read named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(string fieldName);
-
- /// <summary>
- /// Read named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="factory">Factory.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(string fieldName, PortableGenericCollectionFactory<T> factory);
-
- /// <summary>
/// Read named dictionary.
/// </summary>
/// <param name="fieldName">Field name.</param>
@@ -317,21 +287,6 @@ namespace Apache.Ignite.Core.Portable
IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory);
/// <summary>
- /// Read named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName);
-
- /// <summary>
- /// Read named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="factory">Factory.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName, PortableGenericDictionaryFactory<TK, TV> factory);
-
- /// <summary>
/// Get raw reader.
/// </summary>
/// <returns>Raw reader.</returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
index 670a137..6e5d680 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Writer for portable objects.
@@ -220,37 +219,35 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Object array.</param>
- void WriteObjectArray<T>(string fieldName, T[] val);
+ void WriteArray<T>(string fieldName, T[] val);
/// <summary>
- /// Write named collection.
+ /// Writes a named collection in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read collection elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic collection type.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Collection.</param>
void WriteCollection(string fieldName, ICollection val);
/// <summary>
- /// Write named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Collection.</param>
- void WriteGenericCollection<T>(string fieldName, ICollection<T> val);
-
- /// <summary>
- /// Write named dictionary.
+ /// Writes a named dictionary in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read dictionary elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic dictionary type.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Dictionary.</param>
void WriteDictionary(string fieldName, IDictionary val);
/// <summary>
- /// Write named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Dictionary.</param>
- void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val);
-
- /// <summary>
/// Get raw writer.
/// </summary>
/// <returns>Raw writer.</returns>