Esempio n. 1
0
        void SharedRepositoryModelDisplay(RepositoryViewModel model)
        {
            var repo    = model.Repository;
            var appUser = User.GetAppUser();

            model.SettingsJson = repo.Settings;
            if (!string.IsNullOrEmpty(model.SettingsJson))
            {
                try
                {
                    model.SettingsJson = JsonSerializationUtils.FormatJsonString(repo.Settings);
                }
                catch { }
            }

            model.TableOfContentsJson = repo.TableOfContents;
            if (!string.IsNullOrEmpty(model.TableOfContentsJson))
            {
                try
                {
                    model.TableOfContentsJson = JsonSerializationUtils.FormatJsonString(repo.TableOfContents);
                }
                catch { }
            }

            if (!appUser.IsEmpty())
            {
                model.IsOwner = _repoBusiness.IsOwner(repo, appUser.UserId);
            }
        }
Esempio n. 2
0
        public void PrettifyJsonStringTest()
        {
            var test = new
            {
                name    = "rick",
                company = "Westwind",
                entered = DateTime.UtcNow
            };

            string json = JsonConvert.SerializeObject(test);

            Console.WriteLine(json);


            string jsonFormatted = JsonSerializationUtils.FormatJsonString(json);

            //string jsonFormatted = JValue.Parse(json).ToString(Formatting.Indented);

            //JValue.Parse()
            Console.WriteLine(jsonFormatted);
        }