/// <summary> /// Clears and prepares this MIB symbol for garbage collection. /// This method will recursively clear any associated types or /// values, making sure that no data structures references this /// symbol. /// </summary> public override void Clear() { this.type = null; if (this.value != null) { this.value.Clear(); } this.value = null; }
/// <summary> /// Initializes a new instance of the <see cref="MibValueSymbol"/> class. /// NOTE: This is an internal constructor that /// should only be called by the MIB loader. /// </summary> /// <param name="location">The symbol location</param> /// <param name="mib">The symbol MIB name</param> /// <param name="name">The symbol name</param> /// <param name="type">The symbol type</param> /// <param name="value">The symbol value</param> public MibValueSymbol( FileLocation location, Mib mib, string name, MibType type, MibValue value) : base(location, mib, name) { this.type = type; this.value = value; }
/// <summary> /// Initializes the MIB symbol. 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. /// </summary> /// NOTE: This is an internal method that should /// only be called by the MIB loader. /// <param name="log">The MIB loader log</param> /// <exception cref="MibException"> /// If an error was encountered during the initialization /// </exception> public override void Initialize(MibLoaderLog log) { ObjectIdentifierValue oid; if (this.type != null) { try { this.type = this.type.Initialize(this, log); } catch (MibException e) { log.AddError(e.Location, e.Message); this.type = null; } } if (this.value != null) { try { this.value = this.value.Initialize(log, this.type); } catch (MibException e) { log.AddError(e.Location, e.Message); this.value = null; } } if (this.type != null && this.value != null && !this.type.IsCompatible(this.value)) { log.AddError(this.Location, "value is not compatible with type"); } if (this.value is ObjectIdentifierValue) { oid = (ObjectIdentifierValue)this.value; if (oid.Symbol == null) { oid.Symbol = this; } } }
/// <summary> /// Checks if the specified value is compatible with this type. A /// value is compatible if it has a type that matches this one and /// a value that satisfies all constraints. /// </summary> /// <param name="value">The value to check</param> /// <returns>True if the value is compatible, false if not</returns> public abstract bool IsCompatible(MibValue value);
/// <summary>Returns a value symbol from this MIB.</summary> /// <param name="value">The symbol value to look up</param> /// <returns> the MIB value symbol, or null if not found</returns> public MibValueSymbol GetSymbolByValue(MibValue value) { return(this.symbolValueMap[value.ToString()]); }
/// <summary>Returns a value symbol from this MIB.</summary> /// <param name="value">The symbol value to look up</param> /// <returns> the MIB value symbol, or null if not found</returns> public MibValueSymbol GetSymbolByValue(MibValue value) { this.symbolValueMap.TryGetValue(value.ToString(), out MibValueSymbol ms); return(ms); }