1 /* 2 * Created by SharpDevelop. 3 * User: lextm 4 * Date: 2008/5/31 5 * Time: 12:07 6 * 7 * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 */ 9 10 using System.Collections.Generic; 11 12 namespace Lextm.SharpSnmpLib.Mib.Elements 13 { 14 /// <summary> 15 /// The IMPORTS construct is used to specify items used in the current MIB module which are defined in another MIB module or ASN.1 module. 16 /// </summary> 17 public sealed class Imports : List<ImportsFrom>, IElement 18 { 19 private IModule _module; 20 21 /// <summary> 22 /// Creates an <see cref="Imports"/> instance. 23 /// </summary> 24 /// <param name="lexer"></param> Imports(IModule module, ISymbolEnumerator symbols)25 public Imports(IModule module, ISymbolEnumerator symbols) 26 { 27 _module = module; 28 29 Symbol current; 30 while ((current = symbols.NextSymbol()) != Symbol.Semicolon) 31 { 32 if (current == Symbol.EOL) 33 { 34 continue; 35 } 36 37 ImportsFrom imports = new ImportsFrom(current, symbols); 38 39 this.Add(imports); 40 } 41 } 42 43 public IList<string> Dependents 44 { 45 get 46 { 47 List<string> result = new List<string>(); 48 49 foreach (ImportsFrom import in this) 50 { 51 result.Add(import.Module); 52 } 53 54 return result; 55 } 56 } 57 GetImportFromType(string type)58 public ImportsFrom GetImportFromType(string type) 59 { 60 foreach (ImportsFrom import in this) 61 { 62 if (import.Types.Contains(type)) 63 { 64 return import; 65 } 66 } 67 68 return null; 69 } 70 71 #region IElement Member 72 73 public IModule Module 74 { 75 get { return _module; } 76 } 77 78 #endregion 79 80 } 81 }