Class Node
- Namespace
- Yarhl.FileSystem
- Assembly
- Yarhl.dll
Node in the FileSystem with an associated format.
public class Node : NavigableNode<Node>, IDisposable
- Inheritance
-
Node
- Implements
- Inherited Members
Constructors
Node(string)
Initializes a new instance of the Node class.
public Node(string name)
Parameters
name
stringNode name.
Node(string, IFormat)
Initializes a new instance of the Node class.
public Node(string name, IFormat initialFormat)
Parameters
Node(Node)
Initializes a new instance of the Node class.
public Node(Node node)
Parameters
node
NodeThe original node.
Remarks
It makes a copy of the original node. The original format is deep copied. See ICloneableFormat for details.
Properties
Format
Gets the current format of the node.
public IFormat? Format { get; }
Property Value
- IFormat
The current format.
IsContainer
Gets a value indicating whether the format is a container of nodes.
public bool IsContainer { get; }
Property Value
Stream
Gets the node associated DataStream if the format is IBinary.
public DataStream? Stream { get; }
Property Value
- DataStream
DataStream if the format is IBinary, null otherwise.
Methods
ChangeFormat(IFormat?, bool)
Change the format of the current node.
public Node ChangeFormat(IFormat? newFormat, bool disposePreviousFormat = true)
Parameters
newFormat
IFormatThe new format to assign.
disposePreviousFormat
boolIf true the method will dispose the previous format.
Returns
- Node
This node.
Remarks
If the previous format was a container, this method will remove the children of the node. If the new format is a container, this method will add the format children to the node.
If the new format is the same reference as the current format the method is a no-op.
Dispose(bool)
Releases all resource used by the Node object.
protected override void Dispose(bool freeManagedResourcesAlso)
Parameters
GetFormatAs<T>()
Gets the format as the specified type.
public T? GetFormatAs<T>() where T : class, IFormat
Returns
- T
The format casted to the type or null if not possible.
Type Parameters
T
The format type.
TransformWith(Type, params object?[])
Transforms the node format with the specified converter.
public Node TransformWith(Type converterType, params object?[] args)
Parameters
converterType
TypeThe type of the converter to use.
args
object[]Arguments for the constructor of the type if any.
Returns
- Node
This node.
TransformWith(IConverter)
Transform the node format to another format using a converter.
public Node TransformWith(IConverter converter)
Parameters
converter
IConverterConvert to use.
Returns
- Node
This node.
TransformWith<TConv>()
Transform the node format to another format with a given converter.
public Node TransformWith<TConv>() where TConv : IConverter, new()
Returns
- Node
This node.
Type Parameters
TConv
The type of the converter to use.
TransformWith<TConv, TParam>(TParam)
Transform the node format to another format with a given converter initialized with parameters.
[Obsolete("IInitialize is obsolete. Use the converter constructor and TransformWith(converter)")]
public Node TransformWith<TConv, TParam>(TParam param) where TConv : IConverter, IInitializer<TParam>, new()
Parameters
param
TParamParameters to initialize the converter.
Returns
- Node
This node.
Type Parameters
TConv
The type of the converter to use.
TParam
The type for initializing the converter.