Exemple #1
0
 /// <summary>
 /// Copy values from another Pdu class.
 /// </summary>
 /// <param name="value"><see cref="Pdu"/> cast as AsnType</param>
 /// <exception cref="ArgumentNullException">Thrown when received argument is null</exception>
 public void Set(AsnType value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (value is Pdu pdu)
     {
         Type             = pdu.Type;
         _requestId.Value = pdu.RequestId;
         if (Type == PduType.GetBulk)
         {
             NonRepeaters   = pdu.NonRepeaters;
             MaxRepetitions = pdu.MaxRepetitions;
         }
         else
         {
             ErrorStatus = pdu.ErrorStatus;
             ErrorIndex  = pdu.ErrorIndex;
         }
         _vbs.Clear();
         foreach (Vb v in pdu.VbList)
         {
             _vbs.Add((Vb)v.Clone());
         }
     }
     else
     {
         throw new ArgumentNullException("value", "Argument is not an Oid class");
     }
 }
Exemple #2
0
 /// <summary>
 /// Set VbList
 /// </summary>
 /// <remarks>
 /// Copy variable bindings from argument <see cref="VbCollection"/> into this classes variable
 /// binding collection
 /// </remarks>
 /// <param name="value"><see cref="VbCollection"/> to copy variable bindings from</param>
 public void SetVbList(VbCollection value)
 {
     _vbs.Clear();
     foreach (Vb v in value)
     {
         _vbs.Add(v);
     }
 }
        /// <summary>
        /// Initialize the class with values from another <see cref="TrapPdu"/> class.
        /// </summary>
        /// <param name="second">TrapPdu class whose values are used to initialize this class.</param>
        public void Set(TrapPdu second)
        {
            if (second != null)
            {
                _enterprise.Set(second._enterprise);
                _agentAddr.Set(second._agentAddr);
                _generic.Value   = second.Generic;
                _specific.Value  = second.Specific;
                _timeStamp.Value = second.TimeStamp;

                _variables.Clear();

                for (int x = 0; x < second._variables.Count; x++)
                {
                    _variables = (VbCollection)second.VbList.Clone();
                }
            }
            else
            {
                throw new ArgumentException("Invalid argument type.", "value");
            }
        }
Exemple #4
0
        /// <summary>Initialize the class with values from another <see cref="TrapPdu"/> class.</summary>
        /// <param name="second">TrapPdu class whose values are used to initialize this class.</param>
        public void Set(TrapPdu second)
        {
            if (second != null)
            {
                enterprise.Set(second.enterprise);
                agentAddr.Set(second.agentAddr);
                generic.Value   = second.Generic;
                specific.Value  = second.Specific;
                timeStamp.Value = second.TimeStamp;

                variables.Clear();

                for (int x = 0; x < second.variables.Count; x++)
                {
                    variables = (VbCollection)second.VbList.Clone();
                }
            }
            else
            {
                throw new ArgumentException("Invalid argument type.", nameof(second));
            }
        }