Esempio n. 1
0
        private TizenLaunchSettings ReadTizenSettingsFileFromDisk()
        {
            try
            {
                string  jsonString = FileManager.ReadAllText(TizenLaunchSettingsFile);
                var     tizenLaunchSettingsData = new TizenLaunchSettings();
                JObject jsonObject = JObject.Parse(jsonString);
                foreach (var pair in jsonObject)
                {
                    tizenLaunchSettingsData      = TizenLaunchSettings.DeserializeData((JObject)pair.Value);
                    tizenLaunchSettingsData.Name = Path.GetFileNameWithoutExtension(CommonProjectServices.Project.FullPath);
                }

                return(tizenLaunchSettingsData);
            }
            catch (JsonReaderException readerEx)
            {
                string err = string.Format("JsonErrorReadingLaunchSettings", readerEx.Message);
                //LogError(err, TizenLaunchSettingsFile, readerEx.LineNumber, readerEx.LinePosition, false);
                throw;
            }
            catch (JsonException jsonEx)
            {
                string err = string.Format("JsonErrorReadingLaunchSettings", jsonEx.Message);
                //LogError(err, TizenLaunchSettingsFile, -1, -1, false);
                throw;
            }
            catch (Exception ex)
            {
                string err = string.Format("ErrorReadingLaunchSettings", Path.Combine(TizenLaunchSettingsFileFolder, TizenLaunchSettingsFilename), ex.Message);
                //LogError(err, false);
                throw;
            }
        }
Esempio n. 2
0
        protected void SaveTizenSettingsToDisk(ITizenLaunchSettings newSettings)
        {
            var serializeData = new Dictionary <string, Dictionary <string, object> >(StringComparer.Ordinal);

            if (newSettings.Name != string.Empty)
            {
                serializeData.Add(newSettings.Name, TizenLaunchSettings.ToSerializableForm(newSettings));
            }

            try
            {
                EnsureSettingsFolder();

                JsonSerializerSettings settings = new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                };
                string jsonString = JsonConvert.SerializeObject(serializeData, Formatting.Indented, settings);

                IgnoreFileChanges = true;
                FileManager.WriteAllText(TizenLaunchSettingsFile, jsonString);
            }
            catch (Exception ex)
            {
                string err = string.Format("The following error occurred when writing to the launch settings file '{0}'. {1}", TizenLaunchSettingsFile, ex.Message);
                throw;
            }
            finally
            {
                IgnoreFileChanges = false;
            }
        }
Esempio n. 3
0
        protected TizenLaunchSettings GetTizenLaunchSettings()
        {
            TizenLaunchSettings tizenLaunchSettingsData;

            if (FileManager.FileExists(TizenLaunchSettingsFile))
            {
                tizenLaunchSettingsData = ReadTizenSettingsFileFromDisk();
            }
            else
            {
                tizenLaunchSettingsData = new TizenLaunchSettings();
            }

            return(tizenLaunchSettingsData);
        }
        public static TizenLaunchSettings DeserializeData(JObject launchObject)
        {
            TizenLaunchSettings tizenLaunchSettings = new TizenLaunchSettings();

            if (launchObject == null)
            {
                return(tizenLaunchSettings);
            }

            tizenLaunchSettings = JsonConvert.DeserializeObject <TizenLaunchSettings>(launchObject.ToString());

            /*
             * foreach (var setting in launchObject)
             * {
             *  tizenLaunchSettings = JsonConvert.DeserializeObject<TizenLaunchSettings>(setting.ToString());
             * }*/
            return(tizenLaunchSettings);
        }