本文整理汇总了C#中System.Xml.Linq.XNamespace类的典型用法代码示例。如果您正苦于以下问题:C# XNamespace类的具体用法?C# XNamespace怎么用?C# XNamespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XNamespace类属于System.Xml.Linq命名空间,在下文中一共展示了XNamespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGpx_1_1_Route
private Route CreateGpx_1_1_Route(XDocument routeDocument, XNamespace ns)
{
XElement track = routeDocument.Root.Element(ns + "trk");
string name = track.Element(ns + "name").Value;
Route newRoute = new Route {Name = name, DateCreated = DateTime.Now};
List<RoutePoint> routePoints = new List<RoutePoint>();
var trackPoints = track.Descendants(ns + "trkpt");
foreach (XElement trackPoint in trackPoints)
{
RoutePoint routePoint = new RoutePoint();
routePoint.Latitude = double.Parse(trackPoint.Attribute("lat").Value);
routePoint.Longitude = double.Parse(trackPoint.Attribute("lon").Value);
routePoint.Elevation = double.Parse(trackPoint.Element(ns + "ele").Value);
routePoint.TimeRecorded = DateTime.Parse(trackPoint.Element(ns + "time").Value);
routePoints.Add(routePoint);
}
routePoints = routePoints.OrderBy(rp => rp.TimeRecorded).ToList();
int index = 0;
foreach (RoutePoint routePoint in routePoints)
{
routePoint.SequenceIndex = index;
index++;
}
newRoute.RoutePoints = routePoints;
newRoute.Distance = CalculateDistance(newRoute.RoutePoints);
Tuple<double, double> ascentDescent = CalculateAscentDescent(newRoute.RoutePoints);
newRoute.TotalAscent += ascentDescent.Item1;
newRoute.TotalDescent += ascentDescent.Item2;
return newRoute;
}
示例2: GetMsTasks
public static ObservableCollection<GanttTask> GetMsTasks(XDocument xDocument, XNamespace xnamespace)
{
var allTasks = new ObservableCollection<GanttTask>();
var task = xDocument.Root.Elements(xnamespace + "Tasks");
var tasks = task.Elements(xnamespace + "Task");
tasks.FirstOrDefault().Remove();
PrepareXMLTasksForConvertingToGanttTasks(xnamespace, tasks);
GenerateAllGanttTasks(tasks, xnamespace);
foreach (var t in taskIdToGanttTask)
{
var gtask = t.Value.Item1;
SetUpRelationsToGanttTask(t.Key, t.Value, gtask);
var oNumber = t.Value.Item2;
if (oNumber != null)
{
SetUpChildrenToGanttTask(t.Value, gtask);
}
if (IsRootTask(oNumber))
{
allTasks.Add(gtask);
}
}
return allTasks;
}
示例3: CorrelationKey
private CorrelationKey(string keyString, XNamespace provider) : base(GenerateKey(keyString), dictionary)
{
Dictionary<XName, InstanceValue> dictionary = new Dictionary<XName, InstanceValue>(2);
dictionary.Add(provider.GetName("KeyString"), new InstanceValue(keyString, InstanceValueOptions.Optional));
dictionary.Add(WorkflowNamespace.KeyProvider, new InstanceValue(provider.NamespaceName, InstanceValueOptions.Optional));
this.KeyString = keyString;
}
示例4: UPnPService
public UPnPService(UPnPDevice parent, XNamespace ns, XElement service)
{
ParentDevice = parent;
ServiceType = service.Elements().First(e => e.Name.LocalName == "serviceType").Value;
ServiceID = service.Elements().First(e => e.Name.LocalName == "serviceId").Value;
ControlUrl = service.Elements().First(e => e.Name.LocalName == "controlURL").Value;
}
示例5: UpdateXElement
internal static void UpdateXElement(this XElement element, SettingsInfo settings, XNamespace ns)
{
element.Attribute("ID").Value = settings.Id.ToString();
element.Attribute("processorRef").Value = settings.Processor.Id.ToString();
element.Element(ns + "name").Value = settings.Name;
element.Element(ns + "serialPortSettings").UpdateXElement(settings.SerialPortSettings, ns);
}
示例6: CreateElement
/// <summary>
///
/// </summary>
/// <param name="xmlns"></param>
/// <returns></returns>
public override XElement CreateElement(XNamespace xmlns)
{
return new XElement(xmlns + "channel")
.AddElement(xmlns + "title", Title)
.AddElement(xmlns + "link", Link)
.AddElement(xmlns + "description", Description);
}
示例7: EpubSummaryParser
public EpubSummaryParser(Stream source)
{
_zip = ZipContainer.Unzip(source);
XDocument xmlDocument = _zip.GetFileStream("META-INF/container.xml").GetXmlDocument();
XElement root = xmlDocument.Root;
if (root == null)
throw new DataException(InvalidEpubMetaInfo);
XAttribute attribute = root.Attribute("xmlns");
XNamespace xmlns = (attribute != null) ? XNamespace.Get(attribute.Value) : XNamespace.None;
XAttribute fullPath = xmlDocument.Descendants(xmlns + "rootfile").First().Attribute("full-path");
if (fullPath == null)
throw new DataException(InvalidEpubMetaInfo);
string path = fullPath.Value;
_opfPath = path;
_opf = _zip.GetFileStream(path).GetXmlDocument();
_opfRoot = _opf.Root;
if (_opfRoot == null)
throw new DataException(InvalidEpubMetaInfo);
_oebps = GetPath(path);
_opfns = XNamespace.Get("http://www.idpf.org/2007/opf");
_opfdc = XNamespace.Get("http://purl.org/dc/elements/1.1/");
_coverHelper = new EpubCoverHelper(_zip, _opfns, _opfRoot, _oebps);
}
示例8: XElementFromElastic
public static XElement XElementFromElastic(ElasticObject elastic, XNamespace nameSpace = null)
{
// we default to empty namespace
nameSpace = nameSpace ?? string.Empty;
var exp = new XElement(nameSpace + elastic.InternalName);
foreach (var a in elastic.Attributes.Where(a => a.Value.InternalValue != null))
{
// if we have xmlns attribute add it like XNamespace instead of regular attribute
if (a.Key.Equals("xmlns", StringComparison.InvariantCultureIgnoreCase))
{
nameSpace = a.Value.InternalValue.ToString();
exp.Name = nameSpace.GetName(exp.Name.LocalName);
}
else
{
exp.Add(new XAttribute(a.Key, a.Value.InternalValue));
}
}
if (elastic.InternalContent is string)
{
exp.Add(new XText(elastic.InternalContent as string));
}
foreach (var child in elastic.Elements.Select(c => XElementFromElastic(c, nameSpace)))
{
exp.Add(child);
}
return exp;
}
示例9: ActiveForm
//private String Method;
//private String ApiTimeStamp;
public ActiveForm(XNamespace ns, String ApiKey, String SecretApiKey)
{
this.NameSpace = ns;
this.ApiKey = ApiKey;
this.SecretApiKey = SecretApiKey;
BaseUrl = "https://api.activeforms.com/4.0/";
}
示例10: SchemaInfo
internal SchemaInfo(IFormChannelIdentifier channelIdentifier, XNamespace namespaceObj, XDocument schema)
{
this.ChannelIdentifier = channelIdentifier;
this.Namespace = namespaceObj;
this.Schema = schema;
this.SchemaType = FormSchemaType.Uicontrols;
}
示例11: GetAvailability
public static string GetAvailability(this XElement xElement, XNamespace ns)
{
return xElement.Element(ns + "Offers") == null ? string.Empty :
xElement.Element(ns + "Offers").Element(ns + "Offer") == null ? string.Empty :
xElement.Element(ns + "Offers").Element(ns + "Offer").Element(ns + "OfferListing") == null ? string.Empty :
xElement.Element(ns + "Offers").Element(ns + "Offer").Element(ns + "OfferListing").ElementValue("Availability", ns);
}
示例12: XNamespace
static XNamespace ()
{
nstable = new Dictionary<string, XNamespace> ();
blank = Get (String.Empty);
xml = Get ("http://www.w3.org/XML/1998/namespace");
xmlns = Get ("http://www.w3.org/2000/xmlns/");
}
示例13: HtmlImageResultFormatter
public HtmlImageResultFormatter(Configuration configuration, ITestResults results, HtmlResourceSet htmlResourceSet)
{
this.configuration = configuration;
this.results = results;
this.htmlResourceSet = htmlResourceSet;
this.xmlns = HtmlNamespace.Xhtml;
}
示例14: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
if (!Directory.Exists(Utility.RootFolder))
{
Directory.CreateDirectory(Utility.RootFolder);
}
if (!Directory.Exists(Utility.TempFolder))
{
Directory.CreateDirectory(Utility.TempFolder);
}
_mXmlNs = Utility.NS;
_mOnGenerator = new OneNoteGenerator(Utility.RootFolder);
//Get Id of the test notebook so we chould retrieve generated content
//KindercareFormatConverter will create notebookName as Kindercare
_mNotebookId = _mOnGenerator.CreateNotebook(NotebookName);
var word = new Application();
var doc = word.Application.Documents.Add();
//add pages to doc
for (int i = 1; i < DocPageTitles.Count; i++)
{
doc.Content.Text += DocPageTitles[i];
doc.Words.Last.InsertBreak(WdBreakType.wdPageBreak);
}
var filePath = TestDocPath as object;
doc.SaveAs(ref filePath);
((_WordDocument)doc).Close();
((_WordApplication)word).Quit();
}
示例15: OpenXmlSdkDocumentProperties
//TODO Use PackageProperties.
internal OpenXmlSdkDocumentProperties(OpenXmlSdkTextDocument document)
{
if (document == null)
{
throw new ArgumentNullException("document");
}
_document = document;
_xCorePropertiesNamespace = CorePropertiesSchema;
_xDublinCoreNamespace = DublinCoreSchema;
_xDCTermsNamespace = DublinCoreTermsSchema;
_xCreatedElementName = _xDCTermsNamespace + "created";
_xCreatorElementName = _xDublinCoreNamespace + "creator";
_xDescriptionElementName = _xDublinCoreNamespace + "description";
_xKeywordsElementName = _xCorePropertiesNamespace + "keywords";
_xLanguageElementName = _xDublinCoreNamespace + "language";
_xLastModifiedByElementName = _xCorePropertiesNamespace + "lastModifiedBy";
_xLastPrintedElementName = _xCorePropertiesNamespace + "lastPrinted";
_xModifiedElementName = _xDCTermsNamespace + "modified";
_xRevisionElementName = _xCorePropertiesNamespace + "revision";
_xSubjectElementName = _xDublinCoreNamespace + "subject";
_xTitleElementName = _xDublinCoreNamespace + "title";
using (Stream stream = document.InnerObject.CoreFilePropertiesPart.GetStream())
{
_xDocument = XDocument.Load(stream);
}
}