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


C# Dictionary.ContainsValue方法代码示例

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


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

示例1: CreateCombatOrder

        /// <summary>Creates the combat order.</summary>
        public void CreateCombatOrder()
        {
            Die combatDie = DiceService.Instance.GetDie(6);
            var bin = new Dictionary<string, int>();

            foreach (Thing combatant in this.CombatSession.Combatants)
            {
                // Find out who goes first, then add them to the queue.
                // Rinse and repeat, until all have been placed in the
                // correct order.

                // Do initiative roll.
                int combatantInitiative = DoInititiveRoll(combatDie, combatant);

                if (bin.ContainsValue(combatantInitiative))
                {
                    combatantInitiative = DoInititiveRoll(combatDie, combatant);
                }

                bin.Add(combatant.Name, combatantInitiative);
            }

            // Sort the bin dictionary
            var sortedBin = (from entry in bin orderby entry.Value ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);

            foreach (var ent in sortedBin)
            {
                ////Thing combatant = this.CombatSession.Combatants.Values
            }
        }
开发者ID:Hobbitron,项目名称:WheelMUD,代码行数:31,代码来源:WRMCombat.cs

示例2: CreateTable

 public TableResponse CreateTable(string databaseName, string tableName, Dictionary<string,bool> columnData, List<string> columnType)
 {
   if (databaseName == "database1" && tableName == "table1" && columnData.ContainsValue(false) && columnData.ContainsKey("key1") && columnType[0] == "VARCHAR(255)")
   {
     return new TableResponse(true, "success", "12");
   }
   else
     return new TableResponse(false, "failure", "13"); 
 }
开发者ID:Logeshkumar,项目名称:Projects,代码行数:9,代码来源:MockTableServer.cs

示例3: ZE_ValueExists

 public void ZE_ValueExists()
 {
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     dictionary["one"] = "uno";
     Assert.AreEqual(FILL_ME_IN, dictionary.ContainsValue("uno"));
     Assert.AreEqual(FILL_ME_IN, dictionary.ContainsValue("dos"));
 }
开发者ID:halimakoundi,项目名称:CSharpKoan,代码行数:7,代码来源:J_AboutContainers.cs

示例4: CopyData


//.........这里部分代码省略.........
                                    if (destiIndex < 1 || destiIndex > item)
                                    {
                                        destiIndex = item;
                                    }
                                }
                            }
                            foreach (int item in exSheets.Keys)
                            {
                                if (DataUtility.DataUtility.LargerThan(certId, exSheets[item]) && destiIndex < item)
                                {
                                    //在所有比参考编号小的页面里,挑一个最靠后的序号给destiIndex
                                    destiIndex = item;
                                }
                            }
                            //在destiIndex右侧复制模板页
                            ws1.Copy(Type.Missing, destiEx.ExcelWorkbook.Sheets[destiIndex]);
                            //把新复制的模板页赋给ws1
                            ws1 = (MSExcel.Worksheet)destiEx.ExcelWorkbook.Sheets[destiIndex + 1];
                        }
                        else
                        {
                            //没有有效数据页时,在模板页左侧复制模板页
                            ws1.Copy(destiEx.ExcelWorkbook.Sheets[templateIndex], Type.Missing);
                            //把原来模板页,现在的模板复制页的位置给了ws1
                            ws1 = (MSExcel.Worksheet)destiEx.ExcelWorkbook.Sheets[templateIndex];
                        }
                        if (!ws1.Name.Contains(@"标准模板"))
                        {
                            AddException(@"标准模板复制出错", true);
                            success = false;
                            newSheetIndex = -1;
                            return;
                        }
                        if (!exSheets.ContainsValue(certId))
                        {
                            ws1.Name = certId;
                        }
                    }

                    newSheetIndex = ws1.Index;

                    //确定原始数据的数据行
                    for (int i = 15; i < 22; i++)
                    {
                        text = sourceEx.GetText(sourceEx.ExcelWorkbook, sourceIndex, i, 3, out success1).Trim();
                        if (text == "1")
                        {
                            text = sourceEx.GetText(sourceEx.ExcelWorkbook, sourceIndex, i + 1, 3, out success1).Trim();
                            if (text == "2")
                            {
                                text = sourceEx.GetText(sourceEx.ExcelWorkbook, sourceIndex, i + 2, 3, out success1).Trim();
                                if (text == "3")
                                {
                                    startSourceRowIndex = i;
                                    break;
                                }
                            }
                        }
                    }

                    if (startSourceRowIndex == -1)
                    {
                        AddException(@"找不到原始数据所在的行", true);
                        success = false;
                        newSheetIndex = -1;
                        return;
开发者ID:buaaqlyj,项目名称:refactored-umbrella,代码行数:67,代码来源:Job.cs

示例5: generatePoint

 /// <summary>
 /// Generates a MyPoint object that does not belong to the dictionary passed.
 /// </summary>
 /// <param name="dictionary"></param>
 /// <returns></returns>
 private MyPoint generatePoint(ref Dictionary<int, MyPoint> dictionary )
 {
     MyPoint p = new MyPoint(-1, -1);
     bool operation = true;
     do
     {
         p.X = random.Next(KEY_WIDTH);
         p.Y = random.Next(KEY_HEIGHT);
         operation = dictionary.ContainsValue(p);
     } while (operation);
     return p;
 }
开发者ID:osiastedian,项目名称:DIPAlgorithm,代码行数:17,代码来源:OSIASEncryption.cs

示例6: GetUniqueValue

 private static string GetUniqueValue(Dictionary<string, string> dictionary, string valueToBeInserted)
 {
     int i = 0;
     string prefix = "";
     while (dictionary.ContainsValue(valueToBeInserted + prefix))
     {
         prefix = string.Format("_{0}", ++i);
     }
     return string.Format("{0}{1}", valueToBeInserted, prefix);
 }
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:10,代码来源:DataSourceCreator.cs

示例7: PackBans

 public Dictionary<string, object> PackBans(Dictionary<string, object> result)
 {
     Dictionary<string, object> Bans = new Dictionary<string, object>();
     int i = 0;
     foreach (Scene scene in m_scenes)
     {
         foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
         {
             if (!Bans.ContainsValue(ban.BannedUserID))
             {
                 Bans.Add(ConvertDecString(i), ban.BannedUserID);
                 i++;
             }
         }
     }
     result["Bans"] = Bans;
     return result;
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:18,代码来源:CrossRegionBanSystem.cs

示例8: GetImagesinUrl1

 private void GetImagesinUrl1(HttpContext context)
 {
     string url = context.Request.QueryString["url"];
     Regex img = new Regex("<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase);
     Regex src = new Regex(@"src=(?:(['""])(?<src>(?:(?!\1).)*)\1|(?<src>[^\s>]+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
     WebClient source = new WebClient();
     string value = source.DownloadString(new Uri(url));
     if (!string.IsNullOrEmpty(value))
     {
         MatchCollection matches = img.Matches(value);
         if (matches.Count > 0)
         {
             string rpath = Common.RelTemp + Common.UserID;
             string path = Common.Temp + Common.UserID;
             if (!Directory.Exists(path)) Directory.CreateDirectory(path);
             else
             {
                 string[] files = Directory.GetFiles(path);
                 foreach (string file in files)
                 {
                     File.Delete(file);
                 }
             }
             int i = 0;
             Dictionary<int, bool> _dict = new Dictionary<int, bool>();
             List<string> paths = new List<string>();
             AsyncCompletedEventHandler callback = (sender, e) =>
                                                       {
                                                           dynamic dyn = (dynamic)e.UserState;
                                                           _dict[dyn.i] = true;
                                                           string rfn = rpath + dyn.i + ".jpg";
                                                           paths.Add(rfn);
                                                       };
             foreach (Match match in matches)
             {
                 string imgUrl = match.Groups[1].Value;
                 WebClient client = new WebClient();
                 client.DownloadFileCompleted += callback;
                 string fn = path + "\\" + i + ".jpg";
                 dynamic dyn = new ExpandoObject();
                 dyn.fn = fn;
                 dyn.i = i;
                 client.DownloadFileAsync(new Uri(imgUrl), fn, dyn);
                 _dict.Add(i, false);
                 i++;
             }
             while (_dict.ContainsValue(false)) Thread.Sleep(500);
             context.WriteJsonP(JsonConvert.SerializeObject(paths, Formatting.Indented, Common.JsonSerializerSettings));
         }
     }
 }
开发者ID:hurricanechaser,项目名称:pindex,代码行数:51,代码来源:GET.ashx.cs

示例9: GetUnique

        private static string GetUnique(Dictionary<string , string> dic , string value)
        {
            int i = 0;
            string prefixion = "";
            while (dic.ContainsValue(value + prefixion))
            {
                prefixion = string.Format(System.Globalization.CultureInfo.InvariantCulture, "_{0}", ++i);
            }

            string result = string.Format("{0}{1}" , value , prefixion);
            return result;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:12,代码来源:DataSourceCreator.cs

示例10: GetDuplicateSubscribers

        // ------------------------------------------------------------
        // Name: UpdateConvertedProspects
        // Abstract: Retrieve subscribers from a list
        // ------------------------------------------------------------
        public static Dictionary<string, string> GetDuplicateSubscribers()
        {
            Dictionary<string, string> dctDuplicateSubscribers = new Dictionary<string, string>();
            Dictionary<string, string> dctSubscribers = new Dictionary<string, string>();
            Dictionary<string, string> dctAllSubscribers = new Dictionary<string, string>();
            try
            {
                string strCustomerNumber = "";
                string strSubscriberKey = "";
                string strEmail = "";

                // Get subscriber dates
                ET_Subscriber getSub = new ET_Subscriber();
                getSub.AuthStub = m_etcTDClient;
                getSub.Props = new string[] { "SubscriberKey", "EmailAddress" };
                GetReturn getResponse = getSub.Get();
                Console.WriteLine("Get Status: " + getResponse.Status.ToString());
                Console.WriteLine("Message: " + getResponse.Message.ToString());
                Console.WriteLine("Code: " + getResponse.Code.ToString());
                Console.WriteLine("Results Length: " + getResponse.Results.Length);
                while (getResponse.MoreResults == true)
                {

                    foreach (ET_Subscriber sub in getResponse.Results)
                    {
                        Console.WriteLine("SubscriberKey: " + sub.SubscriberKey);

                        // Add to our list
                        dctAllSubscribers.Add(sub.SubscriberKey, sub.EmailAddress);
                    }

                    getResponse = getSub.GetMoreResults();
                }

                foreach (KeyValuePair<string, string> entry in dctAllSubscribers)
                {
                    strSubscriberKey = entry.Key;
                    strEmail = entry.Value;
                    // Add to duplicates if email already exists
                    if (dctSubscribers.ContainsValue(strEmail) == true)
                    {
                        // Get customer number from duplicate if duplicate hasn't been logged
                        if (dctDuplicateSubscribers.ContainsValue(strEmail) == false)
                        {
                            strCustomerNumber = dctSubscribers.FirstOrDefault(x => x.Value == strEmail).Key;

                            // Add (both) duplicate entries
                            dctDuplicateSubscribers.Add(strSubscriberKey, strEmail);
                            dctDuplicateSubscribers.Add(strCustomerNumber, strEmail);
                        }
                        else
                        {
                            dctDuplicateSubscribers.Add(strSubscriberKey, strEmail);
                        }
                    }
                    else
                    {
                        // Add to our list
                        dctSubscribers.Add(strSubscriberKey, strEmail);
                    }
                }

            }
            catch (Exception excError)
            {
                // Display Error
                Console.WriteLine("Error: " + excError.ToString());
            }

            return dctDuplicateSubscribers;
        }
开发者ID:moshimc,项目名称:CodeSamples,代码行数:75,代码来源:CExactTargetUtilities.cs

示例11: ValueExists

 public void ValueExists()
 {
     // This should have been at the top
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     dictionary["one"] = "uno";
     Assert.Equal(FILL_ME_IN, dictionary.ContainsValue("uno"));
     Assert.Equal(FILL_ME_IN, dictionary.ContainsValue("dos"));
 }
开发者ID:elizabrock,项目名称:DotNetKoans,代码行数:8,代码来源:AboutGenericContainers.cs

示例12: DistinctModel

        //去除型號相同的(不管顏色)
        private void DistinctModel(string inPath, string saveRepeatFileName, string saveFileName)
        {
            string line;
            StreamReader file = new StreamReader(inPath);
            List<string> models = new List<string>();
            while ((line = file.ReadLine()) != null)
            {
                if (line.Length != 0)
                    models.Add(line.ToLower());
            }
            file.Close();

            Dictionary<string, string> dic = new Dictionary<string, string>();
            foreach (string m in models)
            {
                if (!dic.ContainsValue(m.Substring(m.IndexOf(m.Split('\t')[1]))))//比較廠牌型號
                {
                    dic.Add(m.Split('\t')[0], m.Substring(m.IndexOf(m.Split('\t')[1])));//ID,值
                    saveData.Save(saveFileName, m);
                }
                else
                    foreach (var d in dic)//印出對應表
                    {
                        if (d.Value == m.Substring(m.IndexOf(m.Split('\t')[1])))
                            saveData.Save(saveRepeatFileName, d.Key + "\t" + m.Split('\t')[0]);
                    }
            }
            //return (String[])DistinctArray.ToArray(typeof(string));
        }
开发者ID:huaditsai,项目名称:-WinForm--Comparison,代码行数:30,代码来源:Form1.cs

示例13: Split

        public static string[] Split(this string line, ICollection<char> separators, Dictionary<char, char> uniters, out int nonClosedParenthesis)
        {
            List<string> parameters = new List<string>();
            int startIndex = 0;
            Stack<char> uniterStack = new Stack<char>();
            for (int j = 0; j < line.Length; j++)
            {
                char currChar = line[j];
                if (separators.Contains(currChar))
                {
                    if (uniterStack.Count == 0)
                    {
                        if (j - startIndex > 0)
                        {
                            parameters.Add(line.Substring(startIndex, j - startIndex));
                        }
                        startIndex = j + 1;
                    }
                }
                else if (uniters.ContainsKey(currChar)
                    && !(uniters[currChar] == currChar
                        && uniterStack.Count > 0 && uniterStack.Peek() == currChar))
                {
                    uniterStack.Push(currChar);
                }
                else if (uniters.ContainsValue(currChar))
                {
                    if (uniterStack.Count > 0 && uniters[uniterStack.Peek()] == currChar)
                    {
                        uniterStack.Pop();
                    }
                    else
                    {
                        throw new ArgumentException();
                    }
                }
            }
            if (startIndex < line.Length)
            {
                parameters.Add(line.Substring(startIndex, line.Length - startIndex));
            }

            nonClosedParenthesis = uniterStack.Count;
            parameters.RemoveAll(string.IsNullOrEmpty);
            return parameters.ToArray();
        }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:46,代码来源:StringExtensions.cs

示例14: _GetLinks

        private static void _GetLinks(string sContent, string sUrl, ref Dictionary<string, string> lisA)
        {
            const string sFilter =
@"首页|下载|中文|English|反馈|讨论区|投诉|建议|联系|关于|about|诚邀|工作|简介|新闻|掠影|风采
|登录|注销|注册|使用|体验|立即|收藏夹|收藏|添加|加入
|更多|more|专题|精选|热卖|热销|推荐|精彩
|加盟|联盟|友情|链接|相关
|订阅|阅读器|RSS
|免责|条款|声明|我的|我们|组织|概况|有限|免费|公司|法律|导航|广告|地图|隐私
|〖|〗|【|】|(|)|[|]|『|』|\.";

            Regex re = new Regex(@"<a\s+[^>]*href\s*=\s*[^>]+>[\s\S]*?</a>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline);
            Regex re2 = new Regex(@"""|'", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline);
            MatchCollection mcs = re.Matches(sContent);
            //foreach (Match mc in mcs)
            for (int i = mcs.Count - 1; i >= 0; i--)
            {
                Match mc = mcs[i];
                string strHref = GetLink(mc.Value).Trim();

                strHref = strHref.Replace("\\\"", "");//针对JS输出链接
                strHref = strHref.Replace("\\\'", "");

                string strTemp = RemoveByReg(strHref, @"^http.*/$");//屏蔽以“http”开头“/”结尾的链接地址
                if (strTemp.Length < 2)
                {
                    continue;
                }

                //过滤广告或无意义的链接
                string strText = ClearTag(GetTextByLink(mc.Value)).Trim();
                strTemp = RemoveByReg(strText, sFilter);
                if (Encoding.Default.GetBytes(strTemp).Length < 9)
                {
                    continue;
                }
                if (re2.IsMatch(strText))
                {
                    continue;
                }

                //换上绝对地址
                strHref = GetUrlByRelative(sUrl, strHref);
                if (strHref.Length <= 18)//例如,http://www.163.com = 18
                {
                    continue;
                }

                //计算#字符出现的位置,移除它后面的内容
                //如果是域名地址,就跳过
                int charIndex = strHref.IndexOf('#');
                if (charIndex > -1)
                {
                    strHref = strHref.Substring(0, charIndex);
                }
                strHref = strHref.Trim(new char[] { '/', '\\' });
                string tmpDomainURL = GetDomain(strHref);
                if (strHref.Equals(tmpDomainURL, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (!lisA.ContainsKey(strHref) && !lisA.ContainsValue(strText))
                {
                    lisA.Add(strHref, strText);
                }
            }
        }
开发者ID:lamp525,项目名称:DotNet,代码行数:68,代码来源:HtmlUtils.cs

示例15: ExportToCsv

        /// <summary>
        /// Exports results to a .csv file.
        /// </summary>
        /// <param name="_filename">The name of the file to save.</param>
        /// <param name="results">The list of RowResults to persist.</param>
        public static void ExportToCsv(string filename, List<RowResults> results)
        {
            try
            {
                // Force the . as decimal separator
                NumberFormatInfo dblFormat = new NumberFormatInfo();
                dblFormat.NumberDecimalSeparator = ".";

                StringBuilder buff = new StringBuilder();
                Dictionary<int, string> metrics_cols = new Dictionary<int, string>();

                // Columns headers
                // ***************************************************************
                buff.Append("filter,parameters,durationticks,filter-chain");
                int colidx = 0;

                // Gets all distinct metrics executed ...
                // Update metrics_cols and columns headers for each one.
                foreach (RowResults rw in results)
                {
                    if (null != rw.Item4)
                    {
                        foreach (MetricResult rw_res in rw.Item4)
                        {
                            if (!metrics_cols.ContainsValue(rw_res.Key))
                            {
                                metrics_cols.Add(colidx, rw_res.Key);
                                ++colidx;
                                // Add metric to columns; change commas by _ just in case!
                                buff.Append(",").Append(rw_res.Key.Replace(",", "_"));
                            }
                        }
                    }
                }

                buff.AppendLine();

                // ***************************************************************
                // Add rows ...
                string sFilter = "", sParameters = "", sChain = "";
                int idxMetric;
                foreach (RowResults rw in results)
                {
                    if (null != rw.Item4 && rw.Item4.Count > 0)
                    {

                        // Get filter, parameters

                        Facilities.FilterExecToString(rw.Item5.FilterType, rw.Item6, out sFilter, out sParameters);

                        // Get chain of nodes ... convert to filter-list form
                        // ...
                        sChain = "";
                        // Try to get history bucket
                        Image theImage = (Image)rw.Item2;
                        if (theImage != null)
                        {
                            ArrayList bucket = Facilities.GetBucket<ArrayList>(
                                    ref theImage, Facilities.EXECUTED_FILTERS);

                            if (bucket != null)
                            {
                                foreach (object o in bucket)
                                {
                                    sChain += (string.IsNullOrEmpty(sChain) ? "" : " ; ") + o.ToString();
                                }
                            }
                        }

                        // filter
                        buff.Append(sFilter);
                        // parameters
                        buff.Append(",").Append(sParameters);
                        // duration
                        buff.Append(",").Append(rw.Item7.Ticks.ToString());
                        // chain
                        buff.Append(",").Append(sChain);

                        Dictionary<string, double> dMetrics = new Dictionary<string, double>();

                        foreach (MetricResult rw_res in rw.Item4)
                        {
                            dMetrics.Add(rw_res.Key, rw_res.Value);
                        }

                        for (int i = 0; i < colidx; ++i)
                        {
                            buff.Append(",");
                            if (dMetrics.ContainsKey(metrics_cols[i]))
                            {
                                buff.Append(dMetrics[metrics_cols[i]].ToString(dblFormat));
                            }
                        }

                        // --
//.........这里部分代码省略.........
开发者ID:fabriceleal,项目名称:ImageProcessing,代码行数:101,代码来源:Structures.cs


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