Skip to content

radtek/TnsNames

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oracle TNS names library for .NET

Main function of the library is parsing/reading of Oracle TNS names files. The library also aids in resolving TNS names files on the local machine.

A console application is provided that lists all available TNS names files and their TNS name entries. It uses Costura.Fody in the build process to embed all dll files inside the exe. This makes for a neat standalone / single file program.

Binaries for the library are provided as a NuGet package. The console application can be found under releases.

Prerequisite for compilation is Visual Studio extension ANTLR Language Support.

Design notes

The library will catch syntax errors, but there are only a few symantic checks:

  • Port numbers is ensured to be integer in range 1 to 65535.
  • A TNS name must have at least one database address.
  • All properties are ensured to have a value (TnsName, ServiceName, Protocol, Host, Port etc.).

Code examples

    /* NOTE
     * differentiation between TnsNamesFileInfo (file not opened) and 
     * TnsNamesFile (file opened and information extracted)
     */

    // get TnsNamesFileInfo for files
    var rootFilesInfos = TnsNames.ResolveRootTnsNamesFiles();
    
    // open files and recursivly open IFile entries
    var allFiles = TnsNames.OpenTnsNamesFiles(rootFilesInfos, ignoreErrors: true, followIFileEntries: true);
    
    // enumerate files and TNS name entries
    foreach (var tnsNamesFile in allFiles)
    {
    	foreach (var tnsName in tnsNamesFile.TnsNames)
        {
        	// process TNS name entry
        }
    }
Code example: enumerate TNS name entries with extension method
    foreach (var tnsName in allFiles.EnumerateTnsNames())
    {
        // process TNS name entry
    }

Developer notes

The TnsNames project include files from obj\ folder. This being unusal is a trick to get ReSharper working correctly in conjunction with ANTLR and the autogenerated parser code.

Dependencies

  • ANTLR 4

Links:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.8%
  • Other 0.2%