public JObject Apply(JObject json)
        {
            var profileId = _manager.CreateNewProfile();
            var profile   = _manager.GetProfile(profileId);

            var loader    = new JsonConfigLoader();
            var finalizer = new JsonValueToEnum();

            json = loader.LoadConfig(json);
            json = finalizer.Apply(json);

            profile.SetProperties(json);
            profile.SetProperty("profile.name", "Profile 1");

            var visibleChannels = profile.GetProperty <List <int> >("behaviour.channel.visible");

            visibleChannels.Add((int)0x01FFFF /*GOBCHAT_INFO*/);
            visibleChannels.Add((int)0x02FFFF /*GOBCHAT_ERROR*/);
            profile.SetProperty("behaviour.channel.visible", visibleChannels);

            var result = new JObject();

            result["version"]       = 2;
            result["activeProfile"] = profileId;
            return(result);
        }
Exemplo n.º 2
0
        public void Synchronize(JObject root)
        {
            if (!_writable)
            {
                throw new ConfigException("Config is read only");
            }

            var enumTransformer = new JsonValueToEnum();

            root = enumTransformer.Apply(root);

            var(changes, _)      = JsonUtil.RemoveUnused(root, _data, (path) => UnchangableValues.Contains(path));
            var(writeChanges, _) = JsonUtil.Overwrite(root, _data, (path) => UnchangableValues.Contains(path));

            changes.UnionWith(writeChanges);
            FirePropertyChange(changes, true);
        }