本文整理汇总了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);
}
}
}
示例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);
}
示例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;
}
示例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;
}