You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/10/22 11:27:26 UTC
[34/50] [abbrv] ignite git commit: IGNITE-1646 .Net: IgniteGuid is
now serializable.
IGNITE-1646 .Net: IgniteGuid is now serializable.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b1b80944
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b1b80944
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b1b80944
Branch: refs/heads/ignite-1651
Commit: b1b80944d6c5c6db74cb1e2f07c9a74975aa249b
Parents: e0853ea
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 20 17:03:36 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 17:03:36 2015 +0300
----------------------------------------------------------------------
.../Portable/PortableSelfTest.cs | 56 +++++++++-----------
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 13 +----
2 files changed, 26 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b80944/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index 275460f..36faf36 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Tests.Portable
using System.Collections.Generic;
using System.Linq;
using System.Text;
+ using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Portable;
@@ -784,20 +785,8 @@ namespace Apache.Ignite.Core.Tests.Portable
obj.PString = "abc";
obj.PGuid = Guid.NewGuid();
obj.PnGuid = Guid.NewGuid();
+ obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = "";
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
-
- //CheckPrimitiveFieldsSerialization(marsh, obj);
-
- //obj.PString = null;
- //obj.PNGuid = null;
-
CheckPrimitiveFieldsSerialization(marsh, obj);
}
@@ -1485,8 +1474,6 @@ namespace Apache.Ignite.Core.Tests.Portable
public class PrimitiveFieldType
{
- private Guid _pGuid;
-
public bool PBool { get; set; }
public sbyte PSbyte { get; set; }
@@ -1513,14 +1500,12 @@ namespace Apache.Ignite.Core.Tests.Portable
public string PString { get; set; }
- public Guid PGuid
- {
- get { return _pGuid; }
- set { _pGuid = value; }
- }
+ public Guid PGuid { get; set; }
public Guid? PnGuid { get; set; }
+ public IgniteGuid IgniteGuid { get; set; }
+
/** <inheritdoc /> */
public override bool Equals(object obj)
{
@@ -1543,8 +1528,9 @@ namespace Apache.Ignite.Core.Tests.Portable
PChar == that.PChar &&
PFloat == that.PFloat &&
PDouble == that.PDouble &&
- (PString == null && that.PString == null || PString != null && PString.Equals(that.PString)) &&
- _pGuid.Equals(that._pGuid) &&
+ (string.Equals(PString, that.PString)) &&
+ PGuid.Equals(that.PGuid) &&
+ IgniteGuid.Equals(that.IgniteGuid) &&
(PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
}
return false;
@@ -1583,6 +1569,8 @@ namespace Apache.Ignite.Core.Tests.Portable
writer.WriteString("string", PString);
writer.WriteGuid("guid", PGuid);
writer.WriteGuid("nguid", PnGuid);
+
+ writer.WriteObject("iguid", IgniteGuid);
}
public unsafe void ReadPortable(IPortableReader reader)
@@ -1610,6 +1598,8 @@ namespace Apache.Ignite.Core.Tests.Portable
PString = reader.ReadString("string");
PGuid = reader.ReadObject<Guid>("guid");
PnGuid = reader.ReadGuid("nguid");
+
+ IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
}
}
@@ -1641,6 +1631,8 @@ namespace Apache.Ignite.Core.Tests.Portable
rawWriter.WriteString(PString);
rawWriter.WriteGuid(PGuid);
rawWriter.WriteGuid(PnGuid);
+
+ rawWriter.WriteObject(IgniteGuid);
}
public unsafe void ReadPortable(IPortableReader reader)
@@ -1670,6 +1662,8 @@ namespace Apache.Ignite.Core.Tests.Portable
PString = rawReader.ReadString();
PGuid = rawReader.ReadGuid().Value;
PnGuid = rawReader.ReadGuid();
+
+ IgniteGuid = rawReader.ReadObject<IgniteGuid>();
}
}
@@ -1701,6 +1695,8 @@ namespace Apache.Ignite.Core.Tests.Portable
writer.WriteString("string", obj0.PString);
writer.WriteGuid("guid", obj0.PGuid);
writer.WriteGuid("nguid", obj0.PnGuid);
+
+ writer.WriteObject("iguid", obj0.IgniteGuid);
}
public unsafe void ReadPortable(object obj, IPortableReader reader)
@@ -1730,6 +1726,8 @@ namespace Apache.Ignite.Core.Tests.Portable
obj0.PString = reader.ReadString("string");
obj0.PGuid = reader.ReadObject<Guid>("guid");
obj0.PnGuid = reader.ReadGuid("nguid");
+
+ obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
}
}
@@ -1763,6 +1761,8 @@ namespace Apache.Ignite.Core.Tests.Portable
rawWriter.WriteString(obj0.PString);
rawWriter.WriteGuid(obj0.PGuid);
rawWriter.WriteGuid(obj0.PnGuid);
+
+ rawWriter.WriteObject(obj0.IgniteGuid);
}
public unsafe void ReadPortable(object obj, IPortableReader reader)
@@ -1793,17 +1793,9 @@ namespace Apache.Ignite.Core.Tests.Portable
obj0.PString = rawReader.ReadString();
obj0.PGuid = rawReader.ReadGuid().Value;
obj0.PnGuid = rawReader.ReadGuid();
- }
- }
-
- public static string PrintBytes(byte[] bytes)
- {
- StringBuilder sb = new StringBuilder();
- foreach (byte b in bytes)
- sb.Append(b + " ");
-
- return sb.ToString();
+ obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
}
public class HandleOuter : IPortableMarshalAware
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b80944/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
index 7386a03..60a5839 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Common
/// <summary>
/// Ignite guid with additional local ID.
/// </summary>
+ [Serializable]
public struct IgniteGuid : IEquatable<IgniteGuid>
{
/** Global id. */
@@ -89,20 +90,10 @@ namespace Apache.Ignite.Core.Common
}
/// <summary>
- /// Writes this object to the given writer.
- /// </summary>
- /// <param name="w">Writer.</param>
- public void WritePortable(IPortableRawWriter w)
- {
- w.WriteGuid(GlobalId);
- w.WriteLong(LocalId);
- }
-
- /// <summary>
/// Reads this object from the given reader.
/// </summary>
/// <param name="r">Reader.</param>
- public static IgniteGuid? ReadPortable(IPortableRawReader r)
+ internal static IgniteGuid? ReadPortable(IPortableRawReader r)
{
var guid = r.ReadGuid();