/// <summary> /// Opens entity utility functions. This opens an entity translation file /// referred to via the Backsight property <see cref="PropertyNaming.EntityFile"/> /// (if there is such a definition). It then reads the file into an /// <see cref="EntityFile"/> object for later use. /// <para/> /// Also opens a style file referred to via the property /// <see cref="PropertyNaming.StyleFile"/> (if there is such a definition). /// It then reads the file into a <see cref="StyleFile"/> object for later use. /// </summary> /// <returns>True if an entity file and/or style file was loaded.</returns> /// <remarks> /// This function should be called near the start of the application. To release /// the resources, a subsequent call to <see cref="Close"/> should be made. /// </remarks> internal bool Open() { // Ensure any files previously loaded have been released. Close(); s_EntityFile = OpenEntityFile(); s_StyleFile = OpenStyleFile(); return (s_EntityFile!=null || s_StyleFile!=null); }
/// <summary> /// Also opens a style file referred to via the property /// <see cref="PropertyNaming.StyleFile"/> (if there is such a definition). /// It then reads the file into a <see cref="StyleFile"/> object for later use. /// </summary> /// <returns>The loaded style file (or null if no such file, or it could /// not be loaded). If the environment variable is undefined, you get back /// an object that represents an empty style file.</returns> StyleFile OpenStyleFile() { // Get the translation (if any) of the property // that refers to the standard style file. IProperty prop = EnvironmentContainer.FindPropertyByName(PropertyNaming.StyleFile); string stdfile = (prop == null ? null : prop.Value); if (String.IsNullOrEmpty(stdfile)) return new StyleFile(); // Create a new style file object, and ask it to load the file. StyleFile file = new StyleFile(); int nStyle = file.Create(stdfile); // Return the file if it loaded ok return (nStyle > 0 ? file : null); }
/// <summary> /// Releases any resources that were allocated via a prior /// call to <see cref="Open"/> /// </summary> internal void Close() { s_EntityFile = null; s_StyleFile = null; }