本文整理匯總了C#中System.Xml.XmlTextReader.ReadElementContentAsFloat方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadElementContentAsFloat方法的具體用法?C# XmlTextReader.ReadElementContentAsFloat怎麽用?C# XmlTextReader.ReadElementContentAsFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementContentAsFloat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DeSerializeColor
//Copy code from SceneObjectSerializer.ProcessColor
public static System.Drawing.Color DeSerializeColor(string colorString)
{
StringReader sr = new StringReader(colorString);
XmlTextReader reader = new XmlTextReader(sr);
System.Drawing.Color color = new System.Drawing.Color();
reader.ReadStartElement("Color");
if (reader.Name == "R")
{
float r = reader.ReadElementContentAsFloat("R", String.Empty);
float g = reader.ReadElementContentAsFloat("G", String.Empty);
float b = reader.ReadElementContentAsFloat("B", String.Empty);
float a = reader.ReadElementContentAsFloat("A", String.Empty);
color = System.Drawing.Color.FromArgb((int)a, (int)r, (int)g, (int)b);
reader.ReadEndElement();
}
return color;
}
示例2: getLocation
/// <summary>
/// Gets the location of the IP address.
/// </summary>
/// <param name="ip">The ip.</param>
/// <returns></returns>
public static GeolocateResult getLocation(IPAddress ip)
{
Stream s = HttpRequest.get("http://api.ipinfodb.com/v2/ip_query.php?key=" + Configuration.singleton()["ipinfodbApiKey"] + "&ip=" + ip + "&timezone=false");
XmlTextReader xtr = new XmlTextReader(s);
GeolocateResult result = new GeolocateResult();
while (!xtr.EOF)
{
xtr.Read();
switch (xtr.Name)
{
case "Status":
result.status = xtr.ReadElementContentAsString();
break;
case "CountryCode":
result.countryCode = xtr.ReadElementContentAsString();
break;
case "CountryName":
result.country = xtr.ReadElementContentAsString();
break;
case "RegionCode":
result.regionCode = xtr.ReadElementContentAsString();
break;
case "RegionName":
result.region = xtr.ReadElementContentAsString();
break;
case "City":
result.city = xtr.ReadElementContentAsString();
break;
case "ZipPostalCode":
result.zipPostalCode = xtr.ReadElementContentAsString();
break;
case "Latitude":
result.latitude = xtr.ReadElementContentAsFloat();
break;
case "Longitude":
result.longitude = xtr.ReadElementContentAsFloat();
break;
}
}
return result;
}
示例3: ReadGrandSlamAbility
public static void ReadGrandSlamAbility(ref XmlTextReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == XMLPropNames.strRadius)
mGrandSlamRadius = reader.ReadElementContentAsFloat();
else if (reader.Name == XMLPropNames.strDamage)
mGrandSlamDamage = reader.ReadElementContentAsInt();
else if (reader.Name == XMLPropNames.strStunDuration)
mGrandSlamStunDuration = reader.ReadElementContentAsInt();
else if (reader.Name == XMLPropNames.strKnockBackSpeed)
mGrandSlamKnockBackSpeed = reader.ReadElementContentAsFloat();
}
else if (reader.NodeType == XmlNodeType.EndElement &&
reader.Name == XMLPropNames.strAbility)
break;
}
}
示例4: LoadBounty
public static void LoadBounty()
{
var multTable = new float[100];
var getting = false;
using (var reader = new XmlTextReader("formula.xml"))
{
while (reader.Read())
{
switch (reader.Name)
{
case "LM":
if (!getting)
break;
var low = int.Parse(reader.GetAttribute("lower"));
var high = int.Parse(reader.GetAttribute("upper"));
var value = reader.ReadElementContentAsFloat();
for (; low <= high; low++)
multTable[low] = value;
break;
case "FORMULA_TABLE":
if (reader.GetAttribute("id") == "GettingExpLM")
getting = true;
else if (reader.GetAttribute("id") == "GettingBountyLM")
reader.Close();
break;
}
}
}
for (var i = 1; i < 100; ++i)
{
var exp = (UInt32)((i * multTable[i] * 20.0f + .5));
GettingExpTable[i] = exp + Convert.ToUInt32((i - 1) * multTable[i] * 10.0 + 0.5f);
}
}
示例5: ReadSuperKnockBackAbility
public static void ReadSuperKnockBackAbility(ref XmlTextReader reader)
{
while (reader.Read())
{
if (reader.Name == XMLPropNames.strSpeed)
mSuperKnockBackSpeed = reader.ReadElementContentAsFloat();
else if (reader.Name == XMLPropNames.strDamage)
mSuperKnockBackDamage = reader.ReadElementContentAsInt();
else if (reader.NodeType == XmlNodeType.EndElement &&
reader.Name == XMLPropNames.strAbility)
break;
}
}
示例6: ProcessCollisionSoundVolume
private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
{
obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
}
示例7: ProcessShpLightIntensity
private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader)
{
shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
}
示例8: ReadQuaternion
static Quaternion ReadQuaternion(XmlTextReader reader, string name)
{
Quaternion quat = new Quaternion();
reader.ReadStartElement(name);
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.Name.ToLower())
{
case "x":
quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
break;
case "y":
quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
break;
case "z":
quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
break;
case "w":
quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
break;
}
}
reader.ReadEndElement();
return quat;
}
示例9: ProcessGravityModifier
private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
{
obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
}
示例10: ProcessFriction
private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader)
{
obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
}
示例11: ProcessShpLightFalloff
private void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader)
{
shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
}
示例12: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of invoice element, get out of here
if (reader.Name == "usage" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
DateTime dateVal;
switch (reader.Name)
{
case "amount":
Amount = reader.ReadElementContentAsInt();
break;
case "unit_amount_in_cents":
UnitAmountInCents = reader.ReadElementContentAsInt();
break;
case "merchant_tag":
MerchantTag = reader.ReadElementContentAsString();
break;
case "usage_percentage":
if (reader.GetAttribute("nil") == null)
{
UsagePercentage = reader.ReadElementContentAsFloat();
}
break;
case "recording_timestamp":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
RecordingTimestamp = dateVal;
break;
case "usage_timestamp":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
UsageTimestamp = dateVal;
break;
case "billed_at":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
BilledAt = dateVal;
break;
case "created_at":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
CreatedAt = dateVal;
break;
case "updated_at":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
UpdatedAt = dateVal;
break;
}
}
}
示例13: LoadPrim
public static PrimObject LoadPrim(XmlTextReader reader)
{
PrimObject obj = new PrimObject();
obj.Shape = new PrimObject.ShapeBlock();
obj.Inventory = new PrimObject.InventoryBlock();
reader.ReadStartElement("SceneObjectPart");
obj.CreatorIdentity = ReadUUID(reader, "CreatorID").ToString();
//warning CS0219: The variable `folderID' is assigned but its value is never used
//UUID folderID = ReadUUID(reader, "FolderID");
obj.Inventory.Serial = reader.ReadElementContentAsInt("InventorySerial", String.Empty);
// FIXME: Parse TaskInventory
obj.Inventory.Items = new PrimObject.InventoryBlock.ItemBlock[0];
reader.ReadInnerXml();
PrimFlags flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty);
obj.UsePhysics = (flags & PrimFlags.Physics) != 0;
obj.Phantom = (flags & PrimFlags.Phantom) != 0;
obj.DieAtEdge = (flags & PrimFlags.DieAtEdge) != 0;
obj.ReturnAtEdge = (flags & PrimFlags.ReturnAtEdge) != 0;
obj.Temporary = (flags & PrimFlags.Temporary) != 0;
obj.Sandbox = (flags & PrimFlags.Sandbox) != 0;
obj.ID = ReadUUID(reader, "UUID");
obj.LocalID = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
obj.Name = reader.ReadElementString("Name");
obj.Material = reader.ReadElementContentAsInt("Material", String.Empty);
reader.ReadInnerXml(); // RegionHandle
obj.RemoteScriptAccessPIN = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);
Vector3 groupPosition = ReadVector(reader, "GroupPosition");
Vector3 offsetPosition = ReadVector(reader, "OffsetPosition");
obj.Rotation = ReadQuaternion(reader, "RotationOffset");
obj.Velocity = ReadVector(reader, "Velocity");
//warning CS0219: The variable `rotationalVelocity' is assigned but its value is never used
//Vector3 rotationalVelocity = ReadVector(reader, "RotationalVelocity");
obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
obj.Acceleration = ReadVector(reader, "Acceleration");
obj.Description = reader.ReadElementString("Description");
reader.ReadStartElement("Color");
if (reader.Name == "R")
{
obj.TextColor.R = reader.ReadElementContentAsFloat("R", String.Empty);
obj.TextColor.G = reader.ReadElementContentAsFloat("G", String.Empty);
obj.TextColor.B = reader.ReadElementContentAsFloat("B", String.Empty);
obj.TextColor.A = reader.ReadElementContentAsFloat("A", String.Empty);
reader.ReadEndElement();
}
obj.Text = reader.ReadElementString("Text", String.Empty);
obj.SitName = reader.ReadElementString("SitName", String.Empty);
obj.TouchName = reader.ReadElementString("TouchName", String.Empty);
obj.LinkNumber = reader.ReadElementContentAsInt("LinkNum", String.Empty);
obj.ClickAction = reader.ReadElementContentAsInt("ClickAction", String.Empty);
reader.ReadStartElement("Shape");
obj.Shape.ProfileCurve = reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
Primitive.TextureEntry te = new Primitive.TextureEntry(teData, 0, teData.Length);
obj.Faces = FromTextureEntry(te);
reader.ReadInnerXml(); // ExtraParams
obj.Shape.PathBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty));
obj.Shape.PathCurve = reader.ReadElementContentAsInt("PathCurve", String.Empty);
obj.Shape.PathEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty));
obj.Shape.PathRadiusOffset = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty));
obj.Shape.PathRevolutions = Primitive.UnpackPathRevolutions((byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty));
obj.Shape.PathScaleX = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty));
obj.Shape.PathScaleY = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty));
obj.Shape.PathShearX = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearX", String.Empty));
obj.Shape.PathShearY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearY", String.Empty));
obj.Shape.PathSkew = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty));
obj.Shape.PathTaperX = Primitive.UnpackPathTaper((sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty));
obj.Shape.PathTaperY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty));
obj.Shape.PathTwist = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty));
obj.Shape.PathTwistBegin = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty));
obj.PCode = reader.ReadElementContentAsInt("PCode", String.Empty);
obj.Shape.ProfileBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty));
obj.Shape.ProfileEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty));
obj.Shape.ProfileHollow = Primitive.UnpackProfileHollow((ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty));
obj.Scale = ReadVector(reader, "Scale");
obj.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);
ProfileShape profileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), reader.ReadElementString("ProfileShape"));
HoleType holeType = (HoleType)Enum.Parse(typeof(HoleType), reader.ReadElementString("HollowShape"));
obj.Shape.ProfileCurve = (int)profileShape | (int)holeType;
UUID sculptTexture = ReadUUID(reader, "SculptTexture");
SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty);
if (sculptTexture != UUID.Zero)
{
obj.Sculpt = new PrimObject.SculptBlock();
obj.Sculpt.Texture = sculptTexture;
obj.Sculpt.Type = (int)sculptType;
}
//.........這裏部分代碼省略.........
示例14: LoadNeed
public static void LoadNeed()
{
var multTable = new float[100];
using (var reader = new XmlTextReader("formula.xml"))
{
while (reader.Read())
{
switch (reader.Name)
{
case "LM":
var low = int.Parse(reader.GetAttribute("lower"));
var high = int.Parse(reader.GetAttribute("upper"));
var value = reader.ReadElementContentAsFloat();
for (; low <= high; low++)
multTable[low] = value;
break;
case "FORMULA_TABLE":
if (reader.GetAttribute("id") != "NeedExpLM")
reader.Close();
break;
}
}
}
for (var i = 1; i < 100; ++i)
{
var exp = (UInt32)((double)(i * i) * multTable[i] * 100.0 + .5f);
NeedExpTable[i] = Convert.ToUInt32(multTable[i - 1] + 2 * exp);
}
}
示例15: ReadTornadoAbility
public static void ReadTornadoAbility(ref XmlTextReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == XMLPropNames.strSpeed)
mTornadoSpeed = reader.ReadElementContentAsFloat();
else if (reader.Name == XMLPropNames.strDuration)
mTornadoDuration = reader.ReadElementContentAsInt();
else if (reader.Name == XMLPropNames.strDegrees)
mTornadoDegrees = reader.ReadElementContentAsInt();
else if (reader.Name == XMLPropNames.strDamage)
mTornadoDamage = reader.ReadElementContentAsInt();
else if (reader.Name == XMLPropNames.strRange)
mTornadoRange = reader.ReadElementContentAsInt();
}
else if (reader.NodeType == XmlNodeType.EndElement &&
reader.Name == XMLPropNames.strAbility)
break;
}
}