本文整理汇总了C#中XmlReader.ReadOuterXml方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadOuterXml方法的具体用法?C# XmlReader.ReadOuterXml怎么用?C# XmlReader.ReadOuterXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadOuterXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateElementsForTileMap
private void CreateElementsForTileMap(XmlReader tilemap)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(tilemap.ReadOuterXml());
XmlNode imageNode = doc.ChildNodes[0];
float scaleInverse = Futile.resourceScaleInverse;
//XMLNode imageNode = tilemap.children[0] as XMLNode;
string sourceString = imageNode.Attributes["name"].Value.ToString();
tileWidth = Convert.ToInt32(imageNode.Attributes["tilewidth"].Value.ToString());
tileHeight = Convert.ToInt32(imageNode.Attributes["tileheight"].Value.ToString());
int firstGID = Convert.ToInt32(imageNode.Attributes["firstgid"].Value.ToString());
imageNode = imageNode.ChildNodes[0];
int sourceWidth = Convert.ToInt32(imageNode.Attributes["width"].Value.ToString());
int sourceHeight = Convert.ToInt32(imageNode.Attributes["height"].Value.ToString());
int numRows = (sourceHeight / tileHeight);
int numCols = (sourceWidth / tileWidth);
int totalTiles = numRows * numCols;
// load tileset image
Futile.atlasManager.LoadImage("Atlases/" + sourceString);
FAtlasElement origElement = Futile.atlasManager.GetElementWithName("Atlases/" + sourceString);
Vector2 _textureSize = origElement.atlas.textureSize;
int gid = firstGID;
for(int i = 0; i < totalTiles; i++) {
FAtlasElement element = new FAtlasElement();
string name = "tile_" + gid;
element.name = name;
element.isTrimmed = origElement.isTrimmed;
element.atlas = origElement.atlas;
element.atlasIndex = i;
//the uv coordinate rectangle within the atlas
float frameX = (origElement.uvRect.x * _textureSize.x) - origElement.sourceRect.x + ((i % numCols) * tileWidth);
float frameY = (-1 * ((origElement.uvRect.y * _textureSize.y) - _textureSize.y + origElement.sourceRect.height)) - origElement.sourceRect.y + ((i / numRows) * tileHeight);
float frameW = tileWidth;
float frameH = tileHeight;
Rect uvRect = new Rect
(
frameX/_textureSize.x,
((_textureSize.y - frameY - frameH)/_textureSize.y),
frameW/_textureSize.x,
frameH/_textureSize.y
);
element.uvRect = uvRect;
element.uvTopLeft.Set(uvRect.xMin,uvRect.yMax);
element.uvTopRight.Set(uvRect.xMax,uvRect.yMax);
element.uvBottomRight.Set(uvRect.xMax,uvRect.yMin);
element.uvBottomLeft.Set(uvRect.xMin,uvRect.yMin);
//the source size is the untrimmed size
element.sourcePixelSize.x = tileWidth;
element.sourcePixelSize.y = tileHeight;
element.sourceSize.x = element.sourcePixelSize.x * scaleInverse;
element.sourceSize.y = element.sourcePixelSize.y * scaleInverse;
//this rect is the trimmed size and position relative to the untrimmed rect
float rectX = origElement.sourceRect.x;
float rectY = origElement.sourceRect.y;
float rectW = tileWidth * scaleInverse;
float rectH = tileHeight * scaleInverse;
element.sourceRect = new Rect(rectX,rectY,rectW,rectH);
_allElementsByName.Add(element.name, element);
gid++;
}
}
示例2: Bar
private void Bar(XmlReader reader)
{
reader.Read();
string foo = reader.ReadOuterXml();
CError.Compare(foo, "<device xmlns=\"http://www.test.com/\"> <thing>1</thing> </device>",
"<device xmlns=\"http://www.test.com/\"><thing>1</thing></device>", "mismatch");
}
示例3: XmlDocument
void IXmlSerializable.ReadXml (XmlReader reader)
{
XmlDocument doc = new XmlDocument ();
string str = reader.ReadString ();
try {
doc.LoadXml (str);
} catch {
doc.LoadXml (reader.ReadOuterXml ());
}
mFuncXmlNode = (XmlNode) (doc.DocumentElement);
}