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


C# ISet.FirstOrDefault方法代码示例

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


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

示例1: ScanLazy

        /// <summary>
        /// Converts the expression to all the tokens that make up the expression
        /// </summary>
        /// <param name="ExpressionToScan">Expression to scan and return all the tokens</param>
        /// <param name="ValidTokens">Valid tokens for this expression type</param>
        /// <returns>list of tokens that make up the expression</returns>
        public static IEnumerable<TokenBase> ScanLazy(string ExpressionToScan, ISet<ITokenFactory> ValidTokens)
        {
            //declare the string reader
            using (var ExpressionReader = new StringReader(ExpressionToScan))
            {
                //keep reading until we are done
                while (HaveMoreCharacters(ExpressionReader))
                {
                    //what character is this?
                    var CurrentCharacterRead = (char)ExpressionReader.Read();

                    //is this a whitespace character
                    if (char.IsWhiteSpace(CurrentCharacterRead))
                    {
                        //this is a space...go to the next character
                        continue;
                    }

                    //next character for items that are multi character (we only support 2 characters now such as >=)
                    char? CharacterPeekedAt = null; //closest thing to a null character

                    //do we have another character
                    if (HaveMoreCharacters(ExpressionReader))
                    {
                        //we have a character
                        CharacterPeekedAt = (char)ExpressionReader.Peek();
                    }

                    //grab the first token this is valid for
                    var FirstValidToken = ValidTokens.FirstOrDefault(x => x.IsToken(CurrentCharacterRead, CharacterPeekedAt));

                    //did we find a valid token
                    if (FirstValidToken == null)
                    {
                        //can't find a token for this
                        throw new ParserUnknownCharacterException(CurrentCharacterRead);
                    }

                    //we have a valid token
                    yield return FirstValidToken.CreateToken(ExpressionReader, CurrentCharacterRead);
                }
            }
        }
开发者ID:dibiancoj,项目名称:ToracLibrary,代码行数:49,代码来源:GenericTokenizer.cs

示例2: CreateSuite

        public Suite CreateSuite(ISet<Goal> goals)
        {
            if (goals.Count == 0)
            {
                goals.Add(Suite.DebugGoal);
                goals.Add(Suite.ReleaseGoal);
            }

            var activeGoal =
                goals.FirstOrDefault(g => g.Name.Equals(targetGoal, StringComparison.InvariantCultureIgnoreCase));

            if (activeGoal == null)
            {
                if (ignoreTargetGoal)
                    activeGoal = goals.First();
                else
                    throw new InvalidGoalException(targetGoal, goals);
            }

            return new Suite(suiteRoot, goals, activeGoal);
        }
开发者ID:zvrana,项目名称:bari,代码行数:21,代码来源:DefaultSuiteFactory.cs

示例3: FollowMergingSources

 private static IBuilder FollowMergingSources(ISet<EquatableEdge<IBuilder>> graph, IBuilder target)
 {
     var mergeParentEdge = graph.FirstOrDefault(e => e.Target != e.Source && e.Target == target && e.Source is MergingBuilder && !HasDifferentMergingTag(e.Source, e.Target));
     return mergeParentEdge != null ? FollowMergingSources(graph, mergeParentEdge.Source) : target;
 }
开发者ID:vigoo,项目名称:bari,代码行数:5,代码来源:OptimizingBuildContextFactory.cs

示例4: CalculateDominantFrequency

        private string CalculateDominantFrequency(List<DataCriteria> Criterias, IDataStructureObject kf, ISet<ICodelistObject> codelists)
        {
            string DominantFreq = null;
            if (kf.FrequencyDimension.HasCodedRepresentation() && !string.IsNullOrEmpty(kf.FrequencyDimension.Representation.Representation.MaintainableReference.MaintainableId))
            {
                ICodelistObject codes = codelists.FirstOrDefault(c => c.Id == kf.FrequencyDimension.Representation.Representation.MaintainableReference.MaintainableId &&
                        c.AgencyId == kf.FrequencyDimension.Representation.Representation.MaintainableReference.AgencyId &&
                        c.Version == kf.FrequencyDimension.Representation.Representation.MaintainableReference.Version);
                if (codes.Items != null && codes.Items.Count > 1)
                {
                    List<string> allFreq = new List<string>();
                    codes.Items.ToList().ForEach(c => allFreq.Add(c.Id));

                    DataCriteria filter = Criterias.Find(cri => cri.component.Id == kf.FrequencyDimension.Id);
                    if (filter != null)
                        allFreq = filter.values;
                    if (allFreq.Count > 1)
                    {
                        if (allFreq.Contains("A")) DominantFreq = "A";
                        if (allFreq.Contains("S")) DominantFreq = "S";
                        if (allFreq.Contains("Q")) DominantFreq = "Q";
                        if (allFreq.Contains("M")) DominantFreq = "M";
                    }
                }
            }
            return DominantFreq;
        }
开发者ID:alcardac,项目名称:SDMX_DATA_BROWSER,代码行数:27,代码来源:DataPaging.cs


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