Class CompositeNode
Namespace: Aspose.Note
Assembly: Aspose.Note.dll (25.12.0)
The base generic class for nodes that can contain other nodes.
public abstract class CompositeNode<T> : CompositeNodeBase, INode, ICompositeNode<T>, ICompositeNode, IEnumerable<T>, IEnumerable where T : INodeType Parameters
T
The type of elements in the composite node.
Inheritance
object ← Node ← CompositeNodeBase ← CompositeNode<T>
Implements
INode , ICompositeNode<T> , ICompositeNode , IEnumerable<T> , IEnumerable
Inherited Members
CompositeNodeBase.GetChildNodes(NodeType) , CompositeNodeBase.GetChildNodes<T1>() , CompositeNodeBase.CheckDocument(Node) , Node.Accept(DocumentVisitor) , Node.Document , Node.IsComposite , Node.NodeType , Node.ParentNode , Node.PreviousSibling , Node.NextSibling , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
CompositeNode(NodeType)
Initializes a new instance of the Aspose.Note.CompositeNode`1 class.
protected CompositeNode(NodeType nodeType)Parameters
nodeType NodeType
The type of the node.
Properties
FirstChild
Gets the first child node of this node.
public T FirstChild { get; }Property Value
T
Examples
Shows how to check if a page is a conflict page(i.e. it has changes that OneNote couldn’t automatically merge).
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write(" {0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
i,
historyPage.PageContentRevisionSummary.AuthorMostRecent,
historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
// By default conflict pages are just skipped on saving.
// If mark it as non-conflict then it will be saved as usual one in the history.
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);IsComposite
Checks whether the node is composite. If true then the node can have child nodes.
public override sealed bool IsComposite { get; }Property Value
LastChild
Gets the last child node of this node.
public T LastChild { get; }Property Value
T
Methods
Accept(DocumentVisitor)
Accepts the visitor of the node.
public override void Accept(DocumentVisitor visitor)Parameters
visitor DocumentVisitor
The object of a class derived from the Aspose.Note.DocumentVisitor.
AppendChildFirst<T1>(T1)
Adds the node to the front of the list of child nodes for this node.
public virtual T1 AppendChildFirst<T1>(T1 newChild) where T1 : TParameters
newChild T1
The node to add.
Returns
T1
The added node.
Type Parameters
T1
The exact type of appended node.
AppendChildLast<T1>(T1)
Adds the node to the end of the list of child nodes for this node.
public virtual T1 AppendChildLast<T1>(T1 newChild) where T1 : TParameters
newChild T1
The node to add.
Returns
T1
The added node.
Type Parameters
T1
The exact type of appended node.
GetChildNodes(NodeType)
Get all child nodes by node type.
[Obsolete("Use GetChildNodes<T>() method instead.")]
public override List<INode> GetChildNodes(NodeType type)Parameters
type NodeType
The node type.
Returns
A list of child nodes.
GetChildNodes<T1>()
Get all child nodes by the node type.
public override List<T1> GetChildNodes<T1>() where T1 : class, INodeReturns
List <T1>
A list of child nodes.
Type Parameters
T1
The type of elements in the returned list.
Examples
Shows how to get an image from a document.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<Aspose.Note.Image> nodes = oneFile.GetChildNodes<Aspose.Note.Image>();
foreach (Aspose.Note.Image image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
// Save image bytes to a file
bitMap.Save(String.Format(dataDir + "{0}", Path.GetFileName(image.FileName)));
}
}
}Shows how to get image’s meta information.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<Aspose.Note.Image> images = oneFile.GetChildNodes<Aspose.Note.Image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}GetEnumerator()
Returns an enumerator that iterates through child nodes of the Aspose.Note.CompositeNode`1.
public IEnumerator<T> GetEnumerator()Returns
IEnumerator <T>
A IEnumerator1 for the Aspose.Note.CompositeNode1.
InsertChild<T1>(int, T1)
Inserts the node to the specified position in the list of child nodes for this node.
public virtual T1 InsertChild<T1>(int i, T1 newChild) where T1 : TParameters
i int
Position to insert
newChild T1
The node to insert.
Returns
T1
The added node.
Type Parameters
T1
The exact type of inserted node.
InsertChildrenRange(int, IEnumerable<T>)
Inserts the node’s sequence starting from specified position in the list of child nodes for this node.
public void InsertChildrenRange(int i, IEnumerable<T> newChildren)Parameters
i int
Position to insert
newChildren IEnumerable
<T>
The sequence of nodes to be inserted.
InsertChildrenRange(int, params T[])
Inserts the node’s sequence starting from specified position in the list of child nodes for this node.
public void InsertChildrenRange(int i, params T[] newChildren)Parameters
i int
Position to insert
newChildren T[]
The sequence of nodes to be inserted.
RemoveChild<T1>(T1)
Removes the child node.
public T1 RemoveChild<T1>(T1 oldChild) where T1 : TParameters
oldChild T1
The node to remove.
Returns
T1
The removed node.
Type Parameters
T1
The exact type of removed node.