本文整理汇总了C#中Variant.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.Add方法的具体用法?C# Variant.Add怎么用?C# Variant.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variant
的用法示例。
在下文中一共展示了Variant.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSelect
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);
}
示例2: TestStreams
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));
}
示例3: TestDictionaryMissingKey
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"];
}
示例4: GetStats
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;
}
示例5: TestDictionaryEnumerator
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;
}
}
示例6: TestBytes
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));
}
示例7: TestDictionary
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));
}
示例8: TestDictionary
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");
}
示例9: GetAuctionSellList
/// <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;
}
示例10: TaskGiveup
/// <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;
}
示例11: TestListEnumerator
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;
}
}
示例12: Deflate
public Variant Deflate()
{
Variant result = new Variant(Variant.EnumType.Dictionary);
result.Add("value", new Variant(m_value));
return result;
}
示例13: GetStats
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);
}
示例14: GetStats
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", "");
}
}
示例15: GetStats
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);
}