本文整理汇总了C#中System.Xml.Linq.XAttribute类的典型用法代码示例。如果您正苦于以下问题:C# XAttribute类的具体用法?C# XAttribute怎么用?C# XAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XAttribute类属于System.Xml.Linq命名空间,在下文中一共展示了XAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetXMLDocument
public XDocument GetXMLDocument()
{
var myxml = new XDocument ();
var myele = new XElement ("myxmls");
var ele100 = new XElement ("myxml");
var idele100 = new XElement ("id", "100");
var nameele100 = new XElement ("name", "hoge");
var mailatt100 = new XAttribute ("mail", "[email protected]");
myele.Add (ele100);
ele100.Add (idele100);
nameele100.Add (mailatt100);
ele100.Add (nameele100);
var ele200 = new XElement ("myxml");
var idele200 = new XElement ("id", "200");
var nameele200 = new XElement ("name", "bar");
var mailatt200 = new XAttribute ("mail", "[email protected]");
myele.Add (ele200);
ele200.Add (idele200);
nameele200.Add (mailatt200);
ele200.Add (nameele200);
var ele300 = new XElement ("myxml");
var idele300 = new XElement ("id", "300");
var nameele300 = new XElement ("name", "foo");
var mailatt300 = new XAttribute ("mail", "[email protected]");
myele.Add (ele300);
ele300.Add (idele300);
nameele300.Add (mailatt300);
ele300.Add (nameele300);
myxml.Add (myele);
return myxml;
}
开发者ID:ahirugumi,项目名称:CSharp-Study,代码行数:35,代码来源:MyXMLClass.cs
示例2: CreateInstance
public static dynamic CreateInstance(XAttribute attribute)
{
Contract.Requires(attribute != null);
Contract.Ensures(Contract.Result<object>() != null);
return new DynamicXAttribute(attribute);
}
开发者ID:SergeyTeplyakov,项目名称:DynamicXml,代码行数:7,代码来源:DynamicXAttribute.cs
示例3: ExportNewTOC
protected override XElement ExportNewTOC()
{
List<XElement> list = new List<XElement>();
foreach (Node item in Model.Nodes)
{
XElement navPoint = ConvertToXElement(item);
if (navPoint != null)
{
list.Add(navPoint);
}
}
IEnumerable<XAttribute> spine = TOC.Attributes();
XElement navMap = null;
if (spine.Count()>0)
{
navMap = new XElement(ns + "spine", spine, list);
} else
{
//There is no spine elements
OpfDocument doc = new OpfDocument();
XAttribute TocRef = new XAttribute("toc", doc.GetNCXid());
navMap = new XElement(ns + "spine", TocRef, list);
}
OnSave(new ExportTocEventArgs(navMap));
//_NewTOC = navMap;
return navMap;
}
开发者ID:andresperezpayeras,项目名称:epubfixer,代码行数:32,代码来源:frmSpineEdit.cs
示例4: ParseSyncAttribute
public static long ParseSyncAttribute(XAttribute syncAttr)
{
if (syncAttr == null) throw new ArgumentNullException("syncAttr");
long res;
if (Int64.TryParse(syncAttr.Value, out res)) return res;
throw new XmlException(String.Format("Invalid synchronization attribute {0}", syncAttr));
}
开发者ID:Notalib,项目名称:DSync,代码行数:7,代码来源:XmlUtils.cs
示例5: ParseClipAttribute
public static TimeSpan ParseClipAttribute(XAttribute attr)
{
if (attr == null) throw new ArgumentNullException("attr");
var m = Regex.Match(attr.Value, @"^npt=(\d+(\.\d+)?)s$");
if (!m.Success) throw new ApplicationException("Clip attribute " + attr.Name + " has invalid value " + attr.Value);
return TimeSpan.FromSeconds(Double.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture));
}
开发者ID:Notalib,项目名称:DSync,代码行数:7,代码来源:DAISYUtils.cs
示例6: XMLConvert
public FrameDirection XMLConvert(FrameDirection v, XAttribute attr)
{
if (attr == null) return v;
FrameDirection f = FrameDirection.None;
f = f.Convert<FrameDirection>(attr);
return f;
}
开发者ID:Dazmo,项目名称:Terraria-Map-Editor,代码行数:7,代码来源:XMLBase.cs
示例7: SetWorkflowElement
void SetWorkflowElement(XDocument xDocument)
{
var workflowElement = xDocument.Descendants(LogicConstants.DefaultsLoader_Workflow).FirstOrDefault();
var defaultAttributeValue = new XAttribute(LogicConstants.DefaultsLoader_Workflow_Name, string.Empty);
if (null != workflowElement)
Defaults.Workflow = (workflowElement.Attribute(LogicConstants.DefaultsLoader_Workflow_Name) ?? defaultAttributeValue).Value;
}
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:7,代码来源:DefaultsLoader.cs
示例8: CandidateElimination
public CandidateElimination(string fileName) : base(fileName) {
//setup current hypothesis
XName name = "row";
_currentHypothesis = new XElement(name);
XAttribute newAttribute = null;
_attributeList = new List<XName>();
//initialize the most specific hypothesis set
foreach (XAttribute a in _dataSet.SampleRowElement.Attributes()) {
newAttribute = new XAttribute(a.Name, "");
_attributeList.Add(a.Name);
_currentHypothesis.Add(newAttribute);
}
_specificHypotheses = new List<XElement>();
_specificHypotheses.Add(new XElement(_currentHypothesis));
//setup current hypothesis
_currentHypothesis = new XElement(name);
//initialize the most specific hypothesis set
foreach (XAttribute a in _dataSet.SampleRowElement.Attributes()) {
newAttribute = new XAttribute(a.Name, "Q");
_currentHypothesis.Add(newAttribute);
}
_generalHypotheses = new List<XElement>();
_generalHypotheses.Add(new XElement(_currentHypothesis));
_targetConcept = _attributeList[_attributeList.Count - 1];
eliminateCandidates();
}
开发者ID:dfilarowski,项目名称:artificial-neural-network,代码行数:27,代码来源:CandidateElimination.cs
示例9: CheckForFiles
/// <summary>
/// Checks if the files exist.
/// </summary>
private void CheckForFiles()
{
if (!File.Exists(@"..\..\Resources\OptionsSettings.xml"))
{
if (MessageBox.Show("Couldn't find the xml file for the settings. \n Would you like to create a new with default settings?", "Error", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
XElement mouseElement = new XElement("mouse", "true");
XElement keyboardElement = new XElement("keyboard", "true");
XElement soundElement = new XElement("sound", "true");
XElement resolutionElement = new XElement("resolution", "1024x768");
XElement leftkeyElement = new XElement("leftkey", "Left");
XElement rightkeyElement = new XElement("rightkey", "Right");
XElement firekeyElement = new XElement("firekey", "Space");
XElement pausekeyElement = new XElement("pausekey", "P");
XElement difficultyElement = new XElement("difficulty", "1");
XElement mapElement = new XElement("map", "1");
XAttribute newAttribute = new XAttribute("id", 1);
XElement newElements = new XElement("option", newAttribute, mouseElement, keyboardElement, soundElement, resolutionElement, leftkeyElement, rightkeyElement, firekeyElement, pausekeyElement, difficultyElement, mapElement);
XElement newOptions = new XElement("Options", newElements);
XDocument newDocument = new XDocument(newOptions);
newDocument.Save(@"..\..\Resources\OptionsSettings.xml");
}
else
{
MapSelection returnToMap = new MapSelection();
returnToMap.Show();
Close();
}
}
// If the OptionsSettings xml doesn't exist, then send message.
}
开发者ID:pezs89,项目名称:BrickBreaker_Wpf_old,代码行数:34,代码来源:DifficultySelection.xaml.cs
示例10: GetXAttributeValue
/// <summary>
/// Get XAttribute Value
/// </summary>
/// <param name="XAttribute">xAttribute</param>
/// <returns>Value</returns>
public static string GetXAttributeValue(XAttribute xAttribute)
{
if (xAttribute == null)
return string.Empty;
return xAttribute.Value;
}
开发者ID:uwitec,项目名称:O2O,代码行数:12,代码来源:StringExtensions.cs
示例11: LogResult
private static void LogResult(Type result, XAttribute attr)
{
if (result == null)
_log.Warn("Unable to load type from attribute named '" + attr.Name + "' with value '" + attr.Value + "'.");
else if (_log.IsDebugEnabled)
_log.Debug("Loaded type '" + result + "' from attribute named '" + attr.Name + "'.");
}
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:ActualTypeFromAttributeTypeConverter.cs
示例12: GetOffset
private Offset GetOffset(XAttribute offsetAttribute, string sourceFilePath, uint? lineNumber)
{
if (offsetAttribute == null || !_fileSystem.File.Exists(sourceFilePath))
{
return null;
}
string start = null;
string end = null;
var dashIndex = offsetAttribute.Value.IndexOf("-", StringComparison.OrdinalIgnoreCase);
if (dashIndex > -1)
{
start = offsetAttribute.Value.Substring(0, dashIndex);
end = offsetAttribute.Value.Substring(dashIndex + 1);
}
var lines = _fileSystem.File.ReadLines(sourceFilePath);
var issueLineOffset = lines.Take((int)lineNumber.Value - 1).Sum(line => line.Length);
return new Offset
{
Start = string.IsNullOrWhiteSpace(start) ? null : (uint?)(int.Parse(start) - (issueLineOffset + lineNumber.Value - 1)),
End = string.IsNullOrWhiteSpace(end) ? null : (uint?)(int.Parse(end) - (issueLineOffset + lineNumber.Value - 1))
};
}
开发者ID:roh85,项目名称:vika,代码行数:26,代码来源:InspectCodeParser.cs
示例13: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change any bogus non-owning footnote links in the vernacular (but NOT in the BT)
/// to be owning links
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000034);
foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
{
XElement para = XElement.Parse(scrTxtPara.Xml);
XElement contents = para.Element("Contents");
if (contents == null)
continue;
XElement str = contents.Element("Str");
if (str == null)
continue;
foreach (XElement run in str.Elements("Run"))
{
XAttribute linkAttr = run.Attribute("link");
if (linkAttr == null)
continue; // Run doesn't contain an unowned hot-link
XAttribute ownedLinkAttr = new XAttribute("ownlink", linkAttr.Value);
run.Add(ownedLinkAttr);
linkAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, scrTxtPara, para.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:DataMigration7000035.cs
示例14: AddAnnotations
protected virtual void AddAnnotations(AnnotatableElementClipboardFormat clipboardFormat, EFElement element)
{
foreach (var t in clipboardFormat.AdditionalAttributes)
{
var name = t.Item1;
var value = t.Item2;
var xn = XName.Get(name);
var xa = new XAttribute(xn, value);
element.XElement.Add(xa);
}
foreach (var s in clipboardFormat.AdditionalElements)
{
try
{
var d = XDocument.Parse(s, LoadOptions.PreserveWhitespace);
var xe = d.Root;
xe.Remove();
element.XElement.Add(xe);
}
catch (XmlException)
{
// ignore an XmlException. There was probalby a problem parsing.
}
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:CopyAnnotatableElementCommand.cs
示例15: AddAttribute
public static XElement AddAttribute(this XElement element, string name, object value)
{
var attribute = new XAttribute(name, value);
element.Add(attribute);
return element;
}
开发者ID:kkalinowski,项目名称:lib12,代码行数:7,代码来源:XmlExtensions.cs
示例16: LoadClues
// this code is modfied code from the following tutorial
// http://blogs.msdn.com/b/mingfeis_code_block/archive/2010/10/03/windows-phone-7-how-to-store-data-and-pass-data-between-pages.aspx
public void LoadClues()
{
EnterClues();
string elementNumber;
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
for (int i=0; i < noClues; i++)
{
elementNumber = "number"+clueId[i].ToString();
XDocument _doc = new XDocument();
XElement _clue = new XElement(elementNumber);
XAttribute _clueId = new XAttribute("clueId", clueId[i]);
XAttribute _clueText = new XAttribute("clueText", clueText[i]);
XAttribute _barcodeRef = new XAttribute("barcodeRef", barcodeRef[i]);
XAttribute _location = new XAttribute("location", location[i]);
XAttribute _locInfo = new XAttribute("locInfo", locInfo[i]);
XAttribute _latitude = new XAttribute("latitude", latitude[i]);
XAttribute _longitude = new XAttribute("longitude", longitude[i]);
_clue.Add(_clueId, _clueText, _barcodeRef, _location, _locInfo, _latitude, _longitude);
_doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), _clue);
IsolatedStorageFileStream memory = new IsolatedStorageFileStream(elementNumber + ".clue", System.IO.FileMode.Create, storage);
System.IO.StreamWriter file = new System.IO.StreamWriter(memory);
_doc.Save(file);
file.Dispose();
memory.Dispose();
}
}
}
开发者ID:borgidiom,项目名称:UC-Scanager-Hunt,代码行数:36,代码来源:Clues.cs
示例17: XAttribute
public XAttribute(XAttribute other)
{
if (other == null)
throw new ArgumentNullException ("other");
name = other.name;
value = other.value;
}
开发者ID:nicocrm,项目名称:DotNetSDataClient,代码行数:7,代码来源:XAttribute.cs
示例18: ToEntity
public BodyType ToEntity(XAttribute xAttribute)
{
if (xAttribute == null)
{
throw new ArgumentNullException("xAttribute");
}
BodyType entity;
switch (xAttribute.Value)
{
case STR_Dynamic:
entity = BodyType.Dynamic;
break;
case STR_Kinematic:
entity = BodyType.Kinematic;
break;
case STR_Static:
entity = BodyType.Static;
break;
default:
throw new NotSupportedException(String.Format("BodyType '{0}' is not supported.", xAttribute.Value));
}
return entity;
}
开发者ID:neaket,项目名称:Dragonfly,代码行数:25,代码来源:BodyTypeTransformer.cs
示例19: GetExceptionMessage
/// <summary>
/// Gets the message text including line info for exceptions that occur when parsing XML.
/// </summary>
/// <param name="attribute">The current attribute.</param>
/// <param name="format">The format string.</param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <returns>The exception message including line info.</returns>
public static string GetExceptionMessage(XAttribute attribute, string format, params object[] args)
{
if (attribute == null)
throw new ArgumentNullException("attribute");
var cultureInfo = CultureInfo.InvariantCulture;
string message = string.Format(cultureInfo, format, args);
// Append line info, if available.
var lineInfo = (IXmlLineInfo)attribute;
if (lineInfo.HasLineInfo())
{
message += string.Format(
cultureInfo,
" (Attribute: \"{0}\", Line: {1}, Position: {2})",
attribute.Name, lineInfo.LineNumber, lineInfo.LinePosition);
}
else
{
message += string.Format(
cultureInfo,
" (Attribute: \"{0}\")",
attribute.Name);
}
return message;
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:34,代码来源:XmlHelper.cs
示例20: AddNewSubElement
public void AddNewSubElement(DateTime date, decimal totalSum)
{
XAttribute dateAttribute = new XAttribute("date", date.ToString("dd-MMM-yyyy", Culture));
XAttribute sumAttribute = new XAttribute("total-sum", totalSum);
XElement newElement = new XElement("summary",dateAttribute,sumAttribute);
this.SubRootElement.Add(newElement);
}
开发者ID:kaloyan-gospodinov,项目名称:ParadiseSuperMarket,代码行数:7,代码来源:XMLWriter.cs
注:本文中的System.Xml.Linq.XAttribute类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论