Products / Name Checker - Builder / API

Using the Name Checker / Builder component via API


In a .NET environment the VITNameCheckerLib can be used easily by adding a reference to the interface IVITNameCheckerLib.dll and the implementation VITNameCheckerLib.dll. After that the VITNameChecker can be initialized using three different ways.

Example 1: First possibility - load from XML file
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"C:\TEMP\Test\VITNameChecker.config");

// create Pattern Access
VisuIT.NameChecker.IVITPatternAccess accessPattern =
          VisuIT.NameChecker.VITXmlAccess.CreatePatternAccess(xDoc);

// create Catalog Access
VisuIT.NameChecker.IVITCatalogAccess accessCatalog =
          VisuIT.NameChecker.VITXmlAccess.CreateCatalogAccess(xDoc);

VITNameCheckerManager manager = new VITNameCheckerManager();
manager.InitNameChecker(accessPattern, accessCatalog);

Example 2: Second possibility - load from database
// create Pattern Access
VisuIT.NameChecker.IVITPatternAccess accessPattern =
          VisuIT.NameChecker.VITOracleAccess.CreatePatternAccess("DSN=ADD; UID=VIT_TEST; PWD=VIT_TEST");

// create Catalog Access
VisuIT.NameChecker.IVITCatalogAccess accessCatalog =
          VisuIT.NameChecker.VITOracleAccess.CreateCatalogAccess("DSN=ADD; UID=VIT_TEST; PWD=VIT_TEST");

VITNameCheckerManager manager = new VITNameCheckerManager();
manager.InitNameChecker(accessPattern, accessCatalog);

Example 3: Third possibility - load from database, get patterns from database
Get source for patterns and catalogs from ' XML settings
' <Database>
' <ReadPatternFromDatabase>1</ReadPatternFromDatabase>
' <ReadCatalogsFromDatabase>1</ReadCatalogsFromDatabase>
' <User>7dVFpUwNnFmyXrOQAifF2g==</User>
' <Password>7dVFpUwNnFmyXrOQAifF2g==</Password>
' <ConnectionString Provider="MSDAORA.1" DataSource="ORCL" />
' <DSN>ADD</DSN>
' <!-- Possible values: 'ConnectionString' or 'DSN' -->
' <UseConnectionType>DSN</UseConnectionType>
' <Description>VIT_REG_VISUIT</Description>
' </Database>
String strXMLFilePath = @"C:\TEMP\Test\VITNameChecker.config";
VITNameCheckerManager manager = new VITNameCheckerManager();
manager.InitNameChecker(strXMLFilePath);

Example 4: Check a given name
String strError, strValidName;
VisuIT.NameChecker.E_TYPE eType = VisuIT.NameChecker.E_TYPE.DO_TYPE_NO;

VisuIT.NameChecker.E_RESULT eResult = VisuIT.NameChecker.E_RESULT.NOT_VALID;
VisuIT.NameChecker.IVITNameChecker nameChecker=
          m_NameCheckerManager.NameCheckers["AUTOSAR"];
if (nameChecker != null)
        eResult = nameChecker.CheckName("VehPen_agm_C", out strValidName, eType, out strError, true, false);
Infobox