示例#1
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            MibSymbol sym;
            string    message;

            sym = this.GetSymbol(log);
            if (sym is MibTypeSymbol)
            {
                this.type = this.InitializeReference(symbol, log, (MibTypeSymbol)sym);
                if (this.type == null)
                {
                    message = "referenced symbol '" + sym.Name +
                              "' contains undefined type";
                    throw new MibException(this.location, message);
                }

                return(this.type);
            }
            else if (sym == null)
            {
                message = "undefined symbol '" + this.Name + "'";
                throw new MibException(this.location, message);
            }
            else
            {
                message = "referenced symbol '" + this.Name + "' is not a type";
                throw new MibException(this.location, message);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (!(symbol is MibValueSymbol))
            {
                throw new MibException(
                          symbol.Location,
                          "only values can have the " + Name + " type");
            }

            this.syntax = this.syntax.Initialize(symbol, log);

            SnmpObjectType.CheckType((MibValueSymbol)symbol, log, this.syntax);

            foreach (SnmpIndex si in this.index)
            {
                si.Initialize(symbol, log);
            }

            if (this.augments != null)
            {
                this.augments = this.augments.Initialize(log, this.syntax);
            }

            if (this.defaultValue != null)
            {
                this.defaultValue = this.defaultValue.Initialize(log, this.syntax);
            }

            return(this);
        }
示例#3
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// </summary>
        /// <remarks>
        /// This is an internal method that should
        /// only be called by the MIB loader.
        /// </remarks>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        /// <exception cref="MibException">If an error occurred during initialization</exception>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            foreach (ElementType elem in this.elements)
            {
                elem.Initialize(symbol, log);
            }

            return(this);
        }
示例#4
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            this.SetTag(true, MibTypeTag.OctetString);
            if (this.constraint != null)
            {
                this.constraint.Initialize(this, log);
            }

            return(this);
        }
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (!(symbol is MibValueSymbol))
            {
                throw new MibException(
                          symbol.Location,
                          "only values can have the " + Name + " type");
            }

            return(this);
        }
示例#6
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// </summary>
        /// <remarks>
        /// This is an internal method that should
        /// only be called by the MIB loader.
        /// </remarks>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            this.SetTag(true, MibTypeTag.Sequence);

            this.baseType = this.baseType.Initialize(symbol, log);
            if (this.baseType != null && this.constraint != null)
            {
                this.constraint.Initialize(this, log);
            }

            return(this);
        }
示例#7
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (!(symbol is MibValueSymbol))
            {
                throw new MibException(
                          symbol.Location,
                          "only values can have the " + Name + " type");
            }

            this.notifications = this.notifications.Select(n => n.Initialize(log, null)).ToList();
            return(this);
        }
示例#8
0
        /// <summary>
        /// Initializes the object. This will remove all levels of
        /// indirection present, such as references to other types and
        /// values.No information is lost by this operation.This method
        /// may modify this object as a side-effect, and will be called by
        /// the MIB loader.
        /// </summary>
        /// <param name="symbol">the MIB symbol containing this object</param>
        /// <param name="log">the MIB loader log</param>
        /// <exception cref="MibException">
        /// If an error was encountered during the initialization
        /// </exception>
        public void Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (this.value != null)
            {
                this.value = this.value.Initialize(log, null);
            }

            if (this.type != null)
            {
                this.type = this.type.Initialize(symbol, log);
            }
        }
示例#9
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        /// <exception cref="MibException">
        /// If an error was encountered during the initialization
        /// </exception>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (!(symbol is MibValueSymbol))
            {
                throw new MibException(
                          symbol.Location,
                          "only values can have the " + Name + " type");
            }

            this.enterprise = this.enterprise.Initialize(log, null);
            this.variables  = this.variables.Select(v => v.Initialize(log, null)).ToList();
            return(this);
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sym"></param>
        private void AddSymbol(MibSymbol sym)
        {
            if (!(sym is MibValueSymbol valSym))
            {
                return;
            }

            if (!(valSym.Value is ObjectIdentifierValue oiv))
            {
                return;
            }

            this.AddToTree(oiv);
        }
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic type.
        /// Note: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        /// <exception cref="MibException">
        /// If an error is encountered during initialization
        /// </exception>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            if (!(symbol is MibValueSymbol))
            {
                throw new MibException(
                          symbol.Location,
                          "only values can have the " + this.Name + " type");
            }

            foreach (var m in this.modules)
            {
                m.Initialize(log);
            }

            return(this);
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sym"></param>
        private void AddSymbol(MibSymbol sym)
        {
            MibValueSymbol valSym = sym as MibValueSymbol;

            if (valSym == null)
            {
                return;
            }

            ObjectIdentifierValue oiv = valSym.Value as ObjectIdentifierValue;

            if (oiv == null)
            {
                return;
            }

            this.AddToTree(oiv);
        }
示例#13
0
        /// <summary>
        /// Initializes the referenced MIB type symbol. This will remove
        /// all levels of indirection present, such as references to other
        /// types, and returns the basic type. This method will add any
        /// constraints or defined values if possible.
        /// </summary>
        /// <param name="symbol">the MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <param name="tref">the referenced MIB type symbol</param>
        /// <returns>
        /// The basic MIB type, or null if the basic type was unresolved
        /// </returns>
        /// <exception cref="MibException">
        /// If an error was encountered during the
        /// initialization</exception>
        private MibType InitializeReference(
            MibSymbol symbol,
            MibLoaderLog log,
            MibTypeSymbol tref)
        {
            MibType type = tref.Type;

            if (type != null)
            {
                type = type.Initialize(symbol, log);
            }

            if (type == null)
            {
                return(null);
            }

            try
            {
                if (this.constraint != null)
                {
                    type = type.CreateReference(this.constraint);
                }
                else if (this.values != null)
                {
                    type = type.CreateReference(this.values);
                }
                else
                {
                    type = type.CreateReference();
                }

                type = type.Initialize(symbol, log);
            }
            catch (NotSupportedException e)
            {
                throw new MibException(this.location, e.Message);
            }

            type.ReferenceSymbol = tref;
            this.InitializeTypeTag(type, this.tag);
            return(type);
        }
示例#14
0
        /// <summary>
        /// Initializes the MIB type. This will remove all levels of
        /// indirection present, such as references to types or values. No
        /// information is lost by this operation. This method may modify
        /// this object as a side-effect, and will return the basic
        /// type.
        /// NOTE: This is an internal method that should
        /// only be called by the MIB loader.
        /// </summary>
        /// <param name="symbol">The MIB symbol containing this type</param>
        /// <param name="log">The MIB loader log</param>
        /// <returns>The basic MIB type</returns>
        public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
        {
            this.SetTag(true, MibTypeTag.Integer);

            if (this.constraint != null)
            {
                this.constraint.Initialize(this, log);
            }

            foreach (MibValueSymbol sym in this.symbols.Values)
            {
                sym.Initialize(log);
                if (!this.IsCompatibleType(sym.Value))
                {
                    string message = "value is not compatible with type";
                    throw new MibException(sym.Location, message);
                }
            }

            return(this);
        }
 /// <summary>
 /// Initializes the MIB type. This will remove all levels of
 /// indirection present, such as references to types or values. No
 /// information is lost by this operation. This method may modify
 /// this object as a side-effect, and will return the basic
 /// type.
 /// NOTE: This is an internal method that should
 /// only be called by the MIB loader.
 /// </summary>
 /// <param name="symbol">The MIB symbol containing this type</param>
 /// <param name="log">The MIB loader log</param>
 /// <returns>The basic MIB type</returns>
 /// <exception cref="MibException">
 /// If an error was encountered during the initialization
 /// </exception>
 public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
 {
     this.syntax = this.syntax.Initialize(symbol, log);
     return(this);
 }
 /// <summary>
 /// Initializes the MIB type. This will remove all levels of
 /// indirection present, such as references to types or values. No
 /// information is lost by this operation. This method may modify
 /// this object as a side-effect, and will return the basic
 /// type.
 /// </summary>
 /// <remarks>
 /// This is an internal method that should
 /// only be called by the MIB loader.
 /// </remarks>
 /// <param name="symbol">The MIB symbol containing this type</param>
 /// <param name="log">The MIB loader log</param>
 /// <returns>The MIB type</returns>
 public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
 {
     this.SetTag(true, MibTypeTag.ObjectIdentifier);
     return(this);
 }
示例#17
0
 /// <summary>
 /// Initializes the MIB type. This will remove all levels of
 /// indirection present, such as references to types or values. No
 /// information is lost by this operation. This method may modify
 /// this object as a side-effect, and will return the basic
 /// type.
 /// NOTE: This is an internal method that should
 /// only be called by the MIB loader.
 /// </summary>
 /// <param name="symbol">The MIB symbol containing this type</param>
 /// <param name="log">The MIB loader log</param>
 /// <returns>The basic MIB type</returns>
 public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
 {
     this.SetTag(true, MibTypeTag.Null);
     return(this);
 }
示例#18
0
 /// <summary>
 /// Initializes the MIB type. This will remove all levels of
 /// indirection present, such as references to types or values. No
 /// information is lost by this operation. This method may modify
 /// this object as a side-effect, and will return the basic
 /// type.
 /// NOTE: This is an internal method that should
 /// only be called by the MIB loader.
 /// </summary>
 /// <param name="symbol">the MIB symbol containing this type</param>
 /// <param name="log">The MIB loader log</param>
 /// <returns>The basic MIB type</returns>
 /// <exception cref="MibException">If an error was encountered during the initialization</exception>
 public override MibType Initialize(MibSymbol symbol, MibLoaderLog log)
 {
     this.SetTag(true, MibTypeTag.Sequence);
     this.elements.Select(e => e.Initialize(symbol, log));
     return(this);
 }