public bool RetrieveOidInfo(OidInfoList lstOidInfo) { if (!IsError) { ProcessFile(lstOidInfo); } return(!IsError); }
/// <summary> /// does the initial work of parsing the input file /// </summary> /// <param name="lstOidInfo">OidInfoList</param> private void ProcessFile(OidInfoList lstOidInfo) { FileStream fs = null; // NAME, OID, INDEXES_SUPPORTED, INDEXES_NOT_SUPPORTED, EXPECTED_VALUE,READABLE, WRITABLE, DATA_TYPE, VALID_SET_VALUE, INVALID_SET_VALUE, IMPLEMENTATION, CAPABILITY try { fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); if (IsHeaderLine(sr.ReadLine())) { while (sr.Peek() != -1) { string line = sr.ReadLine(); string[] buffer = line.Split(','); if (buffer.Length == (int)SNMP_TITLES.Count) { OidInfo oi = new OidInfo(); oi.NameOid = buffer[(int)SNMP_TITLES.Name]; oi.OIDValue = buffer[(int)SNMP_TITLES.OID]; ParseSupportedIndexes(oi, buffer[(int)SNMP_TITLES.SupportedIndexes]); ParseNonSupportedIndexes(oi, buffer[(int)SNMP_TITLES.NonSupportedIndexes]); oi.ExpectedValue = buffer[(int)SNMP_TITLES.ExpectedValues]; oi.IsReadable = GetIsReadWriteable(buffer[(int)SNMP_TITLES.Readable]); oi.IsWriteable = GetIsReadWriteable(buffer[(int)SNMP_TITLES.Writeable]); oi.DataType = GetDataType(buffer[(int)SNMP_TITLES.DataType]); ParseValidSetValues(oi, buffer[(int)SNMP_TITLES.ValidSetValue]); oi.InvalidSetValue = buffer[(int)SNMP_TITLES.InvalidSetValue]; oi.Implementation = buffer[(int)SNMP_TITLES.Implementation]; oi.Capability = GetCapability(buffer[(int)SNMP_TITLES.Capability]); if (!IsError) { lstOidInfo.Add(oi); } } } } } catch (FileNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (DirectoryNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (IOException e) { GetLastError = e.JoinAllErrorMessages(); } finally { if (fs != null) { fs.Close(); } } }