Пример #1
0
        /// <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);
        }
Пример #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);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
 /// <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;
 }
Пример #6
0
 /// <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;
 }