public TnsEntryType Add(TnsEntryType obj) { base.Add(obj); return obj; }
private void ProcessTnsEntry(string entry) { int openBracketIdx = 0; int closeBracketIdx = 0; int equaltoIdx = 0; TnsEntryType tnsEntry = new TnsEntryType(); openBracketIdx = entry.IndexOf('(', 0); tnsEntry.TnsnameEntry = entry.Substring(0, entry.IndexOf('=', 0) - 1).Trim(); while (openBracketIdx > 0) { equaltoIdx = entry.IndexOf('=', openBracketIdx); //get the token string token = entry.Substring((openBracketIdx + 1), (equaltoIdx - openBracketIdx - 1)); //Trim whitespaces token = token.Trim().ToUpper(); //if the current token is the one we are interested in //get the token value closeBracketIdx = entry.IndexOf(')', equaltoIdx); string tokenValue = entry.Substring((equaltoIdx + 1), (closeBracketIdx - equaltoIdx - 1)); //trim whitespaces tokenValue = tokenValue.Trim(); switch (token) { case "SERVICE_NAME": tnsEntry.ServiceName = tokenValue; break; case "HOST": tnsEntry.HostName = tokenValue; break; case "SID": tnsEntry.Sid = tokenValue; break; case "PORT": tnsEntry.PortNumber = int.Parse(tokenValue); break; } //get index of next open bracket openBracketIdx = entry.IndexOf('(', openBracketIdx + 1); } lock (_tnsEntries.SyncRoot) { _tnsEntries.Add(tnsEntry); } }