• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Linq.XNamespace类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Xml.Linq.XNamespace的典型用法代码示例。如果您正苦于以下问题:C# XNamespace类的具体用法?C# XNamespace怎么用?C# XNamespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XNamespace类属于System.Xml.Linq命名空间,在下文中一共展示了XNamespace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:JamesRandall,项目名称:CycleCycleCycle.com,代码行数:31,代码来源:GpxRouteCreator.cs


示例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;
        }
开发者ID:Rufix,项目名称:xaml-sdk,代码行数:28,代码来源:MsProjectImportHelper.cs


示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:CorrelationKey.cs


示例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;
 }
开发者ID:yartat,项目名称:Auto3D,代码行数:7,代码来源:UPnPService.cs


示例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);
 }
开发者ID:KiselevKN,项目名称:BootMega,代码行数:7,代码来源:SettingsInfoExtensions.cs


示例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);
 }
开发者ID:fengweijp,项目名称:higlabo,代码行数:12,代码来源:RssChannel.cs


示例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);
        }
开发者ID:bdvsoft,项目名称:reader_wp8_OPDS,代码行数:27,代码来源:EpubSummaryParser.cs


示例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;
		}
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:32,代码来源:DynamicExtensions.cs


示例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/";
 }
开发者ID:johny1515,项目名称:Bank_REI,代码行数:9,代码来源:ActiveForms.cs


示例10: SchemaInfo

 internal SchemaInfo(IFormChannelIdentifier channelIdentifier, XNamespace namespaceObj, XDocument schema)
 {
     this.ChannelIdentifier = channelIdentifier;
     this.Namespace = namespaceObj;
     this.Schema = schema;
     this.SchemaType = FormSchemaType.Uicontrols;
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:7,代码来源:SchemaBuilder.cs


示例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);
 }
开发者ID:arkum,项目名称:AmazonProductApi,代码行数:7,代码来源:Extensions.cs


示例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/");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:XNamespace.cs


示例13: SetDefaultXmlNamespace

 public static void SetDefaultXmlNamespace(this XElement xelem, XNamespace xmlns)
 {
     if (xelem.Name.NamespaceName == string.Empty)
         xelem.Name = xmlns + xelem.Name.LocalName;
     foreach (var e in xelem.Elements())
         e.SetDefaultXmlNamespace(xmlns);
 }
开发者ID:rndsolutions,项目名称:trx-merger,代码行数:7,代码来源:ExtensionMethods.cs


示例14: GenerateAllGanttTasks

 private static void GenerateAllGanttTasks(IEnumerable<XElement> tasks, XNamespace xnamespace)
 {
     foreach (var t in tasks)
     {
         var ganttTask = new GanttTask();
         if (t.Element(xnamespace + "Name") != null)
         {
             ganttTask.Title = t.Element(xnamespace + "Name").Value;
         }
         ganttTask.UniqueId = t.Element(xnamespace + "UID").Value;
         ganttTask.Start = DateTime.Parse(t.Element(xnamespace + "Start").Value);
         ganttTask.End = DateTime.Parse(t.Element(xnamespace + "Finish").Value);
         ganttTask.IsMilestone = t.Element(xnamespace + "Milestone").Value == "1";
         ganttTask.Progress = Double.Parse(t.Element(xnamespace + "PercentComplete").Value);
         string outlineNumber = null;
         if (t.Element(xnamespace + "OutlineNumber") != null)
         {
             outlineNumber = t.Element(xnamespace + "OutlineNumber").Value;
         }
         var relations = t.Elements(xnamespace + "PredecessorLink");
         IList<string> relatonTaskIDs = new List<string>();
         foreach (var relation in relations)
         {
             var relationTask = relation.Element(xnamespace + "PredecessorUID").Value;
             relatonTaskIDs.Add(relationTask);
         }
         if (outlineNumber != null)
         {
             SetAllChildren(outlineNumber, ganttTask.UniqueId);
         }
         taskIdToGanttTask[ganttTask.UniqueId] = new Tuple<GanttTask, string>(ganttTask, outlineNumber);
     }
 }
开发者ID:Rufix,项目名称:xaml-sdk,代码行数:33,代码来源:MsProjectImportHelper.cs


示例15: objXmlEdmx

 public objXmlEdmx(String strFilename)
     : base(strFilename)
 {
     this.strEdmxNs = XNamespace.Get(ConfigurationManager.AppSettings["EdmxNs"]);
     this.strSchemaNs = XNamespace.Get(ConfigurationManager.AppSettings["EdmxSchemaNs"]);
     InitRuntime();
 }
开发者ID:interstellarspace,项目名称:XML_PARSER,代码行数:7,代码来源:objXmlEdmx.cs


示例16: CreateNodes

        private static void CreateNodes(XNamespace ns, XElement nodes, DgmlNode dgmlNode)
        {
            XElement node;
            if (dgmlNode.Category == "SyntaxToken")
            {
                node = new XElement(ns + "Node",
                    new XAttribute("Id", dgmlNode.Id),
                    new XAttribute("Category", dgmlNode.Category),
                    new XAttribute("Label", dgmlNode.Label));
            }
            else
            {
                node = new XElement(ns + "Node",
                    new XAttribute("Id", dgmlNode.Id),
                    new XAttribute("Category", dgmlNode.Category),
                    new XAttribute("Label", dgmlNode.Kind));
            }

            nodes.Add(node);

            foreach (var childNode in dgmlNode.Childs)
            {
                CreateNodes(ns, nodes, childNode);
            }
        }
开发者ID:plaurin,项目名称:RoslynDemo,代码行数:25,代码来源:Program.cs


示例17: Main

        static void Main(string[] args)
        {
            doc = XDocument.Load("http://events.feed.comportal.be/agenda.aspx?event=TechDays&year=2013&speakerlist=c|Experts");

            jsonns = "http://james.newtonking.com/projects/json";
            doc.Root.SetAttributeValue(XNamespace.Xmlns + "json", jsonns);

            CleanSection("bio");
            CleanSection("description");

            ToJsonArray("timeslot");
            ToJsonArray("session");
            ToJsonArray("tag");
            ToJsonArray("speaker");

            var wrdoc = File.CreateText("sessions.xml");
            wrdoc.Write(doc);
            wrdoc.Close();

            var jsonstring = JsonConvert.SerializeXNode(doc);

            var wr = File.CreateText("sessions.json");
            wr.Write(jsonstring);
            wr.Close();

            var rdr = File.OpenText("sessions.json");
            var json = rdr.ReadToEnd();
            rdr.Close();

            var theevent = JsonConvert.DeserializeObject<TopXml>(json);

            //Console.WriteLine("done");
            //Console.ReadLine();
        }
开发者ID:vermegi,项目名称:TechdaysBeDemo,代码行数:34,代码来源:Program.cs


示例18: GetPrefixOfNamespace

        /// <summary>
        /// Gets the prefix associated with a namespace for this <see cref="XDocument"/>.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="ns"></param>
        /// <returns></returns>
        public static string GetPrefixOfNamespace(this XDocument self, XNamespace ns)
        {
            Contract.Requires<ArgumentNullException>(self != null);
            Contract.Requires<ArgumentNullException>(ns != null);

            return self.Root.GetPrefixOfNamespace(ns);
        }
开发者ID:nxkit,项目名称:nxkit,代码行数:13,代码来源:XDocumentExtensions.cs


示例19: GetOfferListingId

 public static string GetOfferListingId(this XElement xElement, XNamespace ns)
 {
     return xElement.Element(ns + "Offers") == null? string.Empty : xElement.Element(ns + "Offers").Elements(ns + "Offer") == null ? string.Empty :
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing") == null ? string.Empty :
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing").Descendants(ns + "OfferListingId") == null ? string.Empty : 
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing").Descendants(ns + "OfferListingId").Select(f => f == null ? string.Empty : f.Value).First().ToString();
 }
开发者ID:arkum,项目名称:AmazonProductApi,代码行数:7,代码来源:Extensions.cs


示例20: FixSize

 public void FixSize(XNamespace ab, XElement role, string name, string size)
 {
     foreach (var local in role.Elements(ab + "LocalResources"))
         foreach (var storage in local.Elements(ab + "LocalStorage"))
             if (storage.Attribute("name").Value == name)
                 storage.SetAttributeValue("sizeInMB", size);
 }
开发者ID:s-innovations,项目名称:WindowsAzure.Tfs.CloudServices,代码行数:7,代码来源:UnitTest1.cs



注:本文中的System.Xml.Linq.XNamespace类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Linq.XNode类代码示例发布时间:2022-05-26
下一篇:
C# Linq.XName类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap