Parse() public method

public Parse ( GameBitBuffer buffer ) : void
buffer GameBitBuffer
return void
コード例 #1
0
ファイル: ShardKeyTests.cs プロジェクト: JohnPKosh/azos
        public void ShardKey_EntityId()
        {
            var v1 = new ShardKey(new EntityId());
            var v2 = new ShardKey(new EntityId());

            Aver.IsTrue(ShardKey.Type.EntityId == v1.DataType);
            Aver.AreEqual(v1, v2);
            Aver.AreEqual(v1.GetHashCode(), v2.GetHashCode());
            Aver.AreEqual(v1.Hash, v2.Hash);
            Aver.AreEqual(v1.ValueEntityId, v2.ValueEntityId);
            Aver.IsTrue(v1 == v2);

            "Value: {0}".SeeArgs(v1);//ToString()

            v1 = new ShardKey(EntityId.Parse("a@b::c"));
            v2 = new ShardKey(EntityId.Parse("a@b::c"));
            Aver.IsTrue(ShardKey.Type.EntityId == v1.DataType);
            Aver.AreEqual(v1, v2);
            Aver.AreEqual(v1.GetHashCode(), v2.GetHashCode());
            Aver.AreEqual(v1.Hash, v2.Hash);
            Aver.AreEqual(v1.ValueEntityId, v2.ValueEntityId);
            Aver.IsTrue(v1 == v2);
            Aver.AreEqual(EntityId.Parse("a@b::c"), v1.ValueEntityId);

            "Value: {0}".SeeArgs(v1);//ToString()

            v2 = new ShardKey(EntityId.Parse("another@b::c"));
            Aver.AreNotEqual(v1, v2);
            Aver.AreNotEqual(v1.GetHashCode(), v2.GetHashCode());
            Aver.AreNotEqual(v1.Hash, v2.Hash);
            Aver.AreNotEqual(v1.ValueEntityId, v2.ValueEntityId);
            Aver.IsTrue(v1 != v2);
        }
コード例 #2
0
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = new GameId();
     Field0.Parse(buffer);
     Field1 = new EntityId();
     Field1.Parse(buffer);
     Field2 = buffer.ReadInt(5) + (-1);
 }
コード例 #3
0
ファイル: ShardKey.cs プロジェクト: JohnPKosh/azos
        /// <summary>
        /// Returns a stable hash value derived from the actual value encoded in this instance.
        /// The system adds "avalanche" effect for better bit distribution
        /// </summary>
        public ulong GetDistributedStableHash()
        {
            switch (DataType)
            {
            case Type.Uninitialized: return(0);

            case Type.Gdid:  return(ForUlong(Buffer.GetDistributedStableHash()));

            case Type.Atom:  return(ForUlong(new Atom(Buffer.ID).GetDistributedStableHash()));

            case Type.EntityId: return(EntityId.Parse(ObjectValue as string).GetDistributedStableHash());//EntityId is already distributed

            case Type.Ulong: return(ForUlong(Buffer.ID));

            case Type.Uint:  return(ForUlong(Buffer.ID));

            case Type.DateTime: return(ForUlong(Buffer.ID));

            case Type.IDistributedStableHashProvider:
            {
                if (ObjectValue == null)
                {
                    return(0ul);
                }
                return(ForUlong(((IDistributedStableHashProvider)ObjectValue).GetDistributedStableHash()));
            }

            case Type.Guid:
            {
                if (ObjectValue == null)
                {
                    return(0ul);
                }
                return(ForBytes((byte[])ObjectValue));
            }

            case Type.String:
            {
                if (ObjectValue == null)
                {
                    return(0ul);
                }
                return(ForString((string)ObjectValue));
            }

            case Type.ByteArray:
            {
                if (ObjectValue == null)
                {
                    return(0ul);
                }
                return(ForBytes((byte[])ObjectValue));
            }
            }

            throw new DataException(StringConsts.SHARDING_OBJECT_ID_ERROR.Args(DataType));
        }
コード例 #4
0
ファイル: JoinBNetGameMessage.cs プロジェクト: wlasser/D3Emu
 public override void Parse(GameBitBuffer buffer)
 {
     ToonEntityId = new EntityId();
     ToonEntityId.Parse(buffer);
     Field1 = new GameId();
     Field1.Parse(buffer);
     GameId       = buffer.ReadInt(32);
     Field3       = buffer.ReadInt64(64);
     Field4       = buffer.ReadInt(4) + (2);
     ProtocolHash = buffer.ReadInt(32);
     SNOPackHash  = buffer.ReadInt(32);
 }
コード例 #5
0
ファイル: EntityIdTests.cs プロジェクト: erxdkh/azos
        public void JSON01()
        {
            var v    = EntityId.Parse("abc@def::12:15:178");
            var obj  = new { a = v };
            var json = obj.ToJson();

            json.See();
            var map = json.JsonToDataObject() as JsonDataMap;
            var got = EntityId.Parse(map["a"].ToString());

            Aver.AreEqual(v, got);
        }
コード例 #6
0
        private void invariant(JsonDataMap got)
        {
            Aver.IsNotNull(got);
            Aver.AreEqual(new GDID(1, 3, 1234), got["gd"].AsGDID());
            Aver.AreEqual(new Guid("4937EE58-A81F-402A-B019-3D5EA6BC12D6"), got["gu"].AsGUID(Guid.Empty));
            Aver.AreEqual(Atom.Encode("abc123"), got["a"].AsAtom());
            Aver.AreEqual(EntityId.Parse("type.sch@sys::address"), got["e"].AsEntityId());

            Aver.AreEqual(new DateTime(1980, 08, 15, 12, 00, 00, DateTimeKind.Utc), got["dt"].AsDateTime(System.Globalization.DateTimeStyles.AdjustToUniversal));
            Aver.AreEqual(-123.4567m, got["m"].AsDecimal());
            Aver.AreEqual(-5e3d, got["d"].AsDouble());
            Aver.AreEqual(true, got["b"].AsBool());
            Aver.AreEqual(-8_000_000_000L, got["li"].AsLong());
            Aver.AreEqual("my string!", got["s"].AsString());
        }
コード例 #7
0
ファイル: EntityIdTests.cs プロジェクト: erxdkh/azos
        public void JSON04()
        {
            var d1 = new Doc1 {
                V1 = EntityId.Parse("abc@def::abc@def::456"), V2 = EntityId.Parse("lic:::::")
            };
            var json = d1.ToJson(JsonWritingOptions.PrettyPrintRowsAsMap);

            json.See();
            var got = JsonReader.ToDoc <Doc1>(json);

            got.See();

            Aver.AreEqual("abc@def::456", got.V1.Address);
            Aver.AreEqual(":::", got.V2.Value.Address);
        }
コード例 #8
0
ファイル: EntityIdTests.cs プロジェクト: erxdkh/azos
        public void JSON03()
        {
            var d1 = new Doc1 {
                V1 = EntityId.Parse("abc@def::12:15:178"), V2 = EntityId.Parse("lic::i9973od")
            };
            var json = d1.ToJson(JsonWritingOptions.PrettyPrintRowsAsMap);

            json.See();
            var got = JsonReader.ToDoc <Doc1>(json);

            got.See();

            Aver.AreEqual(d1.V1, got.V1);
            Aver.AreEqual(d1.V2, got.V2);
        }
コード例 #9
0
 public override void Parse(GameBitBuffer buffer)
 {
     PlayerIndex = buffer.ReadInt(3);
     ToonId      = new EntityId();
     ToonId.Parse(buffer);
     GameAccountId = new EntityId();
     GameAccountId.Parse(buffer);
     ToonName         = buffer.ReadCharArray(49);
     Field3           = buffer.ReadInt(5) + (-1);
     Field4           = buffer.ReadInt(3) + (-1);
     snoActorPortrait = buffer.ReadInt(32);
     Field6           = buffer.ReadInt(7);
     StateData        = new HeroStateData();
     StateData.Parse(buffer);
     Field8  = buffer.ReadBool();
     Field9  = buffer.ReadInt(32);
     ActorID = buffer.ReadUInt(32);
 }
コード例 #10
0
ファイル: EntityIdTests.cs プロジェクト: azist/azos
        public void JSON06()
        {
            var d1 = new Doc1 {
                V1 = EntityId.Parse("abc.int@sys1::address1"), V2 = null
            };
            var json = d1.ToJson(JsonWritingOptions.PrettyPrintRowsAsMap);

            json.See();
            var got = JsonReader.ToDoc <Doc1>(json);

            got.See();

            Aver.AreEqual("sys1", got.V1.System.Value);
            Aver.AreEqual("int", got.V1.Schema.Value);
            Aver.AreEqual("address1", got.V1.Address);

            Aver.IsTrue(got.V2 == null);
        }
コード例 #11
0
        public async Task EchoVariousParams_POST()
        {
            var obj = new
            {
                gd = new GDID(1, 3, 1234),
                gu = new Guid("4937EE58-A81F-402A-B019-3D5EA6BC12D6"),
                a  = Atom.Encode("abc123"),
                e  = EntityId.Parse("type.sch@sys::address"),
                dt = new DateTime(1980, 08, 15, 12, 00, 00, DateTimeKind.Utc),
                m  = -123.4567m,
                d  = -5e3,
                b  = true,
                li = -8_000_000_000L,
                s  = "my string!"
            };
            var got = await Client.PostAndGetJsonMapAsync("echovariousparams", obj);

            invariant(got);
        }
    }
コード例 #12
0
        public async Task EchoVariousParams_GET()
        {
            var uri = new UriQueryBuilder("echovariousparams")
                      .Add("gd", new GDID(1, 3, 1234))
                      .Add("gu", new Guid("4937EE58-A81F-402A-B019-3D5EA6BC12D6"))
                      .Add("a", Atom.Encode("abc123"))
                      .Add("e", EntityId.Parse("type.sch@sys::address").AsString)
                      .Add("dt", new DateTime(1980, 08, 15, 12, 00, 00, DateTimeKind.Utc).ToString("o"))
                      .Add("m", -123.4567m)
                      .Add("d", -5e3)
                      .Add("b", true)
                      .Add("li", -8_000_000_000L)
                      .Add("s", "my string!");

            uri.ToString().See();

            var response = await Client.GetAsync(uri.ToString());

            Aver.IsTrue(HttpStatusCode.OK == response.StatusCode);
            var got = (await response.Content.ReadAsStringAsync()).JsonToDataObject() as JsonDataMap;

            invariant(got);
        }
コード例 #13
0
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = new EntityId();
     Field0.Parse(buffer);
     Field1 = new GameId();
     Field1.Parse(buffer);
     Field2 = buffer.ReadInt(32);
     Field3 = buffer.ReadInt64(64);
     Field4 = buffer.ReadInt(4) + (2);
     Field5 = buffer.ReadInt(32);
     Field6 = buffer.ReadInt(32);
 }
コード例 #14
0
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = new EntityId();
     Field0.Parse(buffer);
 }
コード例 #15
0
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(3);
     Field1 = new EntityId();
     Field1.Parse(buffer);
     Field2 = new EntityId();
     Field2.Parse(buffer);
     Field3 = buffer.ReadCharArray(49);
     Field4 = buffer.ReadInt(5) + (-1);
     Field5 = buffer.ReadInt(3) + (-1);
     snoActorPortrait = buffer.ReadInt(32);
     Field7 = buffer.ReadInt(7);
     Field8 = new HeroStateData();
     Field8.Parse(buffer);
     Field9 = buffer.ReadBool();
     Field10 = buffer.ReadInt(32);
     Field11 = buffer.ReadInt(32);
 }
コード例 #16
0
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(2) + (-1);
     Field1 = new EntityId();
     Field1.Parse(buffer);
 }
コード例 #17
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new RequiredMessageHeader();
     Field0.Parse(buffer);
     Field1 = new EntityId();
     Field1.Parse(buffer);
 }
コード例 #18
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new RequiredMessageHeader();
     Field0.Parse(buffer);
     Field1 = new GameId();
     Field1.Parse(buffer);
     Field2 = new EntityId();
     Field2.Parse(buffer);
     Field3 = buffer.ReadInt(5) + (-1);
 }
コード例 #19
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new RequiredMessageHeader();
     Field0.Parse(buffer);
     Field1 = new EntityId();
     Field1.Parse(buffer);
     Field2 = new GameId();
     Field2.Parse(buffer);
     Field3 = buffer.ReadInt(32);
     Field4 = buffer.ReadInt64(64);
     Field5 = buffer.ReadInt(4) + (2);
     Field6 = buffer.ReadInt(32);
     Field7 = buffer.ReadInt(32);
 }
コード例 #20
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(2);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(32);
     Field3 = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     Field5 = buffer.ReadInt(32);
     Field6 = buffer.ReadInt(32);
     Field7 = buffer.ReadInt(32);
     Field8 = new int[2];
     for(int i = 0;i < _Field8.Length;i++) _Field8[i] = buffer.ReadInt(32);
     Field9 = new int[2];
     for(int i = 0;i < _Field9.Length;i++) _Field9[i] = buffer.ReadInt(32);
     Field10 = new int[2];
     for(int i = 0;i < _Field10.Length;i++) _Field10[i] = buffer.ReadInt(32);
     Field11 = new EntityId();
     Field11.Parse(buffer);
 }
コード例 #21
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new RequiredMessageHeader();
     Field0.Parse(buffer);
     Field1 = buffer.ReadInt(3);
     Field2 = new EntityId();
     Field2.Parse(buffer);
     Field3 = new EntityId();
     Field3.Parse(buffer);
     Field4 = buffer.ReadCharArray(49);
     Field5 = buffer.ReadInt(5) + (-1);
     Field6 = buffer.ReadInt(3) + (-1);
     snoActorPortrait = buffer.ReadInt(32);
     Field8 = buffer.ReadInt(7);
     Field9 = new HeroStateData();
     Field9.Parse(buffer);
     Field10 = buffer.ReadBool();
     Field11 = buffer.ReadInt(32);
     Field12 = buffer.ReadInt(32);
 }
コード例 #22
0
ファイル: EntityIdMessage.cs プロジェクト: rdavydov/d3sharp
 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = new EntityId();
     Field0.Parse(buffer);
 }
コード例 #23
0
 public static TEntityId ParseEntityId <TEntityId>(this string entityId)
     where TEntityId : EntityId <TEntityId>, new()
 {
     return(EntityId <TEntityId> .Parse(entityId));
 }