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


C# SafeDictionary.ContainsKey方法代码示例

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


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

示例1: RunEnumeration

        /// <summary>
        /// Reflect the Class Name in the Source
        /// </summary>
        /// <param name="templateSource">
        /// The template source.
        /// </param>
        /// <returns>
        /// </returns>
        private static Item[] RunEnumeration(string templateSource, Item sourceItem)
        {
            templateSource = templateSource.Replace("lucene:", string.Empty);
            var commands = templateSource.Split(';');
            var refinements = new SafeDictionary<string>();

            foreach (var command in commands)
            {
                if (!command.IsNullOrEmpty())
                {
                    var commandSplit = command.Split(':');
                    if (commandSplit.Length == 2)
                    {
                        refinements.Add(commandSplit[0], commandSplit[1]);
                    }
                }
            }

            if (refinements.ContainsKey("location"))
            {
                int hitsCount;
                var items = Context.ContentDatabase.GetItem(refinements["location"]).Search(refinements, out hitsCount);
                return items.ToList().Select(x => x.GetItem()).ToArray();
            }
            else
            {
                int hitsCount;
                var items = sourceItem.Search(refinements, out hitsCount);
                return items.ToList().Select(x => x.GetItem()).ToArray();
            }
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:39,代码来源:LuceneQuery.cs

示例2: GetFieldCrawlerValues

        /// <summary>
        /// The get field crawler values.
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="fieldCrawlers">
        /// The field crawlers.
        /// </param>
        /// <returns>
        /// The IEnumerable of field crawler values.
        /// </returns>
        public static IEnumerable<string> GetFieldCrawlerValues(Field field, SafeDictionary<string, string> fieldCrawlers)
        {
            Assert.IsNotNull(field, "Field was not supplied");
            Assert.IsNotNull(fieldCrawlers, "Field Crawler collection is not specified");

            if (fieldCrawlers.ContainsKey(field.TypeKey))
            {
                var fieldCrawlerType = fieldCrawlers[field.TypeKey];

                if (!string.IsNullOrEmpty(fieldCrawlerType))
                {
                    var fieldCrawler = ReflectionUtil.CreateObject(fieldCrawlerType, new object[] { field });

                    if (fieldCrawler is IMultivaluedFieldCrawler)
                    {
                        return (fieldCrawler as IMultivaluedFieldCrawler).GetValues();
                    }

                    if (fieldCrawler is FieldCrawlerBase)
                    {
                        return new[] { (fieldCrawler as FieldCrawlerBase).GetValue() };
                    }
                }
            }

            return new[] { new DefaultFieldCrawler(field).GetValue() };
        }
开发者ID:NetworkTen,项目名称:SitecoreSearchContrib,代码行数:39,代码来源:ExtendedFieldCrawlerFactory.cs

示例3: GetFieldCrawlerValue

        public static string GetFieldCrawlerValue(Field field, SafeDictionary<string, string> fieldCrawlers)
        {
            Assert.IsNotNull(field, "Field was not supplied");
            Assert.IsNotNull(fieldCrawlers, "Field Crawler collection is not specified");

            if (fieldCrawlers.ContainsKey(field.TypeKey))
            {
                var fieldCrawlerType = fieldCrawlers[field.TypeKey];

                if (!fieldCrawlerType.IsNullOrEmpty())
                {
                    var fieldCrawler = ReflectionUtil.CreateObject(fieldCrawlerType, new object[] { field });

                    if (fieldCrawler.IsNotNull() && fieldCrawler is FieldCrawlerBase)
                    {
                        return (fieldCrawler as FieldCrawlerBase).GetValue();
                    }
                }
            }

            return new DefaultFieldCrawler(field).GetValue();
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:22,代码来源:ExtendedFieldCrawlerFactory.cs

示例4: Load

        public static void Load()
        {
            BaseInformations = new SafeDictionary<uint, ConquerItemBaseInformation>(10000);
            PlusInformations = new SafeDictionary<uint, SafeDictionary<byte, ConquerItemPlusInformation>>(10000);
            GradeInformations = new SafeDictionary<string, SafeDictionary<int, ConquerItemBaseInformation>>(10000);
            GradeInformations2 = new SafeDictionary<string, SafeDictionary<uint, int>>(10000);
            string[] baseText = File.ReadAllLines(ServerBase.Constants.ItemBaseInfosPath);
            string text = "►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄";
            int for1prg = baseText.Length / (System.Console.WindowWidth - text.Length);
            int count = 0;
            System.Console.Write(text);
            var old1 = System.Console.BackgroundColor;
            var old2 = System.Console.ForegroundColor;
            System.Console.BackgroundColor = ConsoleColor.Gray;
            System.Console.ForegroundColor = ConsoleColor.Gray;
            int gkey = 0;
            int lastlevel = 0;
            string lastgr = "";
            foreach (string line in baseText)
            {
                count++;
                if (count == for1prg)
                {
                    count = 0;
                    System.Console.Write("▼◘");
                }
                string _item_ = line.Trim();
                if (_item_.Length > 11)
                {
                    if (_item_.IndexOf("//", 0, 2) != 0)
                    {
                        ConquerItemBaseInformation CIBI = new ConquerItemBaseInformation();
                        CIBI.Parse(_item_);

                        var Grades = GradeInformations[CIBI.Description];
                        BaseInformations.Add(CIBI.ID, CIBI);
                        if (GradeInformations.ContainsKey(CIBI.Description) == false)
                        {
                            GradeInformations2.Add(CIBI.Description, new SafeDictionary<uint, int>(1000));
                            GradeInformations2[CIBI.Description].Add((uint)(CIBI.ID / 10), 0);
                            lastlevel = CIBI.Level;
                            GradeInformations.Add(CIBI.Description, new SafeDictionary<int, ConquerItemBaseInformation>(1000));
                            gkey = 0;
                        }
                        else
                        {
                            if (lastgr != CIBI.Description)
                                gkey = GradeInformations2[CIBI.Description].Count - 1;

                            if (GradeInformations2[CIBI.Description].ContainsKey(CIBI.ID / 10) && CIBI.Level == lastlevel)
                            {
                                CIBI.GradeKey = gkey;
                                continue;
                            }
                            else
                            {
                                GradeInformations2[CIBI.Description].Add((uint)(CIBI.ID / 10), 0);
                                lastlevel = CIBI.Level;
                                gkey = gkey + 1;
                            }
                        }
                        lastgr = CIBI.Description;
                        CIBI.GradeKey = gkey;
                        GradeInformations[CIBI.Description].Add(gkey, CIBI);
                    }
                }
            }
            GradeInformations2.Base.Clear();
            System.Console.BackgroundColor = old1;
            System.Console.ForegroundColor = old2;
            baseText = File.ReadAllLines(ServerBase.Constants.ItemPlusInfosPath);

            foreach (string line in baseText)
            {
                try
                {
                    string _item_ = line.Trim();
                    ConquerItemPlusInformation CIPI = new ConquerItemPlusInformation();
                    CIPI.Parse(_item_);
                    SafeDictionary<byte, ConquerItemPlusInformation> info = null;
                    if (PlusInformations.TryGetValue(CIPI.ID, out info))
                    {
                        info.Add(CIPI.Plus, CIPI);
                    }
                    else
                    {
                        PlusInformations.Add(CIPI.ID, new SafeDictionary<byte, ConquerItemPlusInformation>(1000));
                        if (PlusInformations.TryGetValue(CIPI.ID, out info))
                        {
                            info.Add(CIPI.Plus, CIPI);
                        }
                    }
                }
                catch
                {
                    Console.WriteLine(line);
                    Console.ReadLine();
                }
            }
            Console.WriteLine("Item Base and Plus information loaded.");
//.........这里部分代码省略.........
开发者ID:faresali,项目名称:co-pserver,代码行数:101,代码来源:ConquerItemInformation.cs

示例5: TryLoadReferencedAssemblies

        /// <summary>
        /// Tries to load the referenced assemblies.
        /// </summary>
        /// <param name="inputAssemblies">Assemblies</param>
        private void TryLoadReferencedAssemblies(Assembly[] inputAssemblies)
        {
            var ws = new SafeDictionary<string, Assembly>();

            foreach (Assembly a in inputAssemblies)
            {
                if (a == null)
                {
                    continue;
                }

                // recursively load all the assemblies reachables from the root!
                if (!Assemblies.ContainsKey(
                    a.GetName().FullName) && !ws.ContainsKey(a.GetName().FullName))
                {
                    ws.Add(a.GetName().FullName, a);
                }

                while (ws.Count > 0)
                {
                    var en = ws.Keys.GetEnumerator();
                    en.MoveNext();
                    var a_name = en.Current;
                    var a_assembly = ws[a_name];
                    Assemblies.Add(a_name, a_assembly);
                    ws.Remove(a_name);

                    foreach (AssemblyName name in a_assembly.GetReferencedAssemblies())
                    {
                        Assembly b;
                        ExtendedReflection.Utilities.ReflectionHelper.TryLoadAssembly(name.FullName, out b);

                        if (b != null)
                        {
                            if (!Assemblies.ContainsKey(b.GetName().FullName) &&
                                !ws.ContainsKey(b.GetName().FullName))
                            {
                                ws.Add(b.GetName().FullName, b);
                            }
                        }
                    }
                }
            }
        }
开发者ID:yonglehou,项目名称:PSharp,代码行数:48,代码来源:RemoteRaceInstrumentationEngine.cs

示例6: GetLang

        /// <summary>
        /// 取所有语言
        /// </summary>
        /// <returns></returns>
        private ISafeDictionary<string, string> GetLang() {
            if (lang.IsNullEmpty()) Msg.WriteEnd("语言未设置!");
            string path = "".GetMapPath() + "\\lang\\{0}.lang".FormatWith(lang);
            if (!FileDirectory.FileExists(path)) Msg.WriteEnd("语言文件{0}.lang不存在!".FormatWith(lang));

            string lineText = string.Empty; ISafeDictionary<string, string> list = new SafeDictionary<string, string>();
            using (StreamReader reader = new StreamReader(path, System.Text.Encoding.UTF8)) {
                while ((lineText = reader.ReadLine()).IsNotNull()) {
                    int len = lineText.IndexOf('=');
                    if (lineText.IsNullEmpty() || len == -1) continue;
                    string key = lineText.Substring(0, len).Trim();
                    string value = lineText.Substring(len + 1).Trim();
                    if (!list.ContainsKey(key)) list.Add(key, value); else list[key] = value;
                }
            }
            return list;
        }
开发者ID:pczy,项目名称:Pub.Class,代码行数:21,代码来源:MasterPageBase.cs

示例7: AnalyzePreviousAndCurrentUncoveredLoc

        /// <summary>
        /// Compares current uncovered locations with the previous uncovered locations
        /// </summary>
        internal void AnalyzePreviousAndCurrentUncoveredLoc(string currPUTSignature,
            out HashSet<string> allGivenUpLocations, out HashSet<string> allCoveredLocations,
            out HashSet<string> newUncoveredLocations, out bool hasSomeCoveredLocation,
            out bool bAllAreNewLocations, out bool bNoneAreNewLocations)
        {
            hasSomeCoveredLocation = false;
            bAllAreNewLocations = true;
            bNoneAreNewLocations = true;

            var resolvedPrevLocations = new SafeSet<string>();
            var bestFitnessValues = new SafeDictionary<string, int>();

            //This dictionary is constructed since the FactorySuggestionStore is based
            //on declarting type not on the explorable type, which can be different
            allGivenUpLocations = new HashSet<string>();
            allCoveredLocations = new HashSet<string>();
            tempAllLocationStore = new SafeDictionary<string, PersistentUncoveredLocationStore>();

            //All final suggested sequences of the current PUT
            var putspecificsequences = new List<MethodSignatureSequence>();

            foreach (var fss in this.FactorySuggestionsDictionary.Values)
            {
                foreach (var codelockey in fss.locationStoreSpecificSequences.Keys)
                {
                    var pucls = fss.locationStoreSpecificSequences[codelockey];
                    if (!pucls.IsDormat())  //Donot touch dormant persistent stores
                        tempAllLocationStore[codelockey] = pucls;
                }

                foreach (var givenUpLocation in fss.PermanentFailedUncoveredLocations)
                    allGivenUpLocations.Add(givenUpLocation);

                foreach (var coveredLocation in fss.SuccessfulCoveredLocations)
                    allCoveredLocations.Add(coveredLocation);

                //MethodSignatureSequenceList mssl;
                //if (fss.FinalPUTSequences.TryGetValue(currPUTSignature, out mssl))
                //{
                //    foreach (var seq in mssl.SequenceList)
                //    {
                //        if (!putspecificsequences.Contains(seq))
                //            putspecificsequences.Add(seq);
                //    }
                //}
            }

            var failedLocations = new SafeSet<PersistentUncoveredLocationStore>();
            //Traverse all uncovered locations
            foreach (var ucovLocList in this.UncoveredLocationDictionary.Values)
            {
                var locationStr = ucovLocList.Location.ToString();
                var key = UncoveredCodeLocationStore.GetKey(ucovLocList.Location.ToString(),
                    ucovLocList.ExplorableType.ToString(), ucovLocList.TermIndex);

                //Check whether there are any defect detecting sequences. If yes promote them
                //in the associated factory store
                foreach (var ucls in ucovLocList.StoreList)
                {
                    if (ucls.IsADefectDetectingSequence)
                    {
                        var fss = this.FactorySuggestionsDictionary[ucls.ExplorableType.ToString()];
                        SafeDebug.AssumeNotNull(fss, "fss cannot be null");
                        fss.AddToDefectDetectingSequences(ucls.MethodCallSequence);
                    }
                }

                if (allGivenUpLocations.Contains(key))
                {
                    //This location has been earlier given up. No need to deal with this
                    resolvedPrevLocations.Add(key);
                    this.Log.LogMessage(WikiTopics.MissingWikiTopic, "Location " + locationStr + " is ignored since it was already given up earlier!!!");
                    continue;
                }

                if (allCoveredLocations.Contains(key))
                {
                    //This location has been covered earlier. Ideally this case should not happen
                    //resolvedPrevLocations.Add(key);
                    this.Log.LogMessage(WikiTopics.MissingWikiTopic,
                        "Location " + locationStr + " is previously covered, but can be reported since the caller could be different.");
                    bAllAreNewLocations = false;
                    //continue;
                }

                //Get the associated factory suggestion store
                if (tempAllLocationStore.ContainsKey(key))
                {
                    bAllAreNewLocations = false;
                    var pucls = tempAllLocationStore[key];
                    resolvedPrevLocations.Add(key);

                    //For some formats such as TRUE_SET, we do not need the fitness measure
                    //If they are not covered in one attempt, they won't be covered any time
                    if (ucovLocList.StoreList.Count > 0)
                    {
                        var fmt = ucovLocList.StoreList[0].DesiredFieldModificationType;
//.........这里部分代码省略.........
开发者ID:spati2,项目名称:ICSE-2011-Covana,代码行数:101,代码来源:PexMeDynamicDatabase.cs


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