本文整理汇总了C#中System.Xml.XmlElement.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.GetAttribute方法的具体用法?C# XmlElement.GetAttribute怎么用?C# XmlElement.GetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemGroup
public ItemGroup (XmlElement elem, ClassDescriptor klass)
{
declaringType = klass;
label = elem.GetAttribute ("label");
name = elem.GetAttribute ("name");
XmlNodeList nodes = elem.SelectNodes ("property | command | signal");
for (int i = 0; i < nodes.Count; i++) {
XmlElement item = (XmlElement)nodes[i];
string refname = item.GetAttribute ("ref");
if (refname != "") {
if (refname.IndexOf ('.') != -1) {
ItemDescriptor desc = (ItemDescriptor) Registry.LookupItem (refname);
items [desc.Name] = desc;
} else {
ItemDescriptor desc = (ItemDescriptor) klass[refname];
items [desc.Name] = desc;
}
continue;
}
ItemDescriptor idesc = klass.CreateItemDescriptor ((XmlElement)item, this);
if (idesc != null)
items [idesc.Name] = idesc;
}
}
示例2: ProcessIndex
private void ProcessIndex(XmlElement indexElement, IDictionary<string, Table> tables)
{
var tableName = indexElement.GetAttribute("table");
var columnNames = CollectionUtils.Map(indexElement.GetAttribute("columns").Split(','), (string s) => s.Trim());
if (string.IsNullOrEmpty(tableName) || columnNames.Count <= 0)
return;
// get table by name
Table table;
if (!tables.TryGetValue(tableName, out table))
throw new DdlException(
string.Format("An additional index refers to a table ({0}) that does not exist.", table.Name),
null);
// get columns by name
var columns = new List<Column>();
foreach (var columnName in columnNames)
{
var column = CollectionUtils.SelectFirst(table.ColumnIterator, col => col.Name == columnName);
// bug #6994: could be that the index file specifies a column name that does not actually exist, so we need to check for nulls
if (column == null)
throw new DdlException(
string.Format("An additional index on table {0} refers to a column ({1}) that does not exist.", table.Name, columnName),
null);
columns.Add(column);
}
// create index
CreateIndex(table, columns);
}
示例3: CutElement
/// <summary>
/// Erzeugt ein neues Schnittelement.
/// </summary>
/// <param name="element">Die Rohdaten aus der Projektdatei.</param>
public CutElement( XmlElement element )
{
// Load all
VideoIndex = int.Parse( element.GetAttribute( "refVideoFile" ) );
Start = long.Parse( element.GetAttribute( "StartPosition" ) );
End = long.Parse( element.GetAttribute( "EndPosition" ) );
}
示例4: SolutionItemDescriptor
protected SolutionItemDescriptor (XmlElement element)
{
name = element.GetAttribute ("name");
// relativePath = element.GetAttribute ("directory");
typeName = element.GetAttribute ("type");
template = element;
}
示例5: LoadConditionFromXml
public override void LoadConditionFromXml(ICondition condition, XmlElement conditionElement)
{
var c = condition as TimeOfDayCondition;
c.StartTime = TimeSpan.Parse(conditionElement.GetAttribute("start"));
c.EndTime = TimeSpan.Parse(conditionElement.GetAttribute("end"));
c.ShouldBeWithin = bool.Parse(conditionElement.GetAttribute("shouldBeWithin"));
}
示例6: LoadNotificationFromXml
public override void LoadNotificationFromXml(INotification notification, XmlElement notificationElement)
{
var n = notification as PopupNotification;
n.NotificationText = notificationElement.GetAttribute("notificationText");
n.Caption = notificationElement.GetAttribute("caption");
n.Icon = (ToolTipIcon)Enum.Parse(typeof(ToolTipIcon), notificationElement.GetAttribute("icon"));
}
示例7: fromXML
public static Level fromXML(XmlElement node, Game gameref, String campaignPath)
{
Level newLvl = new Level();
newLvl.number = int.Parse(node.GetElementsByTagName("number")[0].FirstChild.Value);
if (node.HasAttribute("autoProgress"))
newLvl.autoProgress = bool.Parse(node.GetAttribute("autoProgress"));
newLvl.name = node.GetAttribute("name");
foreach (string singleAdj in node.GetElementsByTagName("adj")[0].FirstChild.Value.Split(','))
newLvl.adjacent.Add(Int32.Parse(singleAdj));
XmlNodeList list = node.GetElementsByTagName("prereq");
if (list.Count > 0 && list[0].FirstChild != null)
foreach (string singlePrereq in node.GetElementsByTagName("prereq")[0].FirstChild.Value.Split(','))
newLvl.prereq.Add(Int32.Parse(singlePrereq));
newLvl.loc = XMLUtil.fromXMLVector2(node.GetElementsByTagName("location")[0]);
if (node.GetElementsByTagName("horizonPath").Count > 0)
newLvl.horizon = node.GetElementsByTagName("horizonPath")[0].FirstChild.Value;
if (node.GetElementsByTagName("items").Count > 0)
foreach (XmlElement item in node.GetElementsByTagName("items")[0].ChildNodes)
newLvl.items.Add(GameItem.fromXML(item));
if (node.GetElementsByTagName("spawns").Count > 0)
foreach (XmlElement item in node.GetElementsByTagName("spawns")[0].ChildNodes)
newLvl.spawns.Add(SpawnPoint.fromXML(item));
/*XmlNodeList storyNodes = node.GetElementsByTagName("story");
if (storyNodes.Count > 0 && storyNodes[0].ChildNodes.Count > 0)
foreach (XmlNode item in storyNodes[0].ChildNodes)
newLvl.storyElements.Add(StoryElement.fromXML(item, gameref));*/
newLvl.levelLength = int.Parse(node.GetAttribute("length"));
foreach (XmlElement graphic in node.GetElementsByTagName("graphic"))
newLvl.backgroundItems.Add(BackgroundItemStruct.fromXML(graphic));
return newLvl;
}
示例8: ProcessStatement
protected bool ProcessStatement(XmlElement element, IXmlProcessorEngine engine)
{
if (!element.HasAttribute(DefinedAttrName) &&
!element.HasAttribute(NotDefinedAttrName))
{
throw new XmlProcessorException("'if' elements expects a non empty defined or not-defined attribute");
}
if (element.HasAttribute(DefinedAttrName) &&
element.HasAttribute(NotDefinedAttrName))
{
throw new XmlProcessorException("'if' elements expects a non empty defined or not-defined attribute");
}
bool processContents = false;
if (element.HasAttribute(DefinedAttrName))
{
processContents = engine.HasFlag(element.GetAttribute(DefinedAttrName));
}
else
{
processContents = !engine.HasFlag(element.GetAttribute(NotDefinedAttrName));
}
return processContents;
}
示例9: Parse
public static new Inform Parse(XmlElement inform)
{
if (inform == null)
{
throw new Exception("parameter can't be null!");
}
string type = string.Empty;
string operation = string.Empty;
if (inform.HasAttribute("Type"))
{
type = inform.GetAttribute("Type");
}
else
{
throw new Exception("load hasn't type attribute!");
}
if (inform.HasAttribute("Operation"))
{
operation = inform.GetAttribute("Operation");
}
else
{
throw new Exception("parameter hasn't Operation attribute!");
}
Operation enumOperation = (Operation)Enum.Parse(typeof(Operation), operation);
Inform result = new Inform(enumOperation, inform.Name, type, inform.InnerText);
return result;
}
示例10: Field
public Field(XmlElement elField)
{
String typeName = elField.GetAttribute("type");
string lbStr = elField.GetAttribute("lower-bound");
string ubStr = elField.GetAttribute("upper-bound");
string fieldTypeStr = elField.GetAttribute("fieldtype");
string valueStr = elField.InnerText;
type = ClassTypes.GetType(typeName);
fieldType = ParseTypeString(fieldTypeStr);
if (!Formal)
{
value = ParseFieldValue(type, valueStr);
}
else
{
if (lbStr != null)
{
lowerBound = (IComparable) ParseFieldValue(type, lbStr);
}
if (ubStr != null)
{
upperBound = (IComparable) ParseFieldValue(type, ubStr);
}
}
}
示例11: ClientInfoVariable
internal ClientInfoVariable(XmlElement varElement)
{
ClientInfoVariableEditor e = new ClientInfoVariableEditor();
e.VariableName = varElement.GetAttribute("Name");
e.VariableKey = varElement.GetAttribute("Key");
this.Editor = e;
}
示例12: PropertyConfigurationType
/// <summary>
/// Initializes a new instance of the <see cref="PropertyConfigurationType"/> class.
/// </summary>
/// <param name="el">The el.</param>
public PropertyConfigurationType(XmlElement el)
{
Name = el.GetAttribute(NameAttr);
Value = el.GetAttribute(ValueAttr);
Ref = el.GetAttribute(RefAttr);
Type = el.GetAttribute(TypeAttr);
}
示例13: CecilPropertyDescriptor
public CecilPropertyDescriptor (CecilWidgetLibrary lib, XmlElement elem, Stetic.ItemGroup group, Stetic.ClassDescriptor klass, PropertyDefinition pinfo): base (elem, group, klass)
{
string tname;
if (pinfo != null) {
name = pinfo.Name;
tname = pinfo.PropertyType.FullName;
canWrite = pinfo.SetMethod != null;
}
else {
name = elem.GetAttribute ("name");
tname = elem.GetAttribute ("type");
canWrite = elem.Attributes ["canWrite"] == null;
}
Load (elem);
type = Stetic.Registry.GetType (tname, false);
if (type == null) {
Console.WriteLine ("Could not find type: " + tname);
type = typeof(string);
}
if (type.IsValueType)
initialValue = Activator.CreateInstance (type);
// Consider all properties runtime-properties, since they have been created
// from class properties.
isRuntimeProperty = true;
if (pinfo != null)
SaveCecilXml (elem);
}
示例14: GetAddinTextFromUrl
protected string GetAddinTextFromUrl (XmlElement addin, string addinId, string fileId)
{
if (addin == null)
return "<html>Add-in not found: " + addinId + "</html>";
StringBuilder sb = new StringBuilder ("<html>");
sb.Append ("<h1>").Append (addin.GetAttribute ("name")).Append ("</h1>");
XmlElement docs = (XmlElement) addin.SelectSingleNode ("Description");
if (docs != null)
sb.Append (docs.InnerText);
sb.Append ("<p><table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">");
sb.AppendFormat ("<tr><td><b>Id</b></td><td>{0}</td></tr>", addin.GetAttribute ("addinId"));
sb.AppendFormat ("<tr><td><b>Namespace</b></td><td>{0}</td></tr>", addin.GetAttribute ("namespace"));
sb.AppendFormat ("<tr><td><b>Version</b></td><td>{0}</td></tr>", addin.GetAttribute ("version"));
sb.Append ("</table></p>");
sb.Append ("<p><b>Extension Points</b>:</p>");
sb.Append ("<ul>");
foreach (XmlElement ep in addin.SelectNodes ("ExtensionPoint")) {
sb.AppendFormat ("<li><a href=\"extension-point:{0}#{1}#{2}\">{3}</li>", fileId, addinId, ep.GetAttribute ("path"), ep.GetAttribute ("name"));
}
sb.Append ("</ul>");
sb.Append ("</html>");
return sb.ToString ();
}
示例15: RuntimeLicensedProduct
internal RuntimeLicensedProduct(XmlElement el)
{
_assemblyName = el.GetAttribute("AssemblyName");
_version = el.GetAttribute("Version");
_licenseUrl = el.GetAttribute("LicenseUrl");
try
{
_expirationDate = DateTime.Parse(el.GetAttribute("ExpirationDate"));
}
catch
{
_expirationDate = DateTime.MaxValue;
}
try
{
_type = (LicenseType)Enum.Parse(typeof(LicenseType), el.GetAttribute("Type"));
}
catch
{
_type = LicenseType.Evaluation;
}
try
{
_scope = (LicenseScope)Enum.Parse(typeof(LicenseScope), el.GetAttribute("Scope"));
}
catch
{
_scope = LicenseScope.WebSite;
}
}