本文整理汇总了C#中Run.Last方法的典型用法代码示例。如果您正苦于以下问题:C# Run.Last方法的具体用法?C# Run.Last怎么用?C# Run.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Run
的用法示例。
在下文中一共展示了Run.Last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public IRun Create(IComparisonGeneratorsFactory factory)
{
var run = new Run(factory);
var reader = new StreamReader(Stream);
var line = reader.ReadLine();
var titleInfo = line.Split('|');
run.CategoryName = titleInfo[0].Substring(1);
run.AttemptCount = int.Parse(titleInfo[1]);
TimeSpan totalTime = TimeSpan.Zero;
while ((line = reader.ReadLine()) != null)
{
if (line.Length > 0)
{
var majorSplitInfo = line.Split('|');
totalTime += TimeSpanParser.Parse(majorSplitInfo[1]);
while (!reader.EndOfStream && reader.Read() == '*')
{
line = reader.ReadLine();
run.AddSegment(line);
}
var newTime = new Time(run.Last().PersonalBestSplitTime);
newTime.GameTime = totalTime;
run.Last().PersonalBestSplitTime = newTime;
}
else
{
break;
}
}
return run;
}
示例2: Create
public IRun Create(IComparisonGeneratorsFactory factory)
{
var run = new Run(factory);
var iconsList = new List<Image>();
var reader = new StreamReader(Stream);
var oldRunExists = false;
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Length > 0)
{
if (line.StartsWith("Title="))
{
run.CategoryName = line.Substring("Title=".Length);
}
else if (line.StartsWith("Attempts="))
{
run.AttemptCount = int.Parse(line.Substring("Attempts=".Length));
}
else if (line.StartsWith("Offset="))
{
run.Offset = new TimeSpan(0, 0, 0, 0, -int.Parse(line.Substring("Offset=".Length)));
}
else if (line.StartsWith("Size="))
{
//Ignore
}
else if (line.StartsWith("Icons="))
{
var iconsString = line.Substring("Icons=".Length);
iconsList.Clear();
foreach (var iconPath in iconsString.Split(','))
{
var realIconPath = iconPath.Substring(1, iconPath.Length - 2);
Image icon = null;
if (realIconPath.Length > 0)
{
try
{
icon = Image.FromFile(realIconPath);
}
catch (Exception e)
{
Log.Error(e);
}
}
iconsList.Add(icon);
}
}
else //must be a split Kappa
{
var splitInfo = line.Split(',');
Time pbSplitTime = new Time();
Time goldTime = new Time();
Time oldRunTime = new Time();
pbSplitTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[2], CultureInfo.InvariantCulture.NumberFormat));
goldTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[3], CultureInfo.InvariantCulture.NumberFormat));
oldRunTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[1], CultureInfo.InvariantCulture.NumberFormat));
if (pbSplitTime.RealTime == TimeSpan.Zero)
pbSplitTime.RealTime = null;
if (goldTime.RealTime == TimeSpan.Zero)
goldTime.RealTime = null;
if (oldRunTime.RealTime == TimeSpan.Zero)
oldRunTime.RealTime = null;
else
oldRunExists = true;
run.AddSegment(splitInfo[0], pbSplitTime, goldTime);
run.Last().Comparisons["Old Run"] = oldRunTime;
}
}
}
if (oldRunExists)
run.CustomComparisons.Add("Old Run");
for (var i = 0; i < iconsList.Count; ++i)
{
run[i].Icon = iconsList[i];
}
return run;
}