本文整理汇总了C#中System.Xml.XmlReader.ReadContentAsFloat方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadContentAsFloat方法的具体用法?C# XmlReader.ReadContentAsFloat怎么用?C# XmlReader.ReadContentAsFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadContentAsFloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: load
public static Firewall load(XmlReader reader)
{
while (reader.Name != "firewall")
reader.Read();
var complexity = 0;
string solution = null;
var additionalTime = 0.0f;
if (reader.MoveToAttribute("complexity"))
complexity = reader.ReadContentAsInt();
if (reader.MoveToAttribute("solution"))
solution = reader.ReadContentAsString();
if (reader.MoveToAttribute("additionalDelay"))
additionalTime = reader.ReadContentAsFloat();
return new Firewall(complexity, solution, additionalTime);
}
示例2: DeserializePrimitive
private static object DeserializePrimitive(XmlReader xmlReader, Type type)
{
if (!xmlReader.IsEmptyElement)
{
var name = xmlReader.Name;
xmlReader.Read();
object value = null;
if (xmlReader.NodeType == XmlNodeType.CDATA)
{
value = xmlReader.Value;
xmlReader.Read();
}
else if (xmlReader.NodeType == XmlNodeType.Text)
{
if (name == F_NUM)
{
var @float = xmlReader.ReadContentAsFloat();
value = Convert.ChangeType(@float, type);
}
else
{
value = xmlReader.ReadContentAs(type, null);
if (value is string)
{
string valueString = (string)value;
valueString = valueString.Trim();
// for some reason the cdata check above doesn't appear to work
if (valueString.StartsWith("<![CDATA[") && valueString.EndsWith("]]>"))
{
value = valueString.Substring(9, valueString.Length - 12);
}
}
}
}
xmlReader.ReadEndElement();
return value;
}
if (type == typeof (bool))
{
var value = xmlReader.Name;
bool result;
xmlReader.Read();
if (bool.TryParse(value, out result))
{
return result;
}
}
return null;
}
示例3: LoadLevel
private void LoadLevel(XmlReader reader, ContentManager content)
{
string aCurrentElement = string.Empty;
int aPositionX = 0;
int aPositionY = 0;
//vars for the spawning of objects
float aSpawnPosX = 0;
float aSpawnPosY = 0;
string formation = string.Empty;
bool mirrored = false;
while (reader.Read())
{
if(reader.NodeType == XmlNodeType.EndElement &&
reader.Name.Equals("level", StringComparison.OrdinalIgnoreCase))
{
break;
}
else if (reader.NodeType == XmlNodeType.Element)
{
aCurrentElement = reader.Name;
switch (aCurrentElement)
{
case "name":
{
levelName = reader.ReadElementContentAsString();
break;
}
case "nextlevel":
{
nextLevel = reader.ReadElementContentAsString();
break;
}
case "description":
{
description = reader.ReadElementContentAsString();
break;
}
case "tileset":
{
var texfilelocation = reader.ReadElementContentAsString();
LoadTile(texfilelocation, content);
break;
}
}
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
if (aCurrentElement == "row")
{
aPositionY += 1;
aPositionX = 0;
}
}
else if (reader.NodeType == XmlNodeType.Text)
{
if (aCurrentElement == "row")
{
string aRow = reader.Value;
nrOfRows += 1;
for (int counter = 0; counter < aRow.Length; counter++)
{
var tempChar = aRow[counter].ToString().ToCharArray()[0];
mapList.Add(new Tile(new Vector2(aPositionX, aPositionY), tempChar));
aPositionX += 1;
}
}
else if (aCurrentElement == "positionX")
{
aSpawnPosX = reader.ReadContentAsFloat();
aSpawnPosX *= tilesize;
}
else if (aCurrentElement == "positionY")
{
aSpawnPosY = reader.ReadContentAsFloat();
aSpawnPosY *= tilesize;
aSpawnPosY = -aSpawnPosY;
}
else if (aCurrentElement == "formation")
{
formation = reader.Value;
}
else if (aCurrentElement == "mirrored")
{
mirrored = reader.ReadContentAsBoolean();
mapSpawnList.Add(new LevelSpawnObj(new Vector2(aSpawnPosX, aSpawnPosY), formation, mirrored));
}
}
}
StartingCameraPos();
//.........这里部分代码省略.........
示例4: readDataFromXml
/// <summary>Called when the current node in the XmlReader should be parsed into data for this layer</summary>
/// <param name="reader">The XmlReader that holds the current node</param>
protected override void readDataFromXml(XmlReader reader)
{
// Read the pen width
if(reader.Name == "pen-width")
{
reader.Read();
if(reader.NodeType == XmlNodeType.Text)
{
try { penWidth = reader.ReadContentAsFloat(); }
catch(Exception)
{ throw new XmlException("Verkeerd pen breedte formaat."); }
}
else
throw new XmlException("Een 'text node' werd verwacht.");
if(reader.NodeType != XmlNodeType.EndElement || reader.Name != "pen-width")
throw new XmlException("Onverwachte 'node', de node '</pen-width>' werd verwacht.");
}
// Read the points
else if(reader.Name == "points")
{
// Read the amount of points
int pointCount = 0;
while(reader.MoveToNextAttribute())
{
if(reader.Name == "count")
pointCount = reader.ReadContentAsInt();
}
// Create the list of points
points = new List<Point>(pointCount);
while(reader.NodeType != XmlNodeType.EndElement || reader.Name != "points")
{
reader.Read();
if(reader.NodeType == XmlNodeType.Element && reader.Name == "point")
{
Point p = new Point(0, 0);
reader.Read();
while(reader.NodeType != XmlNodeType.EndElement || reader.Name != "point")
{
if(reader.NodeType == XmlNodeType.Element && (reader.Name == "x" || reader.Name == "y"))
{
if(reader.Name == "x")
p.X = reader.ReadElementContentAsInt();
else
p.Y = reader.ReadElementContentAsInt();
}
}
points.Add(p);
}
}
}
// Let the base class read its data
else
base.readDataFromXml(reader);
}
示例5: load
public static Computer load(XmlReader reader, OS os)
{
while (reader.Name != "computer")
reader.Read();
reader.MoveToAttribute("name");
var compName = reader.ReadContentAsString();
reader.MoveToAttribute("ip");
var compIP = reader.ReadContentAsString();
reader.MoveToAttribute("type");
var compType = (byte) reader.ReadContentAsInt();
reader.MoveToAttribute("spec");
var str1 = reader.ReadContentAsString();
reader.MoveToAttribute("id");
var str2 = reader.ReadContentAsString();
string str3 = null;
if (reader.MoveToAttribute("devices"))
str3 = reader.ReadContentAsString();
string str4 = null;
if (reader.MoveToAttribute("icon"))
str4 = reader.ReadContentAsString();
while (reader.Name != "location")
reader.Read();
reader.MoveToAttribute("x");
var x = reader.ReadContentAsFloat();
reader.MoveToAttribute("y");
var y = reader.ReadContentAsFloat();
while (reader.Name != "security")
reader.Read();
reader.MoveToAttribute("level");
var seclevel = reader.ReadContentAsInt();
reader.MoveToAttribute("traceTime");
var num1 = reader.ReadContentAsFloat();
reader.MoveToAttribute("portsToCrack");
var num2 = reader.ReadContentAsInt();
reader.MoveToAttribute("adminIP");
var str5 = reader.ReadContentAsString();
var time = -1f;
if (reader.MoveToAttribute("proxyTime"))
time = reader.ReadContentAsFloat();
while (reader.Name != "admin")
reader.Read();
reader.MoveToAttribute("type");
var str6 = reader.ReadContentAsString();
reader.MoveToAttribute("resetPass");
var flag1 = reader.ReadContentAsBoolean();
reader.MoveToAttribute("isSuper");
var flag2 = reader.ReadContentAsBoolean();
Administrator administrator = null;
switch (str6)
{
case "fast":
administrator = new FastBasicAdministrator();
break;
case "basic":
administrator = new BasicAdministrator();
break;
}
if (administrator != null)
administrator.ResetsPassword = flag1;
if (administrator != null)
administrator.IsSuper = flag2;
while (reader.Name != "links")
reader.Read();
var strArray = reader.ReadElementContentAsString().Split();
Firewall firewall = null;
while (reader.Name != "portsOpen" && reader.Name != "firewall")
reader.Read();
if (reader.Name == "firewall")
firewall = Firewall.load(reader);
while (reader.Name != "portsOpen")
reader.Read();
var portsList = reader.ReadElementContentAsString();
var computer = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);
computer.firewall = firewall;
computer.admin = administrator;
if (time > 0.0)
{
computer.addProxy(time);
}
else
{
computer.hasProxy = false;
computer.proxyActive = false;
}
while (reader.Name != "users")
reader.Read();
computer.users.Clear();
while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
{
if (reader.Name == "user")
{
var userDetail = UserDetail.loadUserDetail(reader);
if (userDetail.name.ToLower() == "admin")
computer.adminPass = userDetail.pass;
computer.users.Add(userDetail);
}
reader.Read();
}
while (reader.Name != "daemons")
reader.Read();
//.........这里部分代码省略.........