当前位置: 首页>>代码示例>>C#>>正文


C# XElement.Remove方法代码示例

本文整理汇总了C#中System.Xml.Linq.XElement.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.Remove方法的具体用法?C# XElement.Remove怎么用?C# XElement.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

		public override void Execute(XElement el){
			string code = el.Attr("code");
			Type type = Type.GetType(code, false);
			if (null == type){
				_project.Log.Error("Не могу найти расширение - генератор с именем " + code);
				return;
			}
			var gen = Activator.CreateInstance(type) as ISourceCodeGenerator;
			if (null == gen){
				_project.Log.Error("Указанный класс " + code + " не соответствует интерфейсу ISourceCodeGenerator");
				return;
			}
			IEnumerable<XNode> replaces = null;
			try{
				replaces = gen.Execute(_project, el, null).ToArray();
			}
			catch (Exception ex){
				_project.Log.Error("Ошибка при вызове " + gen.GetType().Name + " на " + el, ex);
				return;
			}
			if (!replaces.Any()){
				el.Remove();
			}
			else{
				el.ReplaceWith(replaces.OfType<object>().ToArray());
			}
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:27,代码来源:ExecuteCodeGenerator.cs

示例2: Remove

 /// <summary>Removes the specified <see cref="XElement"/> from this node as an extension element.</summary>
 /// <param name="extElement">The <see cref="XElement"/> to remove.</param>
 /// <exception cref="ArgumentNullException"><paramref name="extElement"/> is null.</exception>
 /// <exception cref="ArgumentException"><paramref name="extElement"/> belongs to the Atom namespace.</exception>
 public void Remove(XElement extElement)
 {
   if(extElement == null) throw new ArgumentNullException("extElement");
   if(extElement.Name.Namespace == AtomNamespace) throw new ArgumentException(Errors.ElementAtomNamespace, "extElement");
   if(extElement.Parent == this.Element)
     extElement.Remove();
 }
开发者ID:jordanbtucker,项目名称:NS84.Syndication.Atom,代码行数:11,代码来源:AtomExtensionContainerNode.cs

示例3: EDIXmlNode

 public EDIXmlNode(XElement el)
     : base(el)
 {
     if (el.Parent == null) return;
     //el.Parent.Add(this);
     el.Remove();
 }
开发者ID:agglerithm,项目名称:EDIDocsProcessing,代码行数:7,代码来源:EDIXmlNode.cs

示例4: RewriteElement

		bool RewriteElement(XamlContext ctx, XElement parent, XElement elem) {
			var type = parent.Annotation<XamlType>();
			var property = elem.Annotation<XamlProperty>();
			if ((property == null || type == null) && elem.Name != key)
				return false;

			if (elem.Elements().Count() != 1 || elem.Attributes().Any(t => t.Name.Namespace != XNamespace.Xmlns))
				return false;

			var value = elem.Elements().Single();

			if (!CanInlineExt(ctx, value))
				return false;

			var ext = InlineExtension(ctx, value);
			if (ext == null)
				return false;

			ctx.CancellationToken.ThrowIfCancellationRequested();

			var extValue = ext.ToString(ctx, parent);

			var attrName = elem.Name;
			if (attrName != key)
				attrName = property.ToXName(ctx, parent, property.IsAttachedTo(type));
			var attr = new XAttribute(attrName, extValue);
			parent.Add(attr);
			elem.Remove();

			return true;
		}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:31,代码来源:MarkupExtensionRewritePass.cs

示例5: Execute

		public override void Execute(XElement el){
			if (string.IsNullOrWhiteSpace(Name)){
				el.Remove();
				return;
			}
			XElement[] toremove = (Level == "all" ? el.Descendants(Name) : el.Elements(Name)).ToArray();
			toremove.Remove();
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:8,代码来源:CleanupElementOperation.cs

示例6: Remove

 /// <summary>Removes the specified <see cref="XElement"/> from this node as an extension element.</summary>
 /// <param name="extElement">The <see cref="XElement"/> to remove.</param>
 /// <exception cref="ArgumentNullException"><paramref name="extElement"/> is null.</exception>
 /// <exception cref="ArgumentException"><paramref name="extElement"/> belongs to the Atom namespace.</exception>
 public void Remove(XElement extElement)
 {
   if(extElement == null) throw new ArgumentNullException("extElement");
   if(extElement.Name.Namespace == AtomPubNamespace) throw new ArgumentException(Errors.ElementAtomPubNamespace, "extElement");
   if(this.CanRemoveExtElement(extElement) == false) throw new ArgumentException(Errors.CannotRemoveExtElement, "extElement");
   if(extElement.Parent == this.Element)
     extElement.Remove();
 }
开发者ID:jordanbtucker,项目名称:NS84.Syndication.Atom,代码行数:12,代码来源:AtomPubExtensionContainerNode.cs

示例7: RemoveElement

 private static bool RemoveElement(XElement el)
 {
     if (el == null)
     {
         return false;
     }
     el.Remove();
     return true;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:9,代码来源:LaunchScreenUpdater.cs

示例8: ResolveCondition

		/// <summary>
		/// 	Resolves the condition.
		/// </summary>
		/// <param name="e"> The e. </param>
		/// <param name="id"> The id. </param>
		/// <remarks>
		/// </remarks>
		private void ResolveCondition(XElement e, string id) {
			if (!Match(id)) {
				e.Remove();
				return;
			}
			foreach (var a in e.Attributes()) {
				SetParentAttribute(e, a);
			}
			e.ReplaceWith(e.Elements());
		}
开发者ID:comdiv,项目名称:qorpent.themas,代码行数:17,代码来源:ResolveConditionalCompilationStep.cs

示例9: InsertPredicate

		public override void InsertPredicate(
				XElement target, long id, ElementType type) {
			var oldcode = Python3XmlToCode.Instance.Generate(target);
			var code = "CoverageWriter.WritePredicate(" + id + "," + (int)type + ","
					+ oldcode + ")";
			var node = Python3CodeToXml.Instance.Generate(code)
					.Descendants(target.Name)
					.First();
			target.AddBeforeSelf(node);
			target.Remove();
		}
开发者ID:audioglider,项目名称:OpenCodeCoverageFramework,代码行数:11,代码来源:Python3AstTransformer.cs

示例10: Execute

	    private void Execute(ClassFilter filter, XElement e, string rootns) {
		    if (e.Name.LocalName == BSharpSyntax.Namespace) {
			    var ns = e.Attr("code");
				if (!string.IsNullOrWhiteSpace(rootns)) {
					ns = rootns + "." + ns;
				}
				if (!filter.IsAvailableNamespace(ns)) {
					e.Remove();
				}
				foreach (var c in e.Elements().ToArray())
				{
					Execute(filter, c,ns);
				}
		    }
		    else {
			    var clsname = e.Attr("code");
				if (!filter.IsAvailableClassname(clsname)) {
					e.Remove();
				}
		    }
	    }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:21,代码来源:ResolveClassesAndNamespacesTask.cs

示例11: CreateControlFlowFromComment

        private void CreateControlFlowFromComment( XElement comment )
        {
            var row = comment.XPathSelectElement( "./ancestor::table:table-row", Manager );
            var commentValue = comment.Value.Replace( "U+10FFFD", "@" );

            var beforeNode = new XText( commentValue + "{" );

            var afterNode = new XText( "}" );

            row.AddBeforeSelf( beforeNode );
            row.AddAfterSelf( afterNode );
            comment.Remove();
        }
开发者ID:EventBooking,项目名称:AntiShaun,代码行数:13,代码来源:OdsTemplate.cs

示例12: ReplaceValues

        private void ReplaceValues(XElement dynamicRow)
        {
            var readers = DataReader.GetReaders(TableTag.ItemsSource).ToList();
            for (var index = 0; index < readers.Count(); index++)
            {
                var currentRow = new XElement(dynamicRow);
                var tableElements = TableTag.MakeTableElementCallback(currentRow);

                this.ProcessElements(tableElements, readers[index], index+1, null, true);

                dynamicRow.AddBeforeSelf(currentRow);
            }
            dynamicRow.Remove();
        }
开发者ID:koZZZdya,项目名称:TsSoft.Docx.TemplateEngine,代码行数:14,代码来源:TableProcessor.cs

示例13: InsertPredicate

 public override void InsertPredicate(XElement target, long id, ElementType type) {
     var node = new XElement("call", new object[] {
             new XElement("nil"),
             new XElement("Symbol", "branch"),
             new XElement("lit", new[] {
                     new XElement("Fixnum", id),
             }),
             new XElement("lit", new[] {
                     new XElement("Fixnum", (int)type),
             }),
             target,
     });
     target.AddBeforeSelf(node);
     target.Remove();
 }
开发者ID:audioglider,项目名称:OpenCodeCoverageFramework,代码行数:15,代码来源:Ruby18AstTransformer.cs

示例14: CreateControlFlowSection

        private void CreateControlFlowSection( XElement script )
        {
            //TODO: Test this method

            var parentSection = script.XPathSelectElement( "./ancestor::text:section", Manager );
            // TODO: If ParentSection is null, throw specific exception

            var scriptValue = script.Value.Replace( "U+10FFFD", "@" );

            var beforeNode = new XText( scriptValue + "{" );

            var afterNode = new XText( "}" );

            parentSection.AddBeforeSelf( beforeNode );

            parentSection.AddAfterSelf( afterNode );

            script.Remove();
        }
开发者ID:EventBooking,项目名称:AntiShaun,代码行数:19,代码来源:OdtTemplate.cs

示例15: RewriteElement

		bool RewriteElement(XamlContext ctx, XElement parent, XElement elem) {
			var property = elem.Annotation<XamlProperty>();
			if (property == null && elem.Name != key)
				return false;

			if (elem.HasAttributes || elem.HasElements)
				return false;

			ctx.CancellationToken.ThrowIfCancellationRequested();

			var value = elem.Value;
			var attrName = elem.Name;
			if (attrName != key)
				attrName = property.ToXName(ctx, parent, property.IsAttachedTo(parent.Annotation<XamlType>()));
			var attr = new XAttribute(attrName, value);
			parent.Add(attr);
			elem.Remove();

			return true;
		}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:20,代码来源:AttributeRewritePass.cs


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