Class CompositeNode

Class CompositeNode

Namespace: Aspose.Note
Assembly: Aspose.Note.dll (24.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 : INode

Type Parameters

T

The type of elements in the composite node.

Inheritance

objectNodeCompositeNodeBaseCompositeNode<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).```csharp 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 &lt; 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);

### <a id="Aspose_Note_CompositeNode_1_IsComposite"></a> IsComposite

Checks whether the node is composite. If true then the node can have child nodes.

```csharp
public override sealed bool IsComposite { get; }

Property Value

bool

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 : T

Parameters

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 : T

Parameters

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

List<INode&gt;

A list of child nodes.

GetChildNodes<t1>()

Get all child nodes by the node type.

public override List<t1> GetChildNodes<t1>() where T1 : class, INode

Returns

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.```csharp // 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)));
                                                         }
                                                     }
                                                 }</aspose.note.image></aspose.note.image>

Shows how to get image's meta information.```csharp
// 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();
                                                     }</aspose.note.image></aspose.note.image>

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 : T

Parameters

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 : T

Parameters

oldChild T1

The node to remove.

Returns

T1

The removed node.

Type Parameters

T1

The exact type of removed node. </t1></t></t></t1></t></t1></t1></t1></t1></t1></t></t></t>