Code Examples‎ > ‎HV2 API Explore‎ > ‎

Catalogs

Please read Catalogs documentation to fully understand this documentation.

Opening Catalogs

The API can open managed & unmanaged catalogs as well as .mshx file catalogs.
There are 2 main classes (Catalog & CatalogRead) we need to access a catalog. Most of the other class/enums are used by the methods in these classes. First thing to do instantiate these 2 important classes. 

private Catalog     _catalog = new Catalog();
private CatalogRead _catalogRead = new CatalogRead();

To open a catalog we pass the catalog directory path and locale to the Open() method.
The locale parameter is a prioritized list of locales, but we normally want to pass in one specific locale.

String catalogPath = @"C:\ProgramData\Microsoft\HelpLibrary2\Catalogs\VisualStudio11";
String locale = "en-US";

_catalog.Open(catalogPath, new String[] { locale });

To open a .mshx file we use the OpenMshx() method.

String catalogPath = "c:\somePath\helpfile.mshx";
_catalog.OpenMshx(catalogPath);

Remember to close catalogs. In this example app we check if the catalog is open and close it before opening another catalog.

if (_catalog.IsOpen)
    _catalog.Close();


Catalogs Page

The Catalogs page contains a list of VS 11 managed catalogs. You can also add to this list unmanaged catalog folders and .mshx catalog files.

The main purpose of the page is to open and close catalogs. Access to catalog data can not happen until we open a catalog.
We also demonstrate the other catalog methods.
  • string ContentPath { get; } -- Displays the full path to the Content Store folder of the open catalog. EG. <catalogPath>\ContentStore\
  • bool IsOpen { get; } -- Returns True if the catalog is open.
  • void Open(string path, string[] prioritizedLocales) -- Open a catalog folder.
  • void OpenMshx(string path) -- Open a .mshx catalog file.
  • void Close()  -- Close the catalog.
  • ICatalogReadWriteLock GetReadWriteLock(string catalogPath)  -- Returns locking information for the specified catalog.
  • int IsLanguageSupportAvailable(string lang) -- Pass in a locale such as "en-US". The method returns 0 if the language is support by Windows.


Comments