Files
PDFPatcher/App/Processor/InfoXmlProcessors/LevelDownProcessor.cs
T
Calcitem a25ebdfd4d 部分 if 条件翻转以缩小代码嵌套层级
一般是在 if 控制范围很大的情况下进行调整,如果控制范围小则不调整。
从第三方代码的 Demo 中复制的代码块不修改。
2022-01-15 09:39:10 +08:00

28 lines
624 B
C#

namespace PDFPatcher.Processor
{
sealed class LevelDownProcessor : IPdfInfoXmlProcessor
{
#region IInfoDocProcessor 成员
public string Name => "设置书签为子书签";
public IUndoAction Process(System.Xml.XmlElement item) {
if (item == item.ParentNode.FirstChild) {
return null;
}
var undo = new UndoActionGroup();
var n = item.SelectSingleNode("preceding-sibling::" + Constants.Bookmark + "[1]");
if (n == null) {
return null;
}
undo.Add(new AddElementAction(item));
n.AppendChild(item);
undo.Add(new RemoveElementAction(item));
return undo;
}
#endregion
}
}