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


C# Variant.ContainsKey方法代码示例

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


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

示例1: 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

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

示例3: CreateEmailValue

        /// <summary>
        /// 邮件相关信息
        /// </summary>
        /// <param name="playerid">发件人</param>
        /// <param name="name">发件人名称</param>
        /// <param name="receiveid">接收人</param>
        /// <param name="receivename">接收者名称</param>
        /// <param name="d">邮件内容</param>
        /// <returns></returns>
        public static Variant CreateEmailValue(string playerid, string name, string receiveid, string receivename, Variant d)
        {
            Variant v = new Variant();
            v.Add("SendID", playerid);
            v.Add("SendName", name);
            v.Add("ReceiveID", receiveid);
            v.Add("ReceiveName", receivename);
            v.Add("Content", d.GetValue<object>("mailMess"));
            DateTime dt = DateTime.UtcNow;
            v.Add("UpdateDate", dt);
            //邮件有效天数
            int day = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
            v.Add("EndDate", dt.AddDays(day));

            int IsHave = 0;
            if (d.ContainsKey("moneyGoods"))
            {
                Variant money = d.GetVariantOrDefault("moneyGoods");
                if (money.ContainsKey("Coin"))
                {
                    v.Add("Coin", money.GetIntOrDefault("Coin"));
                    IsHave = money.GetIntOrDefault("Coin") > 0 ? 1 : 0;
                }
                else
                {
                    v.Add("Coin", 0);
                }
                if (money.ContainsKey("Score"))
                {
                    v.Add("Score", money.GetIntOrDefault("Score"));
                    IsHave = money.GetIntOrDefault("Score") > 0 ? 1 : 0;
                }
                else
                {
                    v.Add("Score", 0);
                }
            }
            else
            {
                v.Add("Coin", 0);
                v.Add("Score", 0);
            }

            if (d.ContainsKey("goodsList"))
            {
                List<Variant> list = new List<Variant>();
                IList goodsList = d.GetValue<IList>("goodsList");
                foreach (Variant msg in goodsList)
                {
                    GameConfig gc = GameConfigAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                    string goodsType = string.Empty;
                    int sort = 0;
                    if (gc != null)
                    {
                        goodsType = gc.Value.GetStringOrDefault("GoodsType");
                        sort = gc.Value.GetIntOrDefault("Sort");
                    }
                    else
                    {
                        if (gc == null)
                        {
                            Goods g = GoodsAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                            if (g != null)
                            {
                                goodsType = g.Value.GetStringOrDefault("GoodsType");
                                sort = g.Value.GetIntOrDefault("Sort");
                            }
                            else
                            {
                                if (g == null)
                                {
                                    //查询是否是宠物
                                    Pet pet = PetAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                                    if (pet != null)
                                    {
                                        goodsType = "Pet";
                                        sort = pet.Value.GetIntOrDefault("Sort");
                                    }
                                }
                            }
                        }
                    }
                    if (goodsType == string.Empty)
                        continue;

                    Variant gs = new Variant();
                    gs.Add("SoleID", msg.GetStringOrDefault("E"));
                    gs.Add("GoodsID", msg.GetStringOrDefault("G"));
                    gs.Add("Number", msg.GetIntOrDefault("A"));
                    gs.Add("GoodsType", goodsType);
                    gs.Add("Sort", sort);
//.........这里部分代码省略.........
开发者ID:abel,项目名称:sinan,代码行数:101,代码来源:EmailBase.cs

示例4: NeedSpace

        /// <summary>
        /// 得到一种道具,判断需要多少格子
        /// </summary>
        /// <param name="Content">包袱列表</param>
        /// <param name="goodsid">道具id</param>
        /// <param name="number0">非绑定道具数量</param>
        /// <param name="number1">绑定道具数量</param>
        /// <returns>需要空格子数量</returns>
        public static int NeedSpace(IList Content, string goodsid, Variant v, int sc)
        {
            int space = 0;
            for (int isbinding = 0; isbinding <= 1; isbinding++)
            {
                //0为非绑定,1为绑定
                int number = v.GetIntOrDefault("Number" + isbinding);
                if (number <= 0)
                    continue;

                int cur = 0;//当前该物品所占的格子数
                foreach (Variant k in Content)
                {
                    if (k.GetStringOrDefault("G") != goodsid)
                        continue;
                    if (k.GetIntOrDefault("H") != isbinding)
                        continue;
                    if (v.ContainsKey("EndTime"))
                    {
                        Variant t = k.GetVariantOrDefault("T");
                        if (t == null)
                            continue;
                        if (t.GetStringOrDefault("EndTime") != v.GetStringOrDefault("EndTime"))
                            continue;
                    }
                    number += k.GetIntOrDefault("A");
                    cur++;
                }
                int m = 0;//余数
                int n = Math.DivRem(number, sc, out m);
                n = m > 0 ? n + 1 : n;
                space += (n > cur) ? (n - cur) : 0;
            }
            return space;
        }
开发者ID:abel,项目名称:sinan,代码行数:43,代码来源:BurdenManager.cs

示例5: GetAffix

        /// <summary>
        /// 得到装被附加属性
        /// </summary>
        /// <param name="affix">附加属性</param>
        /// <param name="v">产生的附加属性</param>
        public static void GetAffix(Variant affix, Variant v)
        {
            if (affix == null)
                return;
            int min = affix.GetIntOrDefault("Min");
            int max = affix.GetIntOrDefault("Max");
            if (min > max)
                return;

            Variant lift = affix.GetVariantOrDefault("Life");

            if (lift == null)
                return;

            foreach (var item in lift)
            {
                if (v.ContainsKey(item.Key))
                    continue;

                Variant tmp = (Variant)item.Value;
                if (tmp == null)
                    continue;

                int m = tmp.GetIntOrDefault("Min");
                int n = tmp.GetIntOrDefault("Max");
                double range = tmp.GetDoubleOrDefault("Range");

                if (NumberRandom.RandomHit(range))
                {
                    //表示成功
                    v.Add(item.Key, NumberRandom.Next(m, n + 1));
                    if (v.Count >= max)
                        break;
                }
            }

            if (lift.Count > min && v.Count < min)
            {
                //回调
                GetAffix(affix, v);
            }
        }
开发者ID:abel,项目名称:sinan,代码行数:47,代码来源:BurdenManager.cs

示例6: WriteInstruction

 void WriteInstruction(Variant instruction)
 {
     if (instruction.Is(VariantBase.EnumType.Mapping) && instruction.ContainsKey(XmlConst.Target) && instruction.ContainsKey(XmlConst.Data))
     {
         m_writer.WriteProcessingInstruction(instruction[XmlConst.Target].As<string>(), instruction[XmlConst.Data].As<string>());
     }
     else
     {
         throw new VariantException(string.Format("Expecting dictionary containing '{0}' and '{1}' for processing instruction", XmlConst.Target, XmlConst.Data));
     }
 }
开发者ID:proteanic,项目名称:protean,代码行数:11,代码来源:XmlWriter.cs

示例7: WriteElement

        void WriteElement(Variant element)
        {
            WriteStartTag(m_stack.Peek().m_name);

            switch(element.Type)
            {
            case VariantBase.EnumType.None:
            {
                WriteAttributes(m_stack.Peek().m_attributes);
                break;
            }
            case VariantBase.EnumType.Any:
            case VariantBase.EnumType.String:
            case VariantBase.EnumType.Float:
            case VariantBase.EnumType.Double:
            case VariantBase.EnumType.Int32:
            case VariantBase.EnumType.UInt32:
            case VariantBase.EnumType.Int64:
            case VariantBase.EnumType.UInt64:
            case VariantBase.EnumType.Boolean:
            case VariantBase.EnumType.Date:
            case VariantBase.EnumType.Time:
            case VariantBase.EnumType.DateTime:
            {
                WriteAttributes(m_stack.Peek().m_attributes);
                WriteText(element);
                break;
            }
            case VariantBase.EnumType.Dictionary:
            case VariantBase.EnumType.Bag:
            {
                WriteAttributes(m_stack.Peek().m_attributes);
                if ((m_mode & XmlMode.Preserve)!=0)
                {
                    if (element.ContainsKey(XmlConst.Attributes))
                    {
                        WriteAttributes(element[XmlConst.Attributes]);
                    }

                    foreach(VariantItem item in element)
                    {
                        if (item.Key==XmlConst.Attributes)
                        {
                             continue;
                        }
                        else if (item.Key==XmlConst.Text)
                        {
                            WriteText(item.Value);
                        }
                        else if (item.Key==XmlConst.Instruction)
                        {
                            WriteInstruction(item.Value);
                        }
                        else if (item.Key==XmlConst.Comment)
                        {
                            WriteComment(item.Value);
                        }
                        else
                        {
                            Push(item.Key);
                            WriteElement(item.Value);
                            Pop();
                        }
                    }
                }
                else
                {
                    foreach (VariantItem item in element)
                    {
                        Push(item.Key);
                        WriteVariant(item.Value);
                        Pop();
                    }
                }

                break;
            }
            case VariantBase.EnumType.List:
            {
                WriteAttributes(m_stack.Peek().m_attributes);
                foreach(VariantItem item in element)
                {
                    Push();
                    WriteVariant(item.Value);
                    Pop();
                }

                break;
            }
            case VariantBase.EnumType.Tuple:
            {
                m_stack.Peek().m_attributes.Add("size", new Variant(element.Count));

                WriteAttributes(m_stack.Peek().m_attributes);

                foreach(VariantItem item in element)
                {
                    Push();
                    WriteVariant(item.Value);
                    Pop();
//.........这里部分代码省略.........
开发者ID:proteanic,项目名称:protean,代码行数:101,代码来源:XmlWriter.cs

示例8: FreezeDate

        /// <summary>
        /// 是否在冻结期
        /// </summary>
        /// <param name="v"></param>
        /// <returns>true表示在冻结期</returns>
        private static bool FreezeDate(Variant v)
        {
            if (v.ContainsKey("FreezeDate") && v["FreezeDate"] != null)
            {
                DateTime freezeDate = v.GetDateTimeOrDefault("FreezeDate");

                if (freezeDate > DateTime.UtcNow)
                {
                    return true;
                }
            }
            return false;
        }
开发者ID:abel,项目名称:sinan,代码行数:18,代码来源:MasterBusiness.cs

示例9: GoodsEquipDetails

        /// <summary>
        /// 得到商品明细
        /// </summary>
        /// <param name="user"></param>
        /// <param name="GoodsCode">商品ID</param>
        private void GoodsEquipDetails(UserNote note)
        {
            string goodsid = note.GetString(0);

            GameConfig gc = GameConfigAccess.Instance.FindOneById(goodsid);
            Variant v = new Variant();
            if (gc != null)
            {
                foreach (var item in gc.Value)
                {
                    v[item.Key] = item.Value;
                }
                v.Add("ID", gc.ID);
                v.Add("UI", gc.UI);
                v.Add("Name", gc.Name);
                v.Add("Value", gc.Value);
                note.Call(GoodsCommand.GetGoodsDetailR, true, v);
                return;
            }

            Goods g = GoodsAccess.Instance.FindOneById(goodsid);
            if (g != null)
            {
                foreach (var item in g.Value)
                {
                    v.Add(item.Key, item.Value);
                }

                if (!v.ContainsKey("ID"))
                {
                    v.Add("ID", g.ID);
                }
                if (!v.ContainsKey("GoodsID"))
                {
                    v.Add("GoodsID", g.GoodsID);
                }
                if (!v.ContainsKey("Name"))
                {
                    v.Add("Name", g.Name);
                }
                note.Call(GoodsCommand.GetGoodsDetailR, true, v);
                return;
            }

            Mounts ms = MountsAccess.Instance.FindOneById(goodsid);
            if (ms != null)
            {
                v.Add("ID", ms.ID);
                v.Add("Level", ms.Level);
                v.Add("Name", ms.Name);
                v.Add("Experience", ms.Experience);
                v.Add("Status", ms.Status);
                v.Add("Rank", ms.Rank);
                v.Add("PlayerID", ms.PlayerID);
                v.Add("MountsID", ms.MountsID);
                v.Add("MainType", "Mounts");
                //v.Add("Life", MountsAccess.Instance.MountsLife(ms.Level));
                Variant life = MountsAccess.Instance.MountsLife(ms);
                foreach (var info in life)
                {
                    v.Add(info.Key, info.Value);
                }

                if (ms.Value != null)
                {
                    foreach (var item in ms.Value)
                    {
                        v.Add(item.Key, item.Value);
                    }
                }
                note.Call(GoodsCommand.GetGoodsDetailR, true, v);
                return;
            }
            note.Call(GoodsCommand.GetGoodsDetailR, false, null);
        }
开发者ID:abel,项目名称:sinan,代码行数:80,代码来源:GoodsMediator.cs

示例10: CheckSex

 /// <summary>
 /// 性别限制
 /// </summary>
 /// <param name="player"></param>
 /// <param name="limit"></param>
 /// <returns></returns>
 private static int CheckSex(Player player, Variant limit)
 {
     if (limit.ContainsKey("Sex"))
     {
         int sex = Convert.ToInt32(limit["Sex"]);
         if (sex != 2 && sex != player.Sex)
         {
             return GoodsReturn.NoSex;
         }
     }
     return 0;
 }
开发者ID:abel,项目名称:sinan,代码行数:18,代码来源:GoodsUse.cs

示例11: CheckRole

 /// <summary>
 /// 角色限制
 /// </summary>
 /// <param name="player"></param>
 /// <param name="limit"></param>
 /// <returns></returns>
 private static int CheckRole(Player player, Variant limit)
 {
     if (limit.ContainsKey("RoleID"))
     {
         string RoleID = limit.GetStringOrDefault("RoleID");
         if (RoleID != "0" && RoleID != player.RoleID)
         {
             return GoodsReturn.NoRoleID;
         }
     }
     return 0;
 }
开发者ID:abel,项目名称:sinan,代码行数:18,代码来源:GoodsUse.cs


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