예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// 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.
        /// </summary>
        /// <returns>The loaded entity translation file (or null if no such file, or
        /// it could not be loaded).</returns>
        EntityFile OpenEntityFile()
        {
            // Get the translation (if any) of the property
            // that refers to the entity file.
            IProperty prop    = EnvironmentContainer.FindPropertyByName(PropertyNaming.EntityFile);
            string    entfile = (prop == null ? null : prop.Value);

            if (String.IsNullOrEmpty(entfile))
            {
                return(null);
            }

            // Open the entity file.
            using (StreamReader sr = File.OpenText(entfile))
            {
                // Create a new entity file object, and ask it to load the file.
                EntityFile file   = new EntityFile();
                int        nblock = file.Create(sr);

                // Return the file if it loaded ok
                return(nblock > 0 ? file : null);
            }
        }