internal NXStringNode(string name, NXNode parent, NXFile file, uint strId, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId) { _id = strId; if ((_file._flags & NXReadSelection.EagerParseStrings) == NXReadSelection.EagerParseStrings) { CheckLoad(); } }
internal NXMP3Node(string name, NXNode parent, NXFile file, uint id, int len, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId) { _id = id; _len = len; if ((_file._flags & NXReadSelection.EagerParseMP3) == NXReadSelection.EagerParseMP3) { CheckLoad(); } }
internal NXCanvasNode(string name, NXNode parent, NXFile file, uint id, ushort width, ushort height, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId) { _id = id; _width = width; _height = height; if ((_file._flags & NXReadSelection.EagerParseCanvas) == NXReadSelection.EagerParseCanvas) { CheckLoad(); } }
/// <summary> /// Tries to cast this NXNode to a <see cref="NXValuedNode{T}" /> and returns its value, or throws an /// <see cref="InvalidCastException" /> /// if the cast is invalid. /// </summary> /// <typeparam name="T"> The type of the value to return. </typeparam> /// <param name="n"> This NXNode. </param> /// <returns> The contained value if the cast succeeds. </returns> /// <exception cref="InvalidCastException">Thrown if the cast is invalid.</exception> public static T ValueOrDie <T>(this NXNode n) { return(((NXValuedNode <T>)n).Value); }
/// <summary> /// Tries to cast this NXNode to a <see cref="NXValuedNode{T}" /> and returns its value, or returns the default value if the cast is invalid. /// </summary> /// <typeparam name="T"> The type of the value to return. </typeparam> /// <param name="n"> This NXNode. </param> /// <param name="def"> The default value to return should the cast fail. </param> /// <returns> /// The contained value if the cast succeeds, or <paramref name="def" /> if the cast fails. /// </returns> public static T ValueOrDefault <T>(this NXNode n, T def) { var nxvn = n as NXValuedNode <T>; return(nxvn != null ? nxvn.Value : def); }
/// <summary> /// Constructs a lazily-loaded node. /// </summary> /// <param name="name"> The name of the lazily-loaded node. </param> /// <param name="parent"> The parent node of the lazily-loaded node. </param> /// <param name="file"> The containing file of the lazily-loaded node. </param> /// <param name="childCount"> The number of children this lazily-loaded node contains. </param> /// <param name="firstChildId"> The Node ID of the first child of this node. </param> protected NXLazyValuedNode(string name, NXNode parent, NXFile file, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId) { }
internal NXValuedNode(string name, NXNode parent, NXFile file, T value, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId) { _value = value; }
public static T ValueOrDie <T>(this NXNode n) => ((NXValuedNode <T>)n).Value;