public void TestListAdd() { Variant v = new Variant(Variant.EnumType.List); Assert.Throws <VariantException>(delegate { v.Add("key", new Variant()); }); Assert.Throws <VariantException>(delegate { v.Add(new DateTime(0), new Variant()); }); v.Add(new Variant("value1")); v.Add(new Variant(2.0)); Assert.AreEqual(v.Count, 2); Assert.IsFalse(v.Empty); Assert.AreEqual(Variant.EnumType.String, v[0].Type); Assert.AreEqual("value1", v[0].As <string>()); Assert.AreEqual(Variant.EnumType.Double, v[1].Type); Assert.AreEqual(2.0, v[1].As <double>()); Assert.Throws <VariantException>(delegate { Variant w = v[-1]; }); Assert.Throws <VariantException>(delegate { Variant w = v[2]; }); v[0] = new Variant("other"); Assert.AreEqual(v[0].As <string>(), "other"); v.Clear(); Assert.AreEqual(v.Count, 0); Assert.IsTrue(v.Empty); }
public void TestDictionaryComparison() { Variant v1 = new Variant(Variant.EnumType.Dictionary); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.Dictionary); v2.Add("key2", new Variant("value2")); v2.Add("key1", new Variant("value1")); Variant v3 = new Variant(Variant.EnumType.Dictionary); v3.Add("key2", new Variant("value1")); v3.Add("key3", new Variant("value2")); Variant v4 = new Variant(Variant.EnumType.Dictionary); v4.Add("key1", new Variant("value2")); v4.Add("key2", new Variant("value3")); Assert.AreEqual(0, v1.CompareTo(v2)); Assert.AreEqual(-1, v1.CompareTo(v3)); Assert.AreEqual(1, v3.CompareTo(v1)); Assert.AreEqual(-1, v1.CompareTo(v4)); Assert.AreEqual(1, v4.CompareTo(v1)); }
public void TestSelect() { Variant v = new Variant(Variant.EnumType.Dictionary); v.Add("key1", new Variant(Variant.EnumType.Dictionary)); v.Add("key2", new Variant(Variant.EnumType.Bag)); v["key1"].Add("key3", new Variant("value1")); v["key1"].Add("key4", new Variant("value2")); v["key2"].Add("key5", new Variant("value3")); v["key2"].Add("key6", new Variant("value4")); v["key2"].Add("key5", new Variant("value5")); Variant s1 = v.Select("/none/"); Variant s2 = v.Select("/key1/"); Variant s3 = v.Select("/key1/*"); Variant s4 = v.Select("/key1/key3"); Variant s5 = v.Select("/key1/key4"); Variant s6 = v.Select("/key2/"); Variant s7 = v.Select("/key2/*"); Variant s8 = v.Select("/key2/key5"); Variant s9 = v.Select("/key2/key6"); Assert.AreEqual(0, s1.Count); Assert.AreEqual(1, s2.Count); Assert.AreEqual(2, s3.Count); Assert.AreEqual(1, s4.Count); Assert.AreEqual(1, s5.Count); Assert.AreEqual(1, s6.Count); Assert.AreEqual(3, s7.Count); Assert.AreEqual(2, s8.Count); Assert.AreEqual(1, s9.Count); }
public void TestBagRange() { Variant v = new Variant(Variant.EnumType.Bag); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant(1.0)); v.Add("key1", new Variant("value2")); Variant r1 = v.Range("missing"); Assert.AreEqual(Variant.EnumType.List, r1.Type); Assert.AreEqual(0, r1.Count); Variant r2 = v.Range("key1"); Assert.AreEqual(Variant.EnumType.List, r2.Type); Assert.AreEqual(2, r2.Count); Assert.AreEqual("value1", r2[0].As <string>()); Assert.AreEqual("value2", r2[1].As <string>()); Variant r3 = v.Range("key2"); Assert.AreEqual(Variant.EnumType.List, r2.Type); Assert.AreEqual(1, r3.Count); Assert.AreEqual(1.0, r3[0].As <double>()); }
public void TestBagEnumeration() { Variant v = new Variant(Variant.EnumType.Bag); v.Add("key2", new Variant("value2")); v.Add("key1", new Variant("value1")); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant("value2")); IEnumerator <VariantItem> en = v.GetEnumerator(); en.Reset(); Assert.IsTrue(en.MoveNext()); Assert.AreEqual("key2", en.Current.Key); Assert.AreEqual("value2", en.Current.Value.As <string>()); Assert.IsTrue(en.MoveNext()); Assert.AreEqual("key1", en.Current.Key); Assert.AreEqual("value1", en.Current.Value.As <string>()); Assert.IsTrue(en.MoveNext()); Assert.AreEqual("key1", en.Current.Key); Assert.AreEqual("value1", en.Current.Value.As <string>()); Assert.IsTrue(en.MoveNext()); Assert.AreEqual("key2", en.Current.Key); Assert.AreEqual("value2", en.Current.Value.As <string>()); Assert.IsFalse(en.MoveNext()); }
public void TestStreams() { Variant dict = new Variant(Variant.EnumType.Dictionary); dict.Add("key1", new Variant("value1")); dict.Add("key2", new Variant("value2")); Variant input = new Variant(Variant.EnumType.List); for (int i = 0; i < 10000; ++i) { input.Add(dict); } System.IO.MemoryStream istream = new System.IO.MemoryStream(); using(BinaryWriter writer = new BinaryWriter(istream)) { writer.Write(input); } Variant output; System.IO.MemoryStream ostream = new System.IO.MemoryStream(istream.GetBuffer()); using (BinaryReader reader = new BinaryReader(ostream)) { output = reader.Read(); } Assert.True(input.Equals(output)); }
public void TestPrimitives() { Int32 argInt32 = -1; UInt32 argUInt32 = 0xffffffff; Int64 argInt64 = -1; UInt64 argUInt64 = 0xffffffffffffffff; bool argBoolean = true; double argDouble = 2.0; string argString = "test string"; DateTime argDateTime = new DateTime(2010, 1, 2, 3, 4, 5, 6); TimeSpan argTime = new TimeSpan(0, 1, 2, 3, 4); Variant v1 = new Variant(Variant.EnumType.Dictionary); v1.Add("Int32", new Variant(argInt32)); v1.Add("UInt32", new Variant(argUInt32)); v1.Add("Int64", new Variant(argInt64)); v1.Add("UInt64", new Variant(argUInt64)); v1.Add("Boolean", new Variant(argBoolean)); v1.Add("Double", new Variant(argDouble)); v1.Add("String", new Variant(argString)); v1.Add("DateTime", new Variant(argDateTime)); v1.Add("Time", new Variant(argTime)); v1.Add("None", new Variant(Variant.EnumType.None)); string xml = XmlWriter.ToString(v1); Variant v2 = XmlReader.FromString(xml); Assert.IsTrue(v1.Equals(v2)); }
public void TestDictionaryAdd() { Variant v = new Variant(Variant.EnumType.Dictionary); Assert.Throws <VariantException>(delegate { v.Add(new Variant()); }); Assert.Throws <VariantException>(delegate { v.Add(new DateTime(0), new Variant()); }); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant(1.0)); Assert.AreEqual(v.Count, 2); Assert.IsFalse(v.Empty); Assert.IsTrue(v.ContainsKey("key1")); Assert.IsTrue(v.ContainsKey("key2")); Assert.AreEqual(v["key1"].Type, Variant.EnumType.String); Assert.AreEqual(v["key1"].As <string>(), "value1"); Assert.AreEqual(v["key2"].Type, Variant.EnumType.Double); Assert.AreEqual(v["key2"].As <double>(), 1.0); v["key1"] = new Variant("other"); Assert.AreEqual(v["key1"].As <string>(), "other"); v.Remove("key1"); Assert.AreEqual(v.Count, 1); v.Remove("key2"); Assert.AreEqual(v.Count, 0); Assert.IsTrue(v.Empty); }
public void TestDictionaryMissingKey() { Variant v = new Variant(Variant.EnumType.Dictionary); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant("value2")); Variant MissingValue = v["missing key"]; }
public bool GetStats(Variant info) { info.Add("type", "IOHT_UDP_CARRIER"); info.Add("nearIP", NearIP); info.Add("nearPort", NearPort); info.Add("rx", Rx); return true; }
public bool GetStats(Variant info) { info.Add("type", "IOHT_UDP_CARRIER"); info.Add("nearIP", NearIP); info.Add("nearPort", NearPort); info.Add("rx", Rx); return(true); }
public void TestBag() { Variant v1 = new Variant(Variant.EnumType.Bag); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant(1.0)); byte[] bytes = BinaryWriter.ToBytes(v1); Variant v2 = BinaryReader.FromBytes(bytes); Assert.AreEqual(v2.Type, Variant.EnumType.Bag); Assert.IsTrue(v1.Equals(v2)); }
public void TestTSAdd() { Variant v = new Variant(Variant.EnumType.TimeSeries); Assert.Throws <VariantException>(delegate { v.Add(new Variant()); }); Assert.Throws <VariantException>(delegate { v.Add("key", new Variant()); }); v.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant(1.0)); Assert.AreEqual(v.Count, 2); Assert.IsFalse(v.Empty); }
public void TestBag() { Variant v1 = new Variant(Variant.EnumType.Bag); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant(1.0)); string xml = XmlWriter.ToString(v1); Variant v2 = XmlReader.FromString(xml); Assert.AreEqual(v2.Type, Variant.EnumType.Bag); Assert.IsTrue(v1.Equals(v2)); }
public override void GetStats(Variant info, uint namespaceId) { if (!GetEndpointsInfo()) { Logger.FATAL("Unable to get endpoints info"); info.SetValue("unable to get endpoints info"); return; } info.Add("type", "IOHT_UDP_CARRIER"); info.Add("nearIP", NearIP); info.Add("nearPort", NearPort); info.Add("rx", Rx); }
public void TestTimeSeries() { Variant v1 = new Variant(Variant.EnumType.TimeSeries); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2")); string xml = XmlWriter.ToString(v1); Variant v2 = XmlReader.FromString(xml); Assert.AreEqual(v2.Type, Variant.EnumType.TimeSeries); Assert.IsTrue(v1.Equals(v2)); }
public void TestTimeSeries() { Variant v1 = new Variant(Variant.EnumType.TimeSeries); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2")); byte[] bytes = BinaryWriter.ToBytes(v1); Variant v2 = BinaryReader.FromBytes(bytes); Assert.AreEqual(v2.Type, Variant.EnumType.TimeSeries); Assert.IsTrue(v1.Equals(v2)); }
public void TestListComparison() { Variant v1 = new Variant(Variant.EnumType.List); v1.Add(new Variant("value1")); v1.Add(new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.List); v2.Add(new Variant("value2")); v2.Add(new Variant("value1")); Assert.AreEqual(0, v1.CompareTo(v1)); Assert.AreEqual(-1, v1.CompareTo(v2)); Assert.AreEqual(1, v2.CompareTo(v1)); }
public void TestHeaderOutput() { Variant value = new Variant(Variant.EnumType.Bag); value.Add("key1", new Variant("value1")); value.Add("key2", new Variant(1.0)); var expectUtf8Header = XmlWriter.ToString(value); Assert.That(expectUtf8Header, Is.EqualTo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Variant variant=\"Bag\"><key1 variant=\"String\">value1</key1><key2 variant=\"Double\">1</key2></Variant>")); var expectNoHeader = XmlWriter.ToString(value, XmlMode.NoHeader); Assert.That(expectNoHeader, Is.EqualTo("<Variant variant=\"Bag\"><key1 variant=\"String\">value1</key1><key2 variant=\"Double\">1</key2></Variant>")); }
public void TestDictionaryEnumerator() { Variant dict = new Variant(Variant.EnumType.Dictionary); for (int i = 0; i < 1; ++i) { dict.Add(i.ToString(), new Variant(i)); } // Generic enumerator int count = 0; foreach (VariantItem item in dict) { Assert.True(item.Value.AsInt32().Equals(count)); Assert.True(item.Key.Equals(count.ToString())); Assert.Throws(typeof(VariantException), delegate { DateTime time = item.Time; } ); ++count; } // Non-generic enumerator count = 0; foreach (var item in dict) { Assert.True(item.Value.AsInt32().Equals(count)); Assert.True(item.Key.Equals(count.ToString())); Assert.Throws(typeof(VariantException), delegate { DateTime time = item.Time; } ); ++count; } }
public void TestListHashCode() { Variant v1 = new Variant(Variant.EnumType.List); v1.Add(new Variant("value1")); v1.Add(new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.List); v2.Add(new Variant("value1")); v2.Add(new Variant("value2")); Assert.AreEqual(v1, v2); Assert.AreNotSame(v1, v2); Assert.AreEqual(v1.GetHashCode(), v2.GetHashCode()); }
public override void GetStats(Variant info, uint namespaceId) { base.GetStats(info, namespaceId); info["inStreamUniqueId"] = InStream != null?Variant.Get((((ulong)namespaceId) << 32) | InStream.UniqueId) : Variant.Get(); info.Add("bandwidth", Capabilities?.BandwidthHint ?? 0); }
public void TestTSHashCode() { Variant v1 = new Variant(Variant.EnumType.TimeSeries); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.TimeSeries); v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2")); Assert.AreEqual(v1, v2); Assert.AreNotSame(v1, v2); Assert.AreEqual(v1.GetHashCode(), v2.GetHashCode()); }
public Variant Deflate() { Variant result = new Variant(Variant.EnumType.Dictionary); result.Add("value", new Variant(m_value)); return(result); }
public void TestBagHashCode() { Variant v1 = new Variant(Variant.EnumType.Bag); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.Bag); v2.Add("key1", new Variant("value1")); v2.Add("key2", new Variant("value2")); Assert.AreEqual(v1, v2); Assert.AreNotSame(v1, v2); Assert.AreEqual(v1.GetHashCode(), v2.GetHashCode()); }
public void TestTimeSeriesBuffer() { Variant v1 = new Variant(Variant.EnumType.TimeSeries); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2")); var bufferSize = BinaryWriter.GetByteCount(v1); byte[] bytes = new byte[bufferSize]; BinaryWriter.GetBytes(v1, BinaryMode.Default, bytes, 0); Variant v2 = BinaryReader.FromBytes(bytes); Assert.AreEqual(v2.Type, Variant.EnumType.TimeSeries); Assert.IsTrue(v1.Equals(v2)); }
public void TestBytes() { Variant dict = new Variant(Variant.EnumType.Dictionary); dict.Add("key1", new Variant("value1")); dict.Add("key2", new Variant("value2")); Variant input = new Variant(Variant.EnumType.List); for (int i = 0; i < 10000; ++i) { input.Add(dict); } byte[] bytes = BinaryWriter.ToBytes(input); Variant output = BinaryReader.FromBytes(bytes); Assert.True(input.Equals(output)); }
public void TestDictionary() { Variant input = new Variant(Variant.EnumType.Dictionary); input.Add("key1", new Variant("value1")); input.Add("key2", new Variant("value2")); StringBuilder ibuffer = new StringBuilder(); System.IO.StringWriter istream = new System.IO.StringWriter(ibuffer); XMLWriter writer = new XMLWriter(istream); writer.Write(input); System.IO.StringReader ostream = new System.IO.StringReader(ibuffer.ToString()); XMLReader reader = new XMLReader(ostream); Variant output = reader.Read(); Assert.True(input.Equals(output)); }
public void TestBagBuffer() { Variant v1 = new Variant(Variant.EnumType.Bag); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant(1.0)); var bufferSize = BinaryWriter.GetByteCount(v1); byte[] bytes = new byte[bufferSize]; BinaryWriter.GetBytes(v1, BinaryMode.Default, bytes, 0); Variant v2 = BinaryReader.FromBytes(bytes); Assert.AreEqual(v2.Type, Variant.EnumType.Bag); Assert.IsTrue(v1.Equals(v2)); }
public void TestDictionaryEnumeration() { Variant v = new Variant(Variant.EnumType.Dictionary); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant("value2")); int count = 1; foreach (VariantItem item in v) { Assert.AreEqual("key" + count, item.Key); Assert.AreEqual("value" + count, item.Value.As <string>()); Assert.Throws <VariantException>(delegate { DateTime t = item.Time; }); ++count; } }
public void TestListEnumeration() { Variant v = new Variant(Variant.EnumType.List); v.Add(new Variant("value1")); v.Add(new Variant(2.0)); IEnumerator <VariantItem> en = v.GetEnumerator(); en.Reset(); Assert.IsTrue(en.MoveNext()); Assert.Throws <VariantException>(delegate { string k = en.Current.Key; }); Assert.Throws <VariantException>(delegate { DateTime t = en.Current.Time; }); Assert.AreEqual("value1", en.Current.Value.As <string>()); Assert.IsTrue(en.MoveNext()); Assert.Throws <VariantException>(delegate { string k = en.Current.Key; }); Assert.Throws <VariantException>(delegate { DateTime t = en.Current.Time; }); Assert.AreEqual(2.0, en.Current.Value.As <double>()); Assert.IsFalse(en.MoveNext()); }
public void TestTSEnumeration() { Variant v = new Variant(Variant.EnumType.TimeSeries); v.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2")); IEnumerator <VariantItem> en = v.GetEnumerator(); en.Reset(); Assert.IsTrue(en.MoveNext()); Assert.Throws <VariantException>(delegate { string k = en.Current.Key; }); Assert.AreEqual("value1", en.Current.Value.As <string>()); Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), en.Current.Time); Assert.IsTrue(en.MoveNext()); Assert.Throws <VariantException>(delegate { string k = en.Current.Key; }); Assert.AreEqual("value2", en.Current.Value.As <string>()); Assert.AreEqual(new DateTime(2010, 1, 3, 3, 4, 5, 6), en.Current.Time); Assert.IsFalse(en.MoveNext()); }
public void TestDictionary() { Variant v = new Variant(Variant.EnumType.Dictionary); Assert.AreEqual(v.Count, 0); Assert.IsFalse(v.ContainsKey("key1")); Assert.IsFalse(v.ContainsKey("key2")); v.Add("key1", new Variant("value1")); v.Add("key2", new Variant("value2")); Assert.AreEqual(v.Count, 2); Assert.IsTrue(v.ContainsKey("key1")); Assert.IsTrue(v.ContainsKey("key2")); Assert.AreEqual(v["key1"].AsString(), "value1"); Assert.AreEqual(v["key2"].AsString(), "value2"); }
public void TestPerformanceCS() { Int32 argInt32 = -1; UInt32 argUInt32 = 0xffffffff; Int64 argInt64 = -1; UInt64 argUInt64 = 0xffffffffffffffff; bool argBoolean = true; double argDouble = double.MaxValue; string argString = "test string"; Variant v1 = new Variant(Variant.EnumType.Dictionary); v1.Add("Int32", new Variant(argInt32)); v1.Add("UInt32", new Variant(argUInt32)); v1.Add("Int64", new Variant(argInt64)); v1.Add("UInt64", new Variant(argUInt64)); v1.Add("Boolean", new Variant(argBoolean)); v1.Add("Double", new Variant(argDouble)); v1.Add("String", new Variant(argString)); v1.Add("None", new Variant(Variant.EnumType.None)); const int numIterations = 50000; Variant v2 = new Variant(Variant.EnumType.List); for (int i = 0; i < numIterations; ++i) { v2.Add(v1); } DateTime t1 = DateTime.Now; // C# serialisation, compressed byte[] bytes = BinaryWriter.ToBytes(v2, BinaryMode.Compress); System.Console.WriteLine(bytes.Length); Assert.DoesNotThrow(() => BinaryReader.FromBytes(bytes)); DateTime t2 = DateTime.Now; // C# serialisation, default bytes = BinaryWriter.ToBytes(v2); System.Console.WriteLine(bytes.Length); Assert.DoesNotThrow(() => BinaryReader.FromBytes(bytes)); DateTime t3 = DateTime.Now; System.Console.WriteLine("C# serialisation timings: {0} (compressed), {1} (default)", t2 - t1, t3 - t2); }
protected override bool FeedMetaData(MediaFile pFile, MediaFrame mediaFrame) { //1. Seek into the data file at the correct position if (!pFile.SeekTo(mediaFrame.Start)) { FATAL("Unable to seek to position {0}", mediaFrame.Start); return(false); } var endPosition = pFile.Position + (long)mediaFrame.Length; //2. Read the data //_metadataBuffer.IgnoreAll(); //if (!_metadataBuffer.ReadFromFs(pFile, (int) mediaFrame.Length)) { // Logger.FATAL("Unable to read {0} bytes from offset {1}", mediaFrame.Length, mediaFrame.Start); // return false; //} //3. Parse the metadata _metadataName = ""; _metadataParameters.SetValue(); var _tempVariant = _amf0Reader.ReadVariant(); //if (!_amfSerializer.Read(_metadataBuffer, _tempVariant)) { // Logger.WARN("Unable to read metadata"); // return true; //} if (_tempVariant != VariantType.String) { WARN("Unable to read metadata"); return(true); } _metadataName = _tempVariant; while (pFile.Position < endPosition) { _metadataParameters.Add(_amf0Reader.ReadVariant()); } var message = GenericMessageFactory.GetNotify( ((BaseOutNetRTMPStream )OutStreams.Last()).CommandsChannelId, ((BaseOutNetRTMPStream )OutStreams.Last()).RTMPStreamId, mediaFrame.AbsoluteTime, true, _metadataName, _metadataParameters); //5. Send it return(((BaseRTMPProtocol )Protocol).SendMessage(message, true)); }
public void TestTSComparison() { Variant v1 = new Variant(Variant.EnumType.TimeSeries); v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1")); v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.TimeSeries); v2.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1")); v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2")); Variant v3 = new Variant(Variant.EnumType.TimeSeries); v3.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2")); v3.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1")); Assert.AreEqual(0, v1.CompareTo(v1)); Assert.AreEqual(-1, v1.CompareTo(v2)); Assert.AreEqual(1, v2.CompareTo(v1)); Assert.AreEqual(-1, v1.CompareTo(v3)); Assert.AreEqual(1, v3.CompareTo(v1)); }
public override void GetStats(Variant info, uint namespaceId) { info.Add("type", "IOHT_UDP_CARRIER"); info.Add("farIP", FarIP); info.Add("farPort", FarPort); info.Add("nearIP", NearIP); info.Add("nearPort", NearPort); info.Add("rx", Rx); }
/// <summary> /// 得到出售列表 /// </summary> /// <param name="playerid"></param> /// <param name="str"></param> /// <param name="pageSize">每页条数</param> /// <param name="pageIndex">当前页数</param> /// <returns></returns> public static List<Variant> GetAuctionSellList(string playerid, string str, int pageSize, int pageIndex,out int total,out int curIndex) { int m = 0; int n = 0; List<Auction> list = null; if (Seller==str) { list = AuctionAccess.Instance.AuctionSellerList(playerid, pageSize, pageIndex, out m, out n); } if (Bid == str) { list = AuctionAccess.Instance.AuctionBidderList(playerid, pageSize, pageIndex, out m, out n); } List<Variant> msg = new List<Variant>(); if (list != null) { foreach (Auction model in list) { Variant mv = model.Value; if (mv == null) continue; Variant v = new Variant(); foreach (var item in mv) { v.Add(item.Key, item.Value); } v.Add("ID", model.ID); v.Add("Name", model.Name); msg.Add(v); } } total = m; curIndex = n; return msg; }
/// <summary> /// 任务放异 /// </summary> /// <param name="note">角色信息</param> /// <param name="task">任务</param> /// <returns></returns> public static bool TaskGiveup(PlayerBusiness pb, Task task, bool isremove = true) { PlayerEx burden = pb.B0; Variant v = task.Value; //完成条件 IList finish = v["Finish"] as IList; foreach (Variant k in finish) { string goodsid = k.GetStringOrDefault("GoodsID"); int Cur = k.GetIntOrDefault("Cur"); if (Cur == 0) continue; switch (k.GetIntOrDefault("Type")) { case 10006: Dictionary<string, Variant> dic = new Dictionary<string, Variant>(); Variant vn = new Variant(); vn.Add("Number1", Cur); dic.Add(goodsid, vn); if (BurdenManager.IsFullBurden(burden, dic)) return true; pb.AddGoods(dic, GoodsSource.TaskGiveup); break; case 10003: case 10009: case 10010: BurdenManager.Remove(burden, goodsid, Cur); break; } k["Cur"] = 0; } v["Status"] = 0; if (isremove) { task.Save(); } pb.Call(TaskCommand.GiveupR, true, task.ID); return false; }
public void TestListEnumerator() { Variant list = new Variant(Variant.EnumType.List); for (int i = 0; i < 1; ++i) { list.Add(new Variant(i)); } // Generic enumerator int count = 0; foreach (VariantItem item in list) { Assert.True(item.Value.AsInt32().Equals(count)); Assert.Throws(typeof(VariantException), delegate { String key = item.Key; } ); Assert.Throws(typeof(VariantException), delegate { DateTime time = item.Time; } ); ++count; } // Non-generic enumerator count = 0; foreach (var item in list) { Assert.True(item.Value.AsInt32().Equals(count)); Assert.Throws(typeof(VariantException), delegate { String key = item.Key; } ); Assert.Throws(typeof(VariantException), delegate { DateTime time = item.Time; } ); ++count; } }
public virtual void GetStats(Variant info, uint namespaceId) { info.Add("id",(((ulong)namespaceId)<<32)|Id); info.Add("type",Type.TagToString()); info.Add("creationTimestamp",CreationTimestamp); info.Add("queryTimestamp",DateTime.Now); info.Add("isEnqueueForDelete",IsEnqueueForDelete); if (_application != null) { info.Add("applicationId", (((ulong)namespaceId) << 32) | _application.Id); }else info.Add("applicationId",((ulong)namespaceId)<<32); }
public Variant Deflate() { Variant result = new Variant(Variant.EnumType.Dictionary); result.Add("value", new Variant(m_value)); return result; }
public override void GetStats(Variant info, uint namespaceId) { info.Add("type", "IOHT_UDP_CARRIER"); info.Add("farIP",FarIP); info.Add("farPort", FarPort); info.Add("nearIP", NearIP); info.Add("nearPort", NearPort); info.Add("rx", Rx); }
public override void GetStats(Variant info, uint namespaceId) { if (!GetEndpointsInfo()) { Logger.FATAL("Unable to get endpoints info"); info.SetValue("unable to get endpoints info"); return; } info.Add("type", "IOHT_UDP_CARRIER"); info.Add("nearIP",NearIP); info.Add("nearPort",NearPort); info.Add("rx",Rx); }
public override void GetStats(Variant info, uint namespaceId) { info.SetValue(Parameters); info.Add("id",(((ulong)namespaceId)<<32)| Id); info.Add("enabled",_enabled); info.Add("acceptedConnectionsCount", _acceptedCount); info.Add("droppedConnectionsCount", _droppedCount); if (_pApplication != null) { info.Add("appId", (((ulong) namespaceId) << 32) | Application.Id); info.Add("appName", Application.Name); } else { info.Add("appId",((ulong) namespaceId) << 32); info.Add("appName", ""); } }