Exemple #1
0
            public override BuilderConfiguration ResolveOption(string name)
            {
                if (this._options == null || string.IsNullOrEmpty(name))
                {
                    return(base.ResolveOption(name));
                }

                string config;

                if (!this._options.TryGetValue(name, out config))
                {
                    return(base.ResolveOption(name));
                }

                if (string.IsNullOrEmpty(config))
                {
                    return(base.ResolveOption(name));
                }

                var path = BuilderWindow.BuildConfigurationsDir + config + ".json";

                if (!File.Exists(path))
                {
                    return(base.ResolveOption(name));
                }

                var result = new BuilderConfiguration();

                result.name = config;
                result.FromJson(JObject.Parse(File.ReadAllText(path)));
                return(result);
            }
        private BuilderConfiguration LoadConfiguration(string name)
        {
            var config = new BuilderConfiguration();

            config.name = name;

            string path = BuildConfigurationsDir + name + ".json";

            if (File.Exists(path))
            {
                config.FromJson(JObject.Parse(File.ReadAllText(path)));
            }
            else
            {
                config.InitializeNew();
            }

            return(config);
        }
        private void CopyConfiguration()
        {
            if (this._currentConfiguration == null)
            {
                return;
            }
            var obj = new JObject();

            this._currentConfiguration.ToJson(obj);

            string nameBase = this._currentConfiguration.name;
            string name     = nameBase;
            string path     = null;
            int    i        = 0;

            while (true)
            {
                path = BuildConfigurationsDir + name + ".json";
                if (!File.Exists(path))
                {
                    break;
                }

                name = nameBase + (++i).ToString();
            }

            var config = new BuilderConfiguration();

            config.name = name;
            config.FromJson(obj);
            File.WriteAllText(path, obj.ToString(Newtonsoft.Json.Formatting.Indented), Encoding.UTF8);

            this._currentConfigurationName  = name;
            this._currentConfiguration      = config;
            this._currentConfigurationDirty = false;
        }