本文整理汇总了C#中System.Variant类的典型用法代码示例。如果您正苦于以下问题:C# Variant类的具体用法?C# Variant怎么用?C# Variant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Variant类属于System命名空间,在下文中一共展示了Variant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apc
public Apc(Variant config)
{
ID = config.GetStringOrDefault("_id");
this.Name = config.GetStringOrDefault("Name");
Name = config.GetStringOrDefault("Name");
m_value = config.GetVariantOrDefault("Value");
m_life = new PlayerProperty();
if (m_value != null)
{
m_life.Add(m_value);
this.Level = m_value.GetIntOrDefault("Level");
}
this.ApcType = FighterType.APC;
Variant ui = config.GetVariantOrDefault("UI");
if (ui != null)
{
this.Skin = ui.GetStringOrDefault("Skin");
string apcType = ui.GetStringOrDefault("Type");
if (apcType == "BB")
{
this.ApcType = FighterType.BB;
}
else if (apcType == "Boss")
{
this.ApcType = FighterType.Boss;
}
}
}
示例2: AddPetBook
/// <summary>
/// 学习宠物技能(御宠图鉴)
/// </summary>
/// <param name="variant"></param>
public bool AddPetBook(Variant c)
{
string skillID = c.GetStringOrDefault("SkillID");
if (string.IsNullOrEmpty(skillID)) return false;
int level = c.GetIntOrDefault("SkillLev");
var skill = m_petBook.Value.GetValueOrDefault<List<object>>(skillID);
if (skill == null)
{
skill = new List<object>();
m_petBook.Value[skillID] = skill;
}
if (skill.Contains(level))
{
return false;
}
int mustslevel = level - 1;
if (mustslevel > 0 && (!skill.Contains(mustslevel)))
{
return false;
}
skill.Add(level);
m_petBook.Save();
this.Call(ClientCommand.UpdateActorR, new PlayerExDetail(m_petBook));
return true;
}
示例3: GMAuctionList
/// <summary>
/// GM取得拍卖行数据
/// </summary>
/// <param name="note"></param>
/// <param name="strs"></param>
public static void GMAuctionList(GMNote note, string[] strs)
{
if (strs.Length < 3)
return;
PlayerBusiness player = PlayersProxy.FindPlayerByName(strs[0].Trim());
if (player == null)
return;
int pageIndex = 0;
if (!int.TryParse(strs[1].Trim(), out pageIndex))
return;
int pageSize = 6;
int total = 0;
int curIndex = 0;
List<Auction> auctionList = AuctionAccess.Instance.AuctionSellerList(player.ID, pageSize, pageIndex, out total, out curIndex);
List<Variant> list = new List<Variant>();
foreach (Auction model in auctionList)
{
Variant mv = model.Value;
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);
list.Add(v);
}
note.Call(GMCommand.GMAuctionListR, list, total, curIndex);
}
示例4: WriteAttributes
void WriteAttributes(Variant attribute)
{
foreach (VariantItem item in attribute)
{
m_writer.WriteAttributeString(item.Key, item.Value.AnyCast().As<string>());
}
}
示例5: Task10004
/// <summary>
/// 判断是否存在要求回收的物品
/// </summary>
/// <param name="note"></param>
/// <param name="s"></param>
/// <returns>true表示发生变化</returns>
public static bool Task10004(UserNote note, Variant s)
{
if (s.GetIntOrDefault("Cur") == s.GetIntOrDefault("Total"))
return false;
if (!s.ContainsKey("GoodsID"))
return false;
if (s.GetIntOrDefault("Type") != 10004)
return false;
int m = GameConfigAccess.Instance.GetStactCount(s.GetStringOrDefault("GoodsID"));
if (m <= 0) return false;
PlayerEx burden = note.Player.B0;
IList c = burden.Value.GetValue<IList>("C");
int number = 0;
foreach (Variant d in c)
{
if (d.GetStringOrDefault("G") == s.GetStringOrDefault("GoodsID"))
{
number += d.GetIntOrDefault("A");
}
}
if (number >= s.GetIntOrDefault("Total"))
s["Cur"] = s.GetIntOrDefault("Total");
else
s["Cur"] = number;
return true;
}
示例6: WriteDaily
public int WriteDaily(string key, string id)
{
int day = DateTime.Now.DayOfYear;
ClearDaily(day);
Variant log = m_daily.Value.GetVariantOrDefault(key);
//同一天的..
if (log == null)
{
log = new Variant();
m_daily.Value[key] = log;
}
else
{
//删除过期的.
ClearDaily(day);
}
//前面的为次数.后10位为日期
int old = log.GetIntOrDefault(id);
int count = old >> 10;
if (day == (old & 0X1FF)) //365小于1FF.
{
log[id] = (((count + 1) << 10) | day);
}
else
{
log[id] = (1 << 10) | day;
}
m_daily.Save();
this.Call(ClientCommand.UpdateActorR, new PlayerExDetail(m_daily));
return count + 1;
}
示例7: TestListAdd
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);
}
示例8: GetAwardMsg
/// <summary>
/// 取得领奖情况信息
/// </summary>
/// <returns></returns>
public Variant GetAwardMsg(Player player)
{
Variant v = new Variant();
for (int i = 0; i < 3; i++)
{
string str = "";
if (i == 0)
{
str = "MonthAward";
}
else if (i == 1)
{
str = "WeekAward";
}
else
{
str = "DayAward";
}
string tableName = "Player" + GetTableName(str);
if (IsAward(player, tableName, str))
{
v[str] = -1;//表示已经领取
}
else
{
//得到排名
v[str] = GetMyRank(player, tableName);
}
}
return v;
}
示例9: TestBagAdd
public void TestBagAdd()
{
Variant v = new Variant(Variant.EnumType.Bag);
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));
v.Add("key1", new Variant("value2"));
Assert.AreEqual(v.Count, 3);
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(1, v.Count);
v.Remove("key2");
Assert.AreEqual(v.Count, 0);
Assert.IsTrue(v.Empty);
}
示例10: DocData
public DocData()
{
Properties = new NameValueCollection();
Files = new NameValueCollection();
DocComments = new Dictionary<string, DocComment>();
Global = new Variant();
}
示例11: InitFixBuffer
/// <summary>
/// 初始化固定技能
/// </summary>
/// <param name="skills"></param>
/// <returns></returns>
public static Dictionary<string, Tuple<int, GameConfig>> InitFixBuffer(Variant skills)
{
Dictionary<string, Tuple<int, GameConfig>> fixBuffer = null;
if (skills != null)
{
fixBuffer = new Dictionary<string, Tuple<int, GameConfig>>();
foreach (var s in skills)
{
GameConfig gs = GameConfigAccess.Instance.FindOneById(s.Key);
if (gs == null || gs.Name == null) continue;
string name = gs.Name.Replace(PetSkillSuffix, string.Empty);
if (fixBuffer.ContainsKey(name)) continue;
if (gs.SubType == SkillSub.AddAttack || gs.SubType == SkillSub.AddBuffer || gs.SubType == SkillSub.IncreaseBuffer)
{
//发动类型 被动0/ 主动大于1(冷切回合数)
if (gs.UI.GetIntOrDefault("MaxUse") == 0)
{
fixBuffer.Add(name, new Tuple<int, GameConfig>(Convert.ToInt32(s.Value), gs));
}
}
}
}
return fixBuffer;
}
示例12: AddBond
/// <summary>
/// 添加点券
/// </summary>
/// <param name="bond"></param>
/// <param name="eType"></param>
/// <param name="des"></param>
/// <returns></returns>
public bool AddBond(int bond, FinanceType ft, string remark = null)
{
if (bond != 0)
{
BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "Bond", bond);
if (modified == null)
{
return false;
}
long newBond = Convert.ToInt64(modified["Bond"]);
this.Bond = newBond;
Variant v = new Variant(2);
v.Add("Bond", this.Bond);
this.UpdataActorR(v);
//写日志
PayLog log = new PayLog(ServerLogger.zoneid, Actiontype.Bond);
log.modifyfee = bond;
log.totalfee = newBond;
log.toopenid = UserID;
log.touid = PID;
log.reserve_1 = (int)ft;
log.remark = remark;
this.WriteLog(log);
}
return true;
}
示例13: NewPoint
public static Point NewPoint(Variant point)
{
if (point == null) return Point.Empty;
int x = point.GetIntOrDefault("X");
int y = point.GetIntOrDefault("Y");
return new Point(x, y);
}
示例14: BossAward
/// <summary>
/// 领取奖励
/// </summary>
/// <param name="note"></param>
public static void BossAward(UserNote note)
{
string fid = note.Player.Family.Value.GetStringOrDefault("FamilyID");
if (string.IsNullOrEmpty(fid))
{
note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(FamilyReturn.NoAddFamily));
return;
}
string bid = note.GetString(0);
var p = GameConfigAccess.Instance.FindOneById(bid);
if (p == null)
{
return;
}
string gid = note.GetString(1); //FamilyBossAccess.Instance.ViewAward(fid + bid, note.Player.ID);
if (string.IsNullOrEmpty(gid))
{
return;
}
string[] tt = gid.Split('$');
int number = 1;
if (tt.Length != 2 || (!int.TryParse(tt[1], out number)))
{
number = 1;
}
string goodsid = tt[0];
//TODO:检查包袱
Dictionary<string, Variant> goods = new Dictionary<string, Variant>();
Variant tmp = new Variant();
tmp.Add("Number1", number);
goods.Add(goodsid, tmp);
if (BurdenManager.GetBurdenSpace(note.Player.B0.Value.GetValue<IList>("C")) == null)
{
note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(ActivityReturn.SignAward4));
return;
}
//if (BurdenManager.IsFullBurden(note.Player.B0, goods))
//{
// note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(ActivityReturn.SignAward4));
// return;
//}
if (FamilyBossAccess.Instance.GetAward(fid + bid, note.Player.ID, gid))
{
//发放物品
note.Player.AddGoods(goods, GoodsSource.FamilyBoss);
note.Call(FamilyCommand.BossAwardR, true, gid);
}
else
{
//已领取..
note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(FamilyReturn.CannotBossAward));
}
}
示例15: TestBinaryStreams
public void TestBinaryStreams()
{
System.Data.DataTable dt1 = new DataTable();
dt1.Columns.Add(new DataColumn("Float", typeof(float)));
dt1.Columns.Add(new DataColumn("Double", typeof(double)));
dt1.Columns.Add(new DataColumn("String", typeof(string)));
dt1.Columns.Add(new DataColumn("Boolean", typeof(bool)));
dt1.Columns.Add(new DataColumn("Int32", typeof(int)));
dt1.Columns.Add(new DataColumn("UInt32", typeof(uint)));
dt1.Columns.Add(new DataColumn("Int64", typeof(long)));
dt1.Columns.Add(new DataColumn("UInt64", typeof(ulong)));
dt1.Columns.Add(new DataColumn("Time", typeof(TimeSpan)));
dt1.Columns.Add(new DataColumn("DateTime", typeof(DateTime)));
for (int i = 0; i < 10; ++i)
{
DataRow dr = dt1.NewRow();
dr[0] = 1.0;
dr[1] = 2.0;
dr[2] = "value";
dr[3] = true;
dr[4] = 4;
dr[5] = 5;
dr[6] = 6;
dr[7] = 7;
dr[8] = new TimeSpan(1, 2, 3, 4, 5);
dr[9] = new DateTime(2010, 1, 2, 3, 4, 5, 6);
dt1.Rows.Add(dr);
}
Variant v1 = new Variant(dt1);
byte[] bytes = BinaryWriter.ToBytes(v1);
Variant v2 = BinaryReader.FromBytes(bytes);
DataTable dt2 = v2.AsDataTable();
Assert.AreEqual(dt1.Rows.Count, dt2.Rows.Count);
Assert.AreEqual(dt1.Columns.Count, dt2.Columns.Count);
for(int i=0; i<dt1.Columns.Count; ++i)
{
Assert.AreEqual(dt1.Columns[i].ColumnName, dt2.Columns[i].ColumnName);
Assert.AreEqual(dt1.Columns[i].DataType, dt2.Columns[i].DataType);
}
Assert.AreEqual(1.0, (float)dt2.Rows[0][0]);
Assert.AreEqual(2.0, (double)dt2.Rows[0][1]);
Assert.AreEqual("value", (string)dt2.Rows[0][2]);
Assert.AreEqual(true, (bool)dt2.Rows[0][3]);
Assert.AreEqual(4, (int)dt2.Rows[0][4]);
Assert.AreEqual(5, (uint)dt2.Rows[0][5]);
Assert.AreEqual(6, (long)dt2.Rows[0][6]);
Assert.AreEqual(7, (ulong)dt2.Rows[0][7]);
Assert.AreEqual(new TimeSpan(1, 2, 3, 4, 5), (TimeSpan)dt2.Rows[0][8]);
Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), (DateTime)dt2.Rows[0][9]);
}