Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectIdentifierValue"/> class.
 /// </summary>
 /// <param name="location">The declaration file location</param>
 /// <param name="parent">The component parent</param>
 /// <param name="name">The component name</param>
 /// <param name="value">The component value</param>
 public ObjectIdentifierValue(
     FileLocation location,
     ValueReference parent,
     string name,
     int value)
     : base("OBJECT IDENTIFIER")
 {
     this.location = location;
     this.parent   = parent;
     this.name     = name;
     this.value    = value;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a the MIB value from a value reference. This will
        /// resolve the reference, and set the bit corresponding to the
        /// value.
        /// </summary>
        /// <param name="log">The MIB loader log</param>
        /// <param name="type">The value type</param>
        /// <param name="vref">The value reference to resolve</param>
        /// <exception cref="MibException">
        /// If an error occurred during initialization
        /// </exception>
        private void Initialize(MibLoaderLog log, MibType type, ValueReference vref)
        {
            MibValue val = vref.Initialize(log, type);

            if (val is NumberValue nv)
            {
                this.value.Set((int)nv.Value, true);
            }
            else
            {
                throw new MibException(
                          vref.Location,
                          "referenced value is not a number");
            }
        }
        /// <summary>
        /// Initializes the MIB value. This will remove all levels of
        /// indirection present, such as references to other values. No
        /// value information is lost by this operation. This method may
        /// modify this object as a side-effect, and will return the basic
        /// value.
        /// </summary>
        /// <remarks>
        /// This is an internal method that should
        /// only be called by the MIB loader.
        /// </remarks>
        /// <param name="log">The MIB Loader log</param>
        /// <param name="type">The value type</param>
        /// <returns>The basic MIB value</returns>
        public override MibValue Initialize(MibLoaderLog log, MibType type)
        {
            ValueReference        vref = null;
            ObjectIdentifierValue oid;

            if (this.parent == null)
            {
                return(this);
            }
            else if (this.parent is ValueReference)
            {
                vref = (ValueReference)this.parent;
            }

            this.parent = this.parent.Initialize(log, type);

            if (vref != null)
            {
                if (this.parent is ObjectIdentifierValue)
                {
                    oid = (ObjectIdentifierValue)this.parent;
                    oid.AddChild(log, this.location, this);
                }
                else
                {
                    throw new MibException(
                              vref.Location,
                              "referenced value is not an object identifier");
                }
            }

            this.location = null;

            if (this.parent is ObjectIdentifierValue)
            {
                return(((ObjectIdentifierValue)this.parent).GetChildByValue(this.value));
            }
            else
            {
                return(this);
            }
        }