本文整理汇总了C#中Match类的典型用法代码示例。如果您正苦于以下问题:C# Match类的具体用法?C# Match怎么用?C# Match使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Match类属于命名空间,在下文中一共展示了Match类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ICanCreateAMatch
public void ICanCreateAMatch()
{
var match = new Match(7, 501);
Assert.AreEqual(7, match.BestOfLegs);
Assert.AreEqual(501, match.LegStartScore);
}
示例2: IsValid
public override bool IsValid(Match match)
{
var nextDecision = match.PendingDecisions.First();
return nextDecision.PlayerIndex == this._playerIndex
&& nextDecision.Type == DecisionType.ChooseMergeOrder;
}
示例3: Apply
public override void Apply(Match match)
{
if (!this.IsValid(match))
{
return;
}
match.PendingDecisions.Dequeue();
if (this._stocks.Count>0)
{
Console.WriteLine(" [{0}] Purchasing stock in: ",match.Players[this._playerIndex].Member.Name);
foreach (var stock in _stocks)
{
match.Players[_playerIndex].AddStock(stock.Key, stock.Value);
var price = Engine.GetStockPrice(stock.Key, match);
Console.WriteLine(" - {1}x {0} - spending {2:C}", stock.Key, stock.Value, stock.Value * price);
match.Players[_playerIndex].Money -= stock.Value * price;
match.AvailableStock[stock.Key] -= stock.Value;
}
}
else
{
Console.WriteLine(" No active chains to purchase stock in");
}
if (match.PendingDecisions.Count == 0)
match.CurrentPhase = MatchPhase.DrawingTile;
}
示例4: Extract
/// <summary>
/// Extracts the matches of this pattern from <paramref name="source" />.
/// </summary>
/// <param name="fileName">The name of the file associated with <paramref name="source" />.</param>
/// <param name="source">The source string</param>
/// <returns>
/// A collection of found matches.
/// </returns>
public MatchCollection Extract(string fileName, string source)
{
MatchCollection resultMatches = new MatchCollection();
LineCounter lineCounter = new LineCounter(source);
RegexMatch regexMatch = scanner.Match(source);
while (regexMatch.Success)
{
Match match = new Match();
match["Path"] = Path.GetDirectoryName(fileName);
match["File"] = Path.GetFileName(fileName);
match["LineNumber"] = lineCounter.CountTo(regexMatch.Index).InvariantToString();
foreach (string groupName in scanner.GetGroupNames())
{
// ignore default-names like '0', '1' ... as produced
// by the Regex class
if (Char.IsLetter(groupName[0]) || (groupName[0] == '_'))
{
match[groupName] = ConcatenateCaptures(regexMatch.Groups[groupName]);
}
}
resultMatches.Add(match);
regexMatch = regexMatch.NextMatch();
}
return resultMatches;
}
示例5: Apply
public override IEnumerable<Tuple<ShapeNode, ShapeNode>> Apply(Match<Word, ShapeNode> match, Word output)
{
FeatureStruct fs = _simpleCtxt.FeatureStruct.DeepClone();
fs.ReplaceVariables(match.VariableBindings);
ShapeNode newNode = output.Shape.Add(fs);
return Tuple.Create((ShapeNode) null, newNode).ToEnumerable();
}
示例6: TranslationCandidatesDefaultValue_Match
public void TranslationCandidatesDefaultValue_Match()
{
Match match;
match = new Match();
Assert.IsFalse(match.HasReferenceTranslation, "HasReferenceTranslation is incorrect.");
Assert.IsNull(match.Id, "Id is incorrect.");
Assert.IsNull(match.MatchQuality, "MatchQuality is incorrect.");
Assert.IsNull(match.MatchSuitability, "MatchSuitability is incorrect.");
Assert.IsNull(match.Metadata, "Metadata is incorrect.");
Assert.IsNull(match.Origin, "Origin is incorrect.");
Assert.IsNull(match.OriginalData, "OriginalData is incorrect.");
Assert.IsNull(match.Similarity, "Similarity is incorrect.");
Assert.IsNull(match.Source, "Source is incorrect.");
Assert.IsNull(match.SourceReference, "SourceReference is incorrect.");
Assert.IsNull(match.SubType, "SubType is incorrect.");
Assert.IsNull(match.Target, "Target is incorrect.");
Assert.AreEqual(MatchType.TranslationMemory, match.Type, "Type is incorrect.");
match = new Match("sourcereference");
Assert.IsFalse(match.HasReferenceTranslation, "HasReferenceTranslation is incorrect.");
Assert.IsNull(match.Id, "Id is incorrect.");
Assert.IsNull(match.MatchQuality, "MatchQuality is incorrect.");
Assert.IsNull(match.MatchSuitability, "MatchSuitability is incorrect.");
Assert.IsNull(match.Metadata, "Metadata is incorrect.");
Assert.IsNull(match.Origin, "Origin is incorrect.");
Assert.IsNull(match.OriginalData, "OriginalData is incorrect.");
Assert.IsNull(match.Similarity, "Similarity is incorrect.");
Assert.IsNull(match.Source, "Source is incorrect.");
Assert.AreEqual("sourcereference", match.SourceReference, "SourceReference is incorrect.");
Assert.IsNull(match.SubType, "SubType is incorrect.");
Assert.IsNull(match.Target, "Target is incorrect.");
Assert.AreEqual(MatchType.TranslationMemory, match.Type, "Type is incorrect.");
}
示例7: Goal
public Goal(int id, int minutes, Match match, int idPlayer)
{
Id = id;
Minutes = minutes;
Match = match;
Player = createPlayer(idPlayer);
}
示例8: PointsEarned
public override int PointsEarned(MatchResult outcome, Match MatchOfWeek)
{
int Multiple = outcome.Match == MatchOfWeek ? 2 : 1;
if (outcome.Winner != null && !outcome.Winner.Equals(Winner))
return 0;
//Is a stoppage!
if (outcome.ResultType.HasRounds)
{
if (outcome.Round == Round)
{
return ((3 + 5) * Multiple);
}
else if (outcome.Round <= Round + 1 && outcome.Round >= Round - 1)
{
return ((3 + 3) * Multiple);
}
else if (outcome.Round <= Round + 2 && outcome.Round >= Round - 2)
{
return ((3 + 1) * Multiple);
}
else
{
return (3 * Multiple);
}
}
return 0;
}
示例9: ConvertJsonDateToDateString
/// <summary>
/// 将Json序列化的时间由/Date(....)转为字符串
/// </summary>
private string ConvertJsonDateToDateString(Match m)
{
string result = string.Empty;
DateTime dt = new DateTime(1970, 1, 1);
dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value)).ToLocalTime();
return dt.ToString(FormateStr);
}
示例10: ReplaceMatch
private static void ReplaceMatch(Match scMatch, int monitorHeight, string scConfigContent, string scFolderPath, string fileName)
{
if (scMatch.Success)
{
string fullString = scMatch.Captures[0].Value;
string variablesName = scMatch.Groups[1].Captures[0].Value;
string delimiter = scMatch.Groups[2].Captures[0].Value;
string valueEnclosingCharacter = scMatch.Groups[3].Captures[0].Value;
int configHeight = int.Parse(scMatch.Groups[4].Captures[0].Value);
if (configHeight != monitorHeight)
{
Console.WriteLine("Current Height: {0}", configHeight);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Changing to {0}", monitorHeight);
scConfigContent = scConfigContent.Replace(fullString, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{2}", variablesName, delimiter, valueEnclosingCharacter, monitorHeight));
Console.ForegroundColor = ConsoleColor.Green;
WriteAllText(scFolderPath, fileName, scConfigContent);
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Everthing is already goooood to gooo!!!");
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Something bad happened to the config file... go check it!");
Console.ReadLine();
}
}
示例11: Cluster
/// <summary>
/// Clusters Two INodes together, sets new root/parent/left and right edges
/// </summary>
/// <param name="left"> Node on the left </param>
/// <param name="right"> Node on the Right </param>
/// <param name="match"> Inverted or Not Inverted </param>
/// <param name="matchData"> Optional MatchData variable, store clustering information </param>
public Cluster(INode left, INode right, Match match = Match.NonInverted, MatchData matchData = null)
{
if (match == Match.Impossible)
{
throw new ArgumentException("Match is apparently impossible why are you trying?");
}
// Now Build the new nodes
_left = left;
_right = right;
_matchData = matchData;
_size = left.Size() + right.Size();
_leftedge = left.LeftEdge();
_rightedge = right.RightEdge();
// Set the parents accordingly
left.Parent(this);
right.Parent(this);
_parent = null;
// change the roots
_left.Root(this);
_right.Root(this);
// Update Count
Id = _count++;
}
示例12: CreateMatch
public Match CreateMatch(DateTime matchDate, TimeSpan time, Venue venue, CompetitionMatchType matchType,
Competition competition, Team homeTeam, Team awayTeam)
{
if (homeTeam.GetType() == awayTeam.GetType())
{
Match match = new Match();
match.MatchDate = matchDate;
match.MatchTime = time;
match.Venue = venue;
match.CompetitionMatchType = matchType;
match.Competition = competition;
match.HomeTeam = homeTeam;
match.AwayTeam = awayTeam;
context.Matches.Add(match);
context.SaveChanges();
return match;
}
else
{
return null;
}
}
示例13: MatchCollectionTest
public MatchCollectionTest()
{
Match<char> match;
try
{
match = new Match<char> ("0123456789".ToListCursor (), 0, 10, true);
}
catch (Exception e)
{
Assert.Inconclusive (e.ToString ());
throw;
}
m_allDigitsMatch = match;
try
{
match = new Match<char> ("0123456789".ToListCursor (), 0, 0, false);
}
catch (Exception e)
{
Assert.Inconclusive (e.ToString ());
throw;
}
m_noDigitsMatch = match;
}
示例14: ICannotAdd2PlayersToAMatchWithTheSameName
public void ICannotAdd2PlayersToAMatchWithTheSameName()
{
var match = new Match(7, 501);
var player = new Player("Andy");
match.AddPlayer(player);
match.AddPlayer(player);
}
示例15: ProcessRequest
public override void ProcessRequest(HttpContext context, Match match)
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
try
{
PccConfig.LoadConfig("pcc.config");
string searchTermsId = GetStringFromUrl(context, match, "SearchTermsId");
// make sure target directory exists
String targetDir = System.IO.Path.GetDirectoryName(PccConfig.SearchTermsPath);
if (!System.IO.Directory.Exists(targetDir))
{
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.Write("SearchTermsPath does not exist or is not configured correctly in pcc.config");
context.Response.ContentType = "text/plain";
return;
}
string searchTermsFileName = Path.Combine(targetDir, searchTermsId);
using (FileStream searchStream = new FileStream(searchTermsFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
searchStream.CopyTo(context.Response.OutputStream);
}
context.Response.ContentType = "application/json;charset=utf-8";
context.Response.StatusCode = (int)HttpStatusCode.OK;
}
catch(Exception e)
{
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.Write(e.Message);
context.Response.ContentType = "text/plain";
return;
}
}