Beispiel #1
0
 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();
     }
 }
Beispiel #2
0
 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();
     }
 }
Beispiel #3
0
 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();
     }
 }
Beispiel #4
0
 /// <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);
 }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
 /// <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)
 {
 }
Beispiel #7
0
 internal NXValuedNode(string name, NXNode parent, NXFile file, T value, ushort childCount, uint firstChildId) : base(name, parent, file, childCount, firstChildId)
 {
     _value = value;
 }
Beispiel #8
0
 public static T ValueOrDie <T>(this NXNode n)
 => ((NXValuedNode <T>)n).Value;