本文整理汇总了C#中DataRow.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DataRow.Select方法的具体用法?C# DataRow.Select怎么用?C# DataRow.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataRow
的用法示例。
在下文中一共展示了DataRow.Select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBodyParameter
public Robot.BodyParameter GetBodyParameter(DataRow row )
{
Robot.BodyParameter res = new Robot.BodyParameter();
if (row == null) return res;
res.Name = row.Select("Name").ToString();
res.Health = float.Parse(row.Select("Health").ToString());
res.Power = float.Parse(row.Select("Power").ToString());
res.MoveSpeed = float.Parse(row.Select("MoveSpeed").ToString());
res.TurnAngleSpeed = float.Parse(row.Select("TurnAngleSpeed").ToString());
res.Armor = float.Parse(row.Select("Armor").ToString());
res.CreateTime = float.Parse(row.Select("CreateTime").ToString());
res.EquipmentI = res.EquipmentII = res.EquipmentIII = EquipmentType.None;
if (row.Select("EquipmentI").ToString() != "")
res.EquipmentI = (EquipmentType)Enum.Parse(typeof(EquipmentType),row.Select("EquipmentI").ToString());
if (row.Select("EquipmentII").ToString() != "")
res.EquipmentII = (EquipmentType)Enum.Parse(typeof(EquipmentType),row.Select("EquipmentII").ToString());
if (row.Select("EquipmentIII").ToString() != "")
res.EquipmentIII = (EquipmentType)Enum.Parse(typeof(EquipmentType),row.Select("EquipmentIII").ToString());
return res;
}
示例2: GetArmorParameter
public Armor.ArmorParameter GetArmorParameter(DataRow row = null)
{
Armor.ArmorParameter res = new Armor.ArmorParameter();
if (row == null) return res;
res.Name = row.Select("Name").ToString();
res.CreateTime = float.Parse(row.Select("CreateTime").ToString());
res.Armor = float.Parse(row.Select("Armor").ToString());
//parameters
if (row.Select("PNumber").ToString() != "")
res.PNumber = int.Parse(row.Select("PNumber").ToString());
if (row.Select("PPercentage").ToString() != "")
res.PPercentage = float.Parse(row.Select("PPercentage").ToString());
if (row.Select("PTime").ToString() != "")
res.PTime = float.Parse(row.Select("PTime").ToString());
if (row.Select("PRange").ToString() != "")
res.PRange = float.Parse(row.Select("PRange").ToString());
if (row.Select("PDamage").ToString() != "")
res.PDamage = float.Parse(row.Select("PDamage").ToString());
if (row.Select("Parameter1").ToString() != "")
res.Parameter1 = row.Select("Parameter1").ToString();
if (row.Select("Parameter2").ToString() != "")
res.Parameter2 = row.Select("Parameter1").ToString();
//info
res.Info = row.Select("Info").ToString();
return res;
}
示例3: GetPusherParameter
public Pusher.PusherParameter GetPusherParameter(DataRow row)
{
Pusher.PusherParameter res = new Pusher.PusherParameter();
if (row == null) return res;
res.Name = row.Select("Name").ToString();
res.CreateTime = float.Parse(row.Select("CreateTime").ToString());
res.MoveSpeed = float.Parse(row.Select("MoveSpeed").ToString());
res.TurnAngleSpeed = float.Parse(row.Select("TurnAngleSpeed").ToString());
//parameters
if (row.Select("PNumber").ToString() != "")
res.PNumber = int.Parse(row.Select("PNumber").ToString());
if (row.Select("PPercentage").ToString() != "")
res.PPercentage = float.Parse(row.Select("PPercentage").ToString());
if (row.Select("PTime").ToString() != "")
res.PTime = float.Parse(row.Select("PTime").ToString());
if (row.Select("PRange").ToString() != "")
res.PRange = float.Parse(row.Select("PRange").ToString());
if (row.Select("PDamage").ToString() != "")
res.PDamage = float.Parse(row.Select("PDamage").ToString());
if (row.Select("Parameter1").ToString() != "")
res.Parameter1 = row.Select("Parameter1").ToString();
if (row.Select("Parameter2").ToString() != "")
res.Parameter2 = row.Select("Parameter1").ToString();
//info
res.Info = row.Select("Info").ToString();
return res;
}
示例4: GetWeaponParameter
public Weapon.WeaponParameter GetWeaponParameter(DataRow row )
{
Weapon.WeaponParameter res = new Weapon.WeaponParameter();
if (row == null) return res;
res.Name = row.Select("Name").ToString();
res.Damage = float.Parse(row.Select("Damage").ToString());
res.ShootSpeed = float.Parse(row.Select("ShootSpeed").ToString());
res.ShootCoolDown = float.Parse(row.Select("ShootCoolDown").ToString());
res.DamageType = (DamageType)Enum.Parse(typeof(DamageType),row.Select("DamageType").ToString());
res.BulletName = row.Select("BulletName").ToString();
res.CreateTime = float.Parse(row.Select("CreateTime").ToString());
res.BulletPrefab = Resources.Load(Global.BULLET_PREFAB_PATH + res.BulletName) as GameObject;
res.Range = float.Parse(row.Select("Range").ToString());
res.PowerCost = float.Parse(row.Select("PowerCost").ToString());
//parameters
if (row.Select("PNumber").ToString() != "")
res.PNumber = int.Parse(row.Select("PNumber").ToString());
if (row.Select("PPercentage").ToString() != "")
res.PPercentage = float.Parse(row.Select("PPercentage").ToString());
if (row.Select("PTime").ToString() != "")
res.PTime = float.Parse(row.Select("PTime").ToString());
if (row.Select("PRange").ToString() != "")
res.PRange = float.Parse(row.Select("PRange").ToString());
if (row.Select("PDamage").ToString() != "")
res.PDamage = float.Parse(row.Select("PDamage").ToString());
if (row.Select("Parameter1").ToString() != "")
res.Parameter1 = row.Select("Parameter1").ToString();
if (row.Select("Parameter2").ToString() != "")
res.Parameter2 = row.Select("Parameter1").ToString();
//info
res.Info = row.Select("Info").ToString();
return res;
}
示例5: ReadXLS
public DataTable ReadXLS(string sheetName = "" )
{
Debug.Log("Begin to read " + sheetName + " form " + fileName);
TextAsset xmlData = new TextAsset();
xmlData = (TextAsset)Resources.Load(fileName, typeof(TextAsset));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlData.text);
DataTable res = new DataTable();
//Get sheet by sheetName
XmlNodeList sheets = xmlDoc.GetElementsByTagName("Worksheet");
XmlNode sheet = null;
foreach (XmlNode s in sheets)
{
if (s.Attributes["ss:Name"].Value == sheetName)
{
sheet = s;
}
}
if (sheet == null )
{
Debug.Log("Cannot find sheet " + sheetName);
return res;
}
//Analyze the sheet
// xmlDoc.LoadXml(sheet.InnerXml);
XmlNode sheetContent = sheet.ChildNodes[0];
for(int i = sheetContent.ChildNodes.Count - 1 ; i >= 0 ; --i)
{
// Debug.Log(sheetContent.ChildNodes[i].LocalName);
if ( sheetContent.ChildNodes[i].LocalName != "Row" )
sheetContent.RemoveChild(sheetContent.ChildNodes[i]);
}
// XmlNodeList rows = xmlDoc.GetElementsByTagName("Row");
XmlNodeList rows = sheetContent.ChildNodes;
var firstLineDic = new Dictionary<string,string>();
// xmlDoc.LoadXml(rows[0].InnerXml);
XmlNodeList firstLine = rows[0].ChildNodes;
for(int i = 0 ; i < firstLine.Count ; ++ i )
{
firstLineDic.Add((i+1).ToString(), firstLine[i].InnerText);
res.AddFirst(firstLine[i].InnerText);
// Debug.Log("First Line " + firstLine[i].InnerText);
}
for(int i = 1 ; i < rows.Count ; ++i )
// for( int i = 1 ; i < 3 ; ++ i )
{
// xmlDoc.LoadXml(rows[i].InnerXml);
// XmlNodeList cells = xmlDoc.GetElementsByTagName("Cell",rows[i].NamespaceURI);
XmlNodeList cells = rows[i].ChildNodes;
DataRow r = new DataRow();
int indexNow = 1;
for(int j = 0 ; j < cells.Count ; ++ j )
// for( int j = 0 ; j < 3 ; ++ j)
{
if (cells[j].Attributes["ss:Index"] != null)
{
indexNow = int.Parse( cells[j].Attributes["ss:Index"].Value);
}
if (cells[j].InnerText != "" )
r.Add(firstLineDic[indexNow.ToString()],cells[j].InnerText);
indexNow ++;
}
string key = "";
if (!r.isBlank(firstLineDic["1"]))
key = r.Select(firstLineDic["1"]);
res.AddRow( key, r);
}
Debug.Log("rows " + rows.Count.ToString());
return res;
}