Beispiel #1
0
 /// <summary>
 /// Creates a new instance of <see cref="NbNsNodeStatusResponseResourceRecord"/> with the given <see cref="nodeNames"/> and <see cref="NbNsStatistics"/>
 /// </summary>
 /// <param name="rrName"><see cref="NbName"/> for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 /// <param name="nodeNames">List of <see cref="NbNsNodeName"/>s for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 /// <param name="statistics"><see cref="NbNsStatistics"/> for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 public NbNsNodeStatusResponseResourceRecord(NbName rrName, IEnumerable <NbNsNodeName> nodeNames, NbNsStatistics statistics)
     : base(RrTypeValue.NbStat, RrClassValue.In, 0)
 {
     RrName     = rrName;
     NodeNames  = new List <NbNsNodeName>(nodeNames);
     Statistics = statistics;
 }
 /// <summary>
 /// Creates a new instance of <see cref="NbNsNodeStatusResponseResourceRecord"/> with the given <see cref="nodeNames"/> and <see cref="NbNsStatistics"/>
 /// </summary>
 /// <param name="rrName"><see cref="NbName"/> for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 /// <param name="nodeNames">List of <see cref="NbNsNodeName"/>s for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 /// <param name="statistics"><see cref="NbNsStatistics"/> for this <see cref="NbNsNodeStatusResponseResourceRecord"/></param>
 public NbNsNodeStatusResponseResourceRecord(NbName rrName, IEnumerable<NbNsNodeName> nodeNames, NbNsStatistics statistics)
   : base(RrTypeValue.NbStat, RrClassValue.In, 0)
 {
   RrName = rrName;
   NodeNames = new List<NbNsNodeName>(nodeNames);
   Statistics = statistics;
 }
Beispiel #3
0
        /// <summary>
        /// Tries to parse a <see cref="NbNsNodeStatusResponseResourceRecord"/> from a buffer of bytes
        /// </summary>
        /// <param name="buffer">Byte array containing the NbNsNodeStatusResponseResourceRecord</param>
        /// <param name="offset">Zero based offset in the buffer where the NbNsNodeStatusResponseResourceRecord starts</param>
        /// <param name="resourceRecord">Parsed NbNsNodeStatusResponseResourceRecord if successful, else null</param>
        /// <returns><c>true</c> if parsing was successful, else <c>false</c></returns>
        public static bool TryParse(byte[] buffer, int offset, out NbNsNodeStatusResponseResourceRecord resourceRecord)
        {
            resourceRecord = null;

            var result = new NbNsNodeStatusResponseResourceRecord();

            if (!result.TryParse(buffer, offset))
            {
                return(false);
            }

            if (result.RrType != RrTypeValue.NbStat || result.RrClass != RrClassValue.In)
            {
                return(false);
            }

            offset += result.RrName.Length + 2 + 2 + 4 + 2;
            var numNames = buffer[offset];

            offset++;

            if (buffer.Length <= offset + numNames * NbNsNodeName.NODE_NAME_LENGTH + NbNsStatistics.STATISTICS_LENGTH)
            {
                return(false);
            }

            var nodeNames = new List <NbNsNodeName>();

            for (byte i = 0; i < numNames; i++)
            {
                NbNsNodeName nodeName;
                if (!NbNsNodeName.TryParse(buffer, offset, out nodeName))
                {
                    return(false);
                }
                nodeNames.Add(nodeName);
                offset += NbNsNodeName.NODE_NAME_LENGTH;
            }
            result.NodeNames = nodeNames;

            NbNsStatistics statistics;

            if (!NbNsStatistics.TryParse(buffer, offset, out statistics))
            {
                return(false);
            }
            result.Statistics = statistics;

            resourceRecord = result;
            return(true);
        }
Beispiel #4
0
 /// <summary>
 /// Tries to parse a <see cref="NbNsStatistics"/> from a buffer of bytes
 /// </summary>
 /// <param name="buffer">Byte array containing the NbNsStatistics</param>
 /// <param name="offset">Zero based offset in the buffer where the NbNsStatistics starts</param>
 /// <param name="statistics">Parsed NbNsStatistics if successful, else null</param>
 /// <returns><c>true</c> if parsing was successful, else <c>false</c></returns>
 public static bool TryParse(byte[] buffer, int offset, out NbNsStatistics statistics)
 {
     statistics = null;
     if (buffer == null)
     {
         return(false);
     }
     if (offset < 0 || offset > buffer.Length - STATISTICS_LENGTH)
     {
         return(false);
     }
     statistics = new NbNsStatistics(buffer.Skip(offset).Take(STATISTICS_LENGTH).ToArray());
     return(true);
 }
Beispiel #5
0
 /// <summary>
 /// Tries to parse a <see cref="NbNsStatistics"/> from a buffer of bytes
 /// </summary>
 /// <param name="buffer">Byte array containing the NbNsStatistics</param>
 /// <param name="offset">Zero based offset in the buffer where the NbNsStatistics starts</param>
 /// <param name="statistics">Parsed NbNsStatistics if successful, else null</param>
 /// <returns><c>true</c> if parsing was successful, else <c>false</c></returns>
 public static bool TryParse(byte[] buffer, int offset, out NbNsStatistics statistics)
 {
   statistics = null;
   if (buffer == null)
     return false;
   if (offset < 0 || offset > buffer.Length - STATISTICS_LENGTH)
     return false;
   statistics = new NbNsStatistics(buffer.Skip(offset).Take(STATISTICS_LENGTH).ToArray());
   return true;
 }