internal Enumerator(MessagePackObjectDictionary dictionary) { #if !UNITY Contract.Assert(dictionary != null); #endif // !UNITY this._underlying = dictionary.GetEnumerator(); }
internal DictionaryEnumerator(MessagePackObjectDictionary dictionary) : this() { //#if !UNITY ////Contract.Assert( dictionary != null ); //#endif // !UNITY this._underlying = new Enumerator(dictionary); }
public void TestPackT_IDictionary_ItemIsMessagePackObject_Success() { var value = new MessagePackObjectDictionary() { { 1, 1 }, { 2, 2 } }; TestPackTCore <IDictionary>(value, new byte[] { 0x82, 0x1, 0x1, 0x2, 0x2 }); }
public void TestToObject_Dictionary_Success() { var value = new MessagePackObjectDictionary() { { "1", 1 }, { "2", 2 } }; TestToObjectCore(new MessagePackObject(value), value); }
internal KeyCollection(MessagePackObjectDictionary dictionary) #endif // !UNITY { #if !UNITY Contract.Assert(dictionary != null, "dictionary != null"); #endif // !UNITY this._dictionary = dictionary; }
internal Enumerator( MessagePackObjectDictionary dictionary ) : this() { Contract.Assert( dictionary != null, "dictionary != null" ); this = default( Enumerator ); this._underlying = dictionary; this.ResetCore(); }
private static void DictionaryEquals(MessagePackObjectDictionary actual, IDictionary <int, int> expected) { foreach (var entry in actual) { int value; Assert.That(expected.TryGetValue(entry.Key.AsInt32(), out value), "Key: " + entry.Key); Assert.That(entry.Value, Is.EqualTo(( MessagePackObject )value), "Value: " + entry.Key); } }
internal Enumerator(MessagePackObjectDictionary dictionary) : this() { //#if !UNITY // //Contract.Assert( dictionary != null ); //#endif // !UNITY this = default(Enumerator); this._underlying = dictionary; this.ResetCore(); }
Hashtable convertFromMsgPackObjectDictionary(MsgPack.MessagePackObjectDictionary mpobj) { Hashtable ht = new Hashtable(); MsgPack.MessagePackObjectDictionary.Enumerator e = mpobj.GetEnumerator(); while (e.MoveNext()) { MsgPack.MessagePackObject key = e.Current.Key; MsgPack.MessagePackObject val = e.Current.Value; ht.Add(key.AsString(), convertFromMsgPackObject(val)); } return(ht); }
/// <summary> /// Unpacks current subtree and returns subtree root as array or map. /// </summary> /// <returns> /// An unpacked array or map when current position is array or map header. /// <c>null</c> when current position is not array nor map header. /// </returns> public MessagePackObject?UnpackSubtree() { if (this.IsArrayHeader) { var array = new MessagePackObject[checked (( int )this.Data.Value.AsUInt32())]; using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < array.Length; i++) { var item = subTreeReader.ReadItem(); Contract.Assert(item.HasValue); array[i] = item.Value; } } this.Data = new MessagePackObject(array, true); } else if (this.IsMapHeader) { var capacity = checked (( int )this.Data.Value.AsUInt32()); var map = new MessagePackObjectDictionary(capacity); using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < capacity; i++) { var key = subTreeReader.ReadItem(); var value = subTreeReader.ReadItem(); Contract.Assert(key.HasValue); Contract.Assert(value.HasValue); map.Add(key.Value, value.Value); } } this.Data = new MessagePackObject(map, true); } else { return(null); } return(this.Data); }
public MessagePackObject?UnpackSubtree() { Unpacker unpacker; int num; if (this.IsArrayHeader) { MessagePackObject[] objArray = new MessagePackObject[this.Data.Value.AsUInt32()]; using (unpacker = this.ReadSubtree()) { for (num = 0; num < objArray.Length; num++) { MessagePackObject?nullable = unpacker.ReadItem(); Contract.Assert(nullable.HasValue); objArray[num] = nullable.Value; } } this.Data = new MessagePackObject(objArray, true); } else if (this.IsMapHeader) { int initialCapacity = (int)this.Data.Value.AsUInt32(); MessagePackObjectDictionary dictionary = new MessagePackObjectDictionary(initialCapacity); using (unpacker = this.ReadSubtree()) { for (num = 0; num < initialCapacity; num++) { MessagePackObject?nullable2 = unpacker.ReadItem(); MessagePackObject?nullable3 = unpacker.ReadItem(); Contract.Assert(nullable2.HasValue); Contract.Assert(nullable3.HasValue); dictionary.Add(nullable2.Value, nullable3.Value); } } this.Data = new MessagePackObject(dictionary, true); } else { return(null); } return(this.Data); }
internal bool UnpackSubtreeDataCore(out MessagePackObject result) { // ReSharper disable RedundantIfElseBlock if (this.IsArrayHeader) { var array = new MessagePackObject[checked (( int )this.LastReadData.AsUInt32())]; using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < array.Length; i++) { array[i] = subTreeReader.ReadItemData(); } } result = new MessagePackObject(array, true); return(true); } else if (this.IsMapHeader) { var capacity = checked (( int )this.LastReadData.AsUInt32()); var map = new MessagePackObjectDictionary(capacity); using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < capacity; i++) { var key = subTreeReader.ReadItemData(); var value = subTreeReader.ReadItemData(); map.Add(key, value); } } result = new MessagePackObject(map, true); return(true); } else { result = default(MessagePackObject); return(false); } // ReSharper restore RedundantIfElseBlock }
MsgPack.MessagePackObject convertToMsgPackObject(object v) { Type t = v.GetType(); if (t.Equals(typeof(Hashtable))) { Hashtable ht = v as Hashtable; IDictionaryEnumerator e = ht.GetEnumerator(); MsgPack.MessagePackObjectDictionary d = new MsgPack.MessagePackObjectDictionary(); while (e.MoveNext()) { d.Add(new MsgPack.MessagePackObject(e.Key as string), convertToMsgPackObject(e.Value)); } return(new MsgPack.MessagePackObject(d)); } else if (t.Equals(typeof(ArrayList))) { ArrayList al = v as ArrayList; IEnumerator e = al.GetEnumerator(); System.Collections.Generic.IList <MsgPack.MessagePackObject> l = new System.Collections.Generic.List <MsgPack.MessagePackObject> (); while (e.MoveNext()) { l.Add(convertToMsgPackObject(e.Current)); } return(new MsgPack.MessagePackObject(l)); } else if (t.Equals(typeof(bool))) { return(new MsgPack.MessagePackObject((bool)v)); } else if (t.Equals(typeof(string))) { return(new MsgPack.MessagePackObject((string)v)); } else { Debug.AssertFormat(false, "Unknwon type: " + t.Name); return(new MsgPack.MessagePackObject()); } }
internal async Task <AsyncReadResult <MessagePackObject> > UnpackSubtreeDataAsyncCore(CancellationToken cancellationToken) { if (this.IsArrayHeader) { var array = new MessagePackObject[checked (( int )this.LastReadData.AsUInt32())]; using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < array.Length; i++) { array[i] = await subTreeReader.ReadItemDataAsync(cancellationToken).ConfigureAwait(false); } } return(AsyncReadResult.Success(new MessagePackObject(array, true))); } else if (this.IsMapHeader) { var capacity = checked (( int )this.LastReadData.AsUInt32()); var map = new MessagePackObjectDictionary(capacity); using (var subTreeReader = this.ReadSubtree()) { for (int i = 0; i < capacity; i++) { var key = await subTreeReader.ReadItemDataAsync(cancellationToken).ConfigureAwait(false); var value = await subTreeReader.ReadItemDataAsync(cancellationToken).ConfigureAwait(false); map.Add(key, value); } } return(AsyncReadResult.Success(new MessagePackObject(map, true))); } else { return(AsyncReadResult.Fail <MessagePackObject>()); } }
internal ValueCollection( MessagePackObjectDictionary dictionary ) { this._dictionary = dictionary; }
internal ValueCollection(MessagePackObjectDictionary dictionary) { Contract.Assert(dictionary != null, "dictionary != null"); this._dictionary = dictionary; }
internal KeySet(MessagePackObjectDictionary dictionary) { Contract.Assert(dictionary != null); this._dictionary = dictionary; }
internal DictionaryEnumerator(MessagePackObjectDictionary dictionary) { this = new MessagePackObjectDictionary.DictionaryEnumerator(); Contract.Assert(dictionary != null); this._underlying = new MessagePackObjectDictionary.Enumerator(dictionary); }
internal Enumerator(MessagePackObjectDictionary dictionary) { this._underlying = dictionary.GetEnumerator(); }
internal KeySet(MessagePackObjectDictionary dictionary)
internal Enumerator(MessagePackObjectDictionary dictionary) { Contract.Assert(dictionary != null, "dictionary != null"); this._underlying = dictionary.GetEnumerator(); }
static void runobserveNodes() { var linkto = "127.0.0.1:1892"; var node = new Node(null, linkto, null, true);//观察节点 node.actor.beObserver = true; var pipeline = node.sys.GetPipeline(null, "this/node"); while (pipeline.IsVaild) { Console.WriteLine("localCmd a1=a系统的plevel(5)联向b系统的plevel(6) a2=>:a系统的plevel(5)联向b系统的plevel(5) a3=a系统的plevel(5)联向b系统的plevel(2)"); Console.WriteLine("localCmd b1=断开a系统的plevel(5)到b系统的plevel(6)连接 b2=>:断开a系统的plevel(5)到b系统的plevel(5)连接 b3=断开a系统的plevel(5)联向b系统的plevel(2)连接"); var line = Console.ReadLine(); if (string.IsNullOrEmpty(line) == false) { if (line == "exit") { //node.actor.Dispose(); node.sys.Dispose(); break; } if (line == "a1" || line == "a2" || line == "a3" || line == "b1" || line == "b2" || line == "b3") { switch (line) { case "a1": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_ConnectTo("127.0.0.1:2896")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; case "a2": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_ConnectTo("127.0.0.1:2895")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; case "a3": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_ConnectTo("127.0.0.1:2892")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; case "b1": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_DisconnectTo("127.0.0.1:2896")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; case "b2": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_DisconnectTo("127.0.0.1:2895")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; case "b3": { var msg = node.actor.makeCmd_SendMsg("127.0.0.1:1895", node.actor.makeCmd_DisconnectTo("127.0.0.1:2892")); var localcmd = node.actor.makeCmd_FakeRemote(msg); pipeline.Tell(localcmd); } break; } } else { var cmds = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); var dict = new MsgPack.MessagePackObjectDictionary(); dict["cmd"] = (UInt16)AllPet.Module.CmdList.Local_Cmd; var list = new MsgPack.MessagePackObject[cmds.Length]; for (var i = 0; i < cmds.Length; i++) { list[i] = cmds[i]; } dict["params"] = list; pipeline.Tell(new MsgPack.MessagePackObject(dict)); } } } }