当前位置: 首页>>代码示例>>C#>>正文


C# Variant.Add方法代码示例

本文整理汇总了C#中System.Variant.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.Add方法的具体用法?C# Variant.Add怎么用?C# Variant.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Variant的用法示例。


在下文中一共展示了Variant.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:proteanic,项目名称:protean,代码行数:28,代码来源:TestSequence.cs

示例2: GMAuctionList

        /// <summary>
        /// GM取得拍卖行数据
        /// </summary>
        /// <param name="note"></param>
        public static object GMAuctionList(Notification note)
        {
            string[] strs = GMBusiness.GetCommand(note);
            if (strs.Length < 3)
                return null;
            PlayerBusiness player = PlayersProxy.FindPlayerByName(strs[0].Trim());
            if (player == null)
                return null;
            int pageIndex = 0;

            if (!int.TryParse(strs[1].Trim(), out pageIndex))
                return null;
            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);
            }
            return new object[] { list, total, curIndex };
        }
开发者ID:abel,项目名称:sinan,代码行数:36,代码来源:ManageAuction.cs

示例3: 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);
        }
开发者ID:rokstrnisa,项目名称:protean,代码行数:32,代码来源:TestMapping.cs

示例4: AddFriends

        /// <summary>
        /// 添加好友
        /// </summary>
        /// <param name="note"></param>
        public static void AddFriends(UserNote note)
        {
            string name = note.GetString(0);
            if (note.Player.Name == name)
            {
                return;
            }
            PlayerEx social = note.Player.Social;
            if (social == null)
            {
                note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            PlayerBusiness player = PlayersProxy.FindPlayerByName(name);
            if (player == null)
            {
                note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            if (social.Value != null)
            {
                if (SocialBusiness.IsLet(social, player.ID, new List<string> { "Friends" }))
                {
                    note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.Friends));
                    return;
                }

                if (SocialBusiness.IsLet(social, player.ID, new List<string> { "Enemy" }))
                {
                    note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.Master));
                    return;
                }
            }

            Variant v = new Variant();
            v.Add("PlayerID", player.ID);
            v.Add("Created", DateTime.UtcNow);
            IList list = social.Value.GetValue<IList>("Friends");
            int num = 0;
            if (list == null)
            {
                social.Value["Friends"] = new List<Variant>() { v };
                num = 1;
            }
            else
            {
                list.Add(v);
                num = list.Count;
            }
            social.Save();

            note.Call(SocialCommand.AddFriendsR, true, new PlayerSimple(player, 3));

            //添加好友
            note.Player.FinishNote(FinishCommand.Friends, num);
        }
开发者ID:abel,项目名称:sinan,代码行数:62,代码来源:FriendsBusiness.cs

示例5: TestBag

        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));
        }
开发者ID:proteanic,项目名称:protean,代码行数:12,代码来源:TestBinaryStreams.cs

示例6: TestList

        public void TestList()
        {
            Variant v1 = new Variant(Variant.EnumType.List);
            v1.Add(new Variant("value1"));
            v1.Add(new Variant(1.0));

            string xml = XmlWriter.ToString(v1);
            Variant v2 = XmlReader.FromString(xml);

            Assert.AreEqual(v2.Type, Variant.EnumType.List);
            Assert.IsTrue(v1.Equals(v2));
        }
开发者ID:proteanic,项目名称:protean,代码行数:12,代码来源:TestXmlStreams.cs

示例7: IntoPart

        /// <summary>
        /// 进入扣除
        /// </summary>
        /// <param name="player"></param>
        public override bool IntoPart(PlayerBusiness player)
        {
            if (BurdenManager.GoodsCount(player.B0, m_elements[0]) > 0)
            {
                //请先处理包袱中的【守护凭证】后再进入
                player.Call(ClientCommand.IntoSceneR, false, null,TipManager.GetMessage(ClientReturn.ProBusiness1));
                return false;
            }

            Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
            Variant v = new Variant();
            v.Add("Number1", 1);
            v.Add("EndTime", this.EndTime.AddHours(1));//活动结束后一个小时道具过期

            dic.Add(m_elements[0], v);

            if (BurdenManager.IsFullBurden(player.B0, dic))
            {
                //包袱满,请整理你的包袱再进行该操作
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.ProBusiness2));
                return false;
            }

            bool pass = (m_part.Coin == 0 && m_part.Score == 0);
            if ((!pass) && m_part.Score > 0)
            {
                pass = player.AddScore(-m_part.Score, FinanceType.Part);
            }
            if ((!pass) && m_part.Coin > 0)
            {
                pass = player.AddCoin(-m_part.Coin, FinanceType.Part);
            }
            if (!pass)
            {
                player.Call(ClientCommand.IntoSceneR, false, null, m_part.CoinMsg);
                return false;
            }

            if (m_part.MaxInto > 0)
            {
                m_playerInto.SetOrInc(player.PID, 1);
            }

            //进入场景成功,发送道具
            player.AddGoods(dic, GoodsSource.Pro);
            player.MoreFight = 0;
            player.NoFight = 0;
            player.Call(ActivityCommand.GetDefendCardR, MainScene.Players.Count);
            //进入守护战争,记录活跃度
            player.AddAcivity(ActivityType.Pro, 1);
            return true;
        }
开发者ID:abel,项目名称:sinan,代码行数:56,代码来源:ProBusiness.cs

示例8: AddEnemy

        /// <summary>
        /// 添加仇人
        /// </summary>
        /// <param name="note"></param>
        public static void AddEnemy(UserNote note)
        {
            string name = note.GetString(0);

            PlayerEx Social = note.Player.Social;
            if (Social == null)
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }
            PlayerBusiness player = PlayersProxy.FindPlayerByName(name);
            if (player == null)
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Friends" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Friends));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Apprentice" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Master" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Master));
                return;
            }

            IList Enemy = Social.Value.GetValue<IList>("Enemy");
            Variant v = new Variant();
            v.Add("PlayerID", player.ID);
            v.Add("Created", DateTime.UtcNow);
            if (Enemy == null)
            {
                Social.Value["Enemy"] = new List<Variant> { v };
            }
            else
            {
                Enemy.Add(v);
            }
            Social.Save();
            note.Call(SocialCommand.AddEnemyR, true, new PlayerSimple(player, 3));
        }
开发者ID:abel,项目名称:sinan,代码行数:56,代码来源:EnemyBusiness.cs

示例9: TestTSAdd

        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);
        }
开发者ID:proteanic,项目名称:protean,代码行数:13,代码来源:TestTimeSeries.cs

示例10: TestListComparison

        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));
        }
开发者ID:proteanic,项目名称:protean,代码行数:14,代码来源:TestSequence.cs

示例11: DealApply

        /// <summary>
        /// 申请交易
        /// </summary>
        /// <param name="note"></param>
        public static void DealApply(UserNote note)
        {
            string playerid = note.GetString(0);

            if (note.Player.Value.ContainsKey("Deal"))
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.DealOther));
                return;
            }
            PlayerBusiness OnlineBusiness = PlayersProxy.FindPlayerByID(playerid);
            if (OnlineBusiness == null || (!OnlineBusiness.Online))
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.NoLine));
                return;
            }

            if (OnlineBusiness.AState == ActionState.Fight)
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.Fighting));
                return;
            }

            if (OnlineBusiness.Value.ContainsKey("Deal"))
            {
                Variant dy = OnlineBusiness.Value.GetVariantOrDefault("Deal");
                if (dy.GetIntOrDefault("Status") >= 0)
                {
                    note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.DealOther));
                    return;
                }
            }

            Variant d0 = new Variant();
            d0.Add("Status", 0);
            d0.Add("PlayerID", playerid);//被邀请者
            d0.Add("Goods", null);
            if (!note.Player.Value.ContainsKey("Deal"))
                note.Player.Value.Add("Deal", d0);

            Variant d1 = new Variant();
            d1.Add("Status", 0);
            d1.Add("PlayerID", note.PlayerID);//邀请者
            d1.Add("Goods", null);
            if (!OnlineBusiness.Value.ContainsKey("Deal"))
                OnlineBusiness.Value.Add("Deal", d1);

            OnlineBusiness.Call(DealCommand.DealApplyR, true, note.PlayerID);
            note.Call(DealCommand.DealApplyR, true, note.PlayerID);
        }
开发者ID:abel,项目名称:sinan,代码行数:53,代码来源:DealBusiness.cs

示例12: PersonInfo

 /// <summary>
 /// 加入家族
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 public static Variant PersonInfo(string playerid, int roleid)
 {
     Variant d = new Variant();
     d.Add("PlayerID", playerid);//用户ID
     d.Add("AddDate", DateTime.UtcNow);//添加时间
     d.Add("Devote", 0);//玩家贡献
     d.Add("RoleID", roleid);//职业0族长,1副族长,2族员
     d.Add("Fire", 0);//开除权限,0没有,1有
     //d.PlayerID = playerid;//用户ID
     //d.AddDate = DateTime.UtcNow;//添加时间
     //d.Devote = 0;//玩家贡献
     //d.RoleID = roleid;//职业0族长,1副族长,2族员
     //d.Fire = 0;//开除权限,0没有,1有
     return d;
 }
开发者ID:abel,项目名称:sinan,代码行数:20,代码来源:FamilyBase.cs

示例13: 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;
        }
开发者ID:abel,项目名称:sinan,代码行数:34,代码来源:PlayerBusiness_Property.cs

示例14: Exec

        protected override void Exec()
        {
            if (PlayerAccess.Instance.FightValueClear())
            {
                //在线用户列表
                foreach (PlayerBusiness user in PlayersProxy.Players)
                {
                    user.FightValue = 0;

                    Variant v = new Variant();
                    v.Add("ID", user.ID);
                    v.Add("FightValue", user.FightValue);
                    user.Call(ClientCommand.UpdateActorR, v);
                }
            }
        }
开发者ID:abel,项目名称:sinan,代码行数:16,代码来源:FightValueTimer.cs

示例15: FamilyValue

 /// <summary>
 /// 创建家族的动态值
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 public static Variant FamilyValue(UserNote note)
 {
     Variant d = new Variant();
     d.Add("Level", 1);
     d.Add("Experience", 0);
     d.Add("Notice", string.Empty);
     d.Add("Persons", new List<Variant>() { PersonInfo(note.PlayerID, 0) });
     d.Add("Skill", null);
     //d.Add("Level", 1);
     //d.Level = 1;
     //d.Experience = 0;
     //d.Notice = string.Empty;
     //d.Persons = new List<Variant>() { PersonInfo(note.PlayerID,0) };
     //d.Skill = null;//技能
     return d;
 }
开发者ID:abel,项目名称:sinan,代码行数:21,代码来源:FamilyBase.cs


注:本文中的System.Variant.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。