本文整理汇总了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());
}
}
示例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();
}
示例3: EDIXmlNode
public EDIXmlNode(XElement el)
: base(el)
{
if (el.Parent == null) return;
//el.Parent.Add(this);
el.Remove();
}
示例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;
}
示例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();
}
示例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();
}
示例7: RemoveElement
private static bool RemoveElement(XElement el)
{
if (el == null)
{
return false;
}
el.Remove();
return true;
}
示例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());
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}