本文整理汇总了C#中TableInfo.AddField方法的典型用法代码示例。如果您正苦于以下问题:C# TableInfo.AddField方法的具体用法?C# TableInfo.AddField怎么用?C# TableInfo.AddField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableInfo
的用法示例。
在下文中一共展示了TableInfo.AddField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadLibConfig
public void LoadLibConfig(string file)
{
this.statusmessage = "";
tables.Clear();
infotables.Clear();
XmlReader xmlr = XmlReader.Create(file);
TableInfo currentTable = null;
string currentTag = "";
while (xmlr.Read())
{
if (xmlr.NodeType == XmlNodeType.Element)
{
if (xmlr.IsStartElement())
{
currentTag = xmlr.Name;
switch (currentTag.ToLower())
{
case "ini":
tablecount = xmlr["TableCount"];
tableinfocount = xmlr["TableInfoCount"];
break;
case "table":
// Add table to table list
currentTable = new TableInfo();
currentTable.Name = xmlr["name"];
currentTable.RowCount = xmlr["RowCount"];
currentTable.TableInfoID = xmlr["TableInfoID"];
currentTable.FieldCnt = xmlr["FieldCnt"];
infotables.Add(xmlr["TableInfoID"]);
break;
case "fieldinfo":
currentTable.AddField(xmlr["Name"], xmlr["IsKey"], xmlr["DataType"]);
break;
case "row":
currentTable.BeginRow();
break;
default:
break;
}
}
}
if (xmlr.NodeType == XmlNodeType.EndElement)
{
switch (xmlr.Name.ToLower())
{
case "ini":
break;
case "table":
if (!currentTable.UpdateMetadata())
{
this.statusmessage = "Warning: Table \"" + currentTable.Name + "\" data might be malformed";
}
tables.Add(currentTable);
break;
case "fieldinfo":
break;
case "row":
currentTable.EndRow();
break;
default:
// Can only get value after tag concluded
//currentTable.SetValue(lasttag, xmlr.Value);
break;
}
}
if (xmlr.NodeType == XmlNodeType.Text || xmlr.NodeType == XmlNodeType.CDATA)
{
currentTable.SetValue(currentTag, xmlr.Value);
}
}
// Fix table count info if it does not match
int matchTableCount = 0;
int.TryParse(tablecount, out matchTableCount);
if (matchTableCount != tables.Count)
{
this.statusmessage = "Warning: Number of tables do not match libconfig info";
tablecount = tables.Count.ToString();
}
}