Here are the examples of the csharp api System.Collections.Generic.List.Contains(WikiTextTableEntry) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : WikiTextTableParser.cs
with MIT License
from AnnoDesigner
with MIT License
from AnnoDesigner
private static List<WikiTextTableEntry> ParseTableEntry(string curTable)
{
var allEntries = new List<WikiTextTableEntry>();
var regionInfo = GetRegionAndTierInfo(curTable);
WikiTextTableEntry curEntry = null;
var entryCounter = 0;
var lastLineWasCollapsible = false;
//read string line by line
//use StringReader?
foreach (var curLine in curTable.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
//line is a collapsible information
if (lastLineWasCollapsible)
{
lastLineWasCollapsible = !lastLineWasCollapsible;
continue;
}
if (curLine.StartsWith("!", StringComparison.OrdinalIgnoreCase) && curLine.Contains("colspan=\"6\""))
{
lastLineWasCollapsible = true;
continue;
}
//line is empty
if (string.IsNullOrWhiteSpace(curLine))
{
continue;
}
//line has no useful information
if (curLine.Equals(STYLE_INFO, StringComparison.OrdinalIgnoreCase) &&
entryCounter != 4)//there are buildings without maintenance cost
{
continue;
}
//line is end of table
if (curLine.Equals("=", StringComparison.OrdinalIgnoreCase))
{
continue;
}
//line contains description
if (!curLine.StartsWith("|", StringComparison.OrdinalIgnoreCase) &&
!curLine.StartsWith("(", StringComparison.OrdinalIgnoreCase) &&
!regexSize.IsMatch(curLine))
{
curEntry.Description += $"{Environment.NewLine}{curLine}";
continue;
}
//line contains radius info
if (curLine.StartsWith("(", StringComparison.OrdinalIgnoreCase))
{
curEntry.Size += $"{Environment.NewLine}{curLine}";
continue;
}
//start new entry
if (curLine.StartsWith("|-", StringComparison.OrdinalIgnoreCase))
{
if (curEntry != null)
{
allEntries.Add(curEntry);
}
entryCounter = 0;
curEntry = new WikiTextTableEntry
{
Region = regionInfo.Item1,
Tier = regionInfo.Item2
};
continue;
}
switch (entryCounter)
{
case 0:
{
curEntry.Icon = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 1:
{
curEntry.Name = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 2:
{
curEntry.Description = curLine.Remove(0, 1);
entryCounter++;
break;
}
case 3:
{
curEntry.ConstructionCost = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
entryCounter++;
break;
}
case 4:
{
curEntry.MaintenanceCost = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty)
.Replace("−", "-");//can't parse as negative number
entryCounter++;
break;
}
case 5:
{
if (curLine.StartsWith("|", StringComparison.OrdinalIgnoreCase))
{
curEntry.Size = curLine.Remove(0, 1)
.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
}
else
{
curEntry.Size = curLine.Replace(" style=\"text-align:center;\" |", string.Empty)
.Replace(" style=\"text-align: center;\" |", string.Empty);
}
entryCounter++;
break;
}
default:
break;
}
}
//add last entry
if (curEntry != null && !allEntries.Contains(curEntry))
{
allEntries.Add(curEntry);
}
return allEntries;
}