getMessage() public static method

public static getMessage ( String messageKey ) : String
messageKey String
return String
Beispiel #1
0
        public static bool OpenFile(out byte[] byteContent, out FileInfo fileInfo, String filter)
        {
            bool fileOpened = false;

            fileInfo    = null;
            byteContent = new byte[] {};
            string fileName    = "";
            var    openFileDlg = new OpenFileDialog();

            openFileDlg.Filter           = filter;
            openFileDlg.FilterIndex      = 1;
            openFileDlg.RestoreDirectory = false;


            if (openFileDlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    fileName    = openFileDlg.FileName;
                    fileInfo    = new FileInfo(fileName);
                    byteContent = File.ReadAllBytes(fileName);
                    fileOpened  = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format(MessageManager.getMessage("FileManager.ReadFileError"), ex.Message));
                }
            }
            return(fileOpened);
        }
        /**
         * Returns a Cache object determined by the name provided. If no cache exists for the name provided, an Exception will be thrown.
         * @param name The name of the Cache object to return
         * @throws Exception if the cache object does not exist for the name provided.
         */

        public static Cache getCache(String name)
        {
            if (!getInstance().cacheMap.ContainsKey(name))
            {
                throw new Exception(String.Format(MessageManager.getMessage("CacheManager.noCacheError"), name));
            }
            return(getInstance().cacheMap[name]);
        }
Beispiel #3
0
        /**
         * Call to open a file. This method will open the Open File Dialog using the filter provided.
         * @param out xmlContent - will contain the xml file contents
         * @param out fileName - will contain the selected file name
         * @param filter - file filter to use to restrict files listed for selection.
         */
        public static bool OpenFile(out String xmlContent, out String fileName, String filter)
        {
            bool fileOpened = false;

            xmlContent = "";
            fileName   = "";
            Stream inputStream = null;
            var    openFileDlg = new OpenFileDialog();

            openFileDlg.Filter           = filter;
            openFileDlg.FilterIndex      = 1;
            openFileDlg.RestoreDirectory = false;

            if (openFileDlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    fileName = openFileDlg.FileName;
                    if ((inputStream = openFileDlg.OpenFile()) != null)
                    {
                        using (inputStream)
                        {
                            var reader = new StreamReader(inputStream);
                            xmlContent = reader.ReadToEnd();
                            reader.Close();
                            fileOpened = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format(MessageManager.getMessage("FileManager.ReadFileError"), ex.Message));
                }
            }
            return(fileOpened);
        }