XULRunnerConfigDeserialize() public static method

JSON Deserialization
public static XULRunnerConfigDeserialize ( string path ) : XULRunnerConfig
path string
return XULRunnerConfig
Exemplo n.º 1
0
        /// <summary>
        /// Sets properties in config.json XULRunner configuration file.
        /// </summary>
        /// <returns></returns>
        public static bool SetXulRunnerConfiguration()
        {
            bool setXulRunnerConfiguration = false;

            try
            {
                // Get the path of the "Program Data" directory.
                string localAppDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                //string programDataDirectory = Environment.GetEnvironmentVariable("PROGRAMMDATA");

                // Set the location of the XULRunnerConfigFileDirectory
                StringBuilder xulRunnerConfigFileDirectoryBuilder = new StringBuilder(localAppDataDirectory).Append("\\").Append(MANUFACTURER_LOCAL).Append("\\");  //.Append(PRODUCT_NAME).Append("\\");
                XulRunnerConfigFileDirectory = xulRunnerConfigFileDirectoryBuilder.ToString();

                // Set the location of the config.json file
                StringBuilder xulRunnerConfigFileBuilder = new StringBuilder(XulRunnerConfigFileDirectory).Append(XUL_RUNNER_CONFIG);
                XulRunnerConfigFile = xulRunnerConfigFileBuilder.ToString();

                XULRunnerConfig xulRunnerConfig = SEBXulRunnerSettings.XULRunnerConfigDeserialize(XulRunnerConfigFile);
                xulRunnerConfig.seb_openwin_width  = Int32.Parse(SEBClientInfo.getSebSetting(SEBSettings.KeyNewBrowserWindowByLinkWidth)[SEBSettings.KeyNewBrowserWindowByLinkWidth].ToString());
                xulRunnerConfig.seb_openwin_height = Int32.Parse(SEBClientInfo.getSebSetting(SEBSettings.KeyNewBrowserWindowByLinkHeight)[SEBSettings.KeyNewBrowserWindowByLinkHeight].ToString());
                if ((Int32)SEBClientInfo.getSebSetting(SEBSettings.KeyBrowserViewMode)[SEBSettings.KeyBrowserViewMode] == (int)browserViewModes.browserViewModeWindow)
                {
                    xulRunnerConfig.seb_mainWindow_titlebar_enabled = true;
                }
                else
                {
                    xulRunnerConfig.seb_mainWindow_titlebar_enabled = false;
                }
                xulRunnerConfig.seb_url   = SEBClientInfo.getSebSetting(SEBSettings.KeyStartURL)[SEBSettings.KeyStartURL].ToString();
                setXulRunnerConfiguration = true;
                SEBXulRunnerSettings.XULRunnerConfigSerialize(xulRunnerConfig, XulRunnerConfigFile);
            }
            catch (Exception ex)
            {
                Logger.AddError("Error ocurred by setting XulRunner configuration.", null, ex, ex.Message);
            }

            return(setXulRunnerConfiguration);
        }
        public static bool SetXulRunnerConfiguration()
        {
            bool flag = false;

            try
            {
                SEBClientInfo.XulRunnerConfigFileDirectory = new StringBuilder(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)).Append("\\").Append("SafeExamBrowser").Append("\\").ToString();
                SEBClientInfo.XulRunnerConfigFile          = new StringBuilder(SEBClientInfo.XulRunnerConfigFileDirectory).Append("config.json").ToString();
                XULRunnerConfig objXULRunnerConfig = SEBXulRunnerSettings.XULRunnerConfigDeserialize(SEBClientInfo.XulRunnerConfigFile);
                objXULRunnerConfig.seb_openwin_width  = int.Parse(SEBClientInfo.getSebSetting("newBrowserWindowByLinkWidth")["newBrowserWindowByLinkWidth"].ToString());
                objXULRunnerConfig.seb_openwin_height = int.Parse(SEBClientInfo.getSebSetting("newBrowserWindowByLinkHeight")["newBrowserWindowByLinkHeight"].ToString());
                objXULRunnerConfig.seb_mainWindow_titlebar_enabled = (int)SEBClientInfo.getSebSetting("browserViewMode")["browserViewMode"] == 0;
                objXULRunnerConfig.seb_url = SEBClientInfo.getSebSetting("startURL")["startURL"].ToString();
                flag = true;
                SEBXulRunnerSettings.XULRunnerConfigSerialize(objXULRunnerConfig, SEBClientInfo.XulRunnerConfigFile);
            }
            catch (Exception ex)
            {
                Logger.AddError("Error ocurred by setting XulRunner configuration.", (object)null, ex, ex.Message);
            }
            return(flag);
        }