コード例 #1
0
ファイル: Interpreters.cs プロジェクト: acken/OpenIDE
        private void readInterpreters(Configuration config)
        {
            var prefix = "interpreter.";
            foreach (var interpreter in config.GetSettingsStartingWith(prefix)) {
                if (interpreter.Key.Length <= prefix.Length)
                    continue;

                var extension =
                    interpreter.Key
                        .Substring(
                            prefix.Length,
                             interpreter.Key.Length - prefix.Length);
                if (extension.Length == 0)
                    continue;

                extension = "." + extension;
                var path = interpreter.Value;
                if (Environment.OSVersion.Platform != PlatformID.Unix &&
                    Environment.OSVersion.Platform != PlatformID.MacOSX) {
                    path.Replace("/", "\\");
                }
                if (!File.Exists(path)) {
                    path =
                        System.IO.Path.Combine(
                            System.IO.Path.GetDirectoryName(
                                Assembly.GetExecutingAssembly().Location),
                            path);
                    if (!File.Exists(path))
                        continue;
                }
                if (!_interpreters.ContainsKey(extension))
                    _interpreters.Add(extension, path);
            }
        }
コード例 #2
0
ファイル: Interpreters.cs プロジェクト: acken/OpenIDE
 public Interpreters(string token)
 {
     _token = token;
     var local = new Configuration(_token, false);
     var global =
         new Configuration(
             Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
             , false);
     readInterpreters(local);
     readInterpreters(global);
 }
コード例 #3
0
ファイル: ConfigurationTests.cs プロジェクト: acken/OpenIDE
 public void Setup()
 {
     var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     _config = new Configuration(basePath, false);
     var file = Configuration.GetConfigFile(basePath);
     if (file != null)
         File.Delete(file);
     var dir = Path.Combine(basePath, ".OpenIDE");
     if (!Directory.Exists(dir))
         Directory.CreateDirectory(dir);
     File.WriteAllText(Path.Combine(dir, "oi.config"), "");
 }
コード例 #4
0
ファイル: Bootstrapper.cs プロジェクト: robertpi/OpenIDE
        public AppSettings(string path, Func<IEnumerable<ICommandHandler>> handlers, Func<IEnumerable<ICommandHandler>> pluginHandlers)
        {
            _path = path;
            var locator = new ProfileLocator(Environment.CurrentDirectory);
            RootPath = locator.GetLocalProfilePath("default");
            if (RootPath == null)
                RootPath = Directory.GetCurrentDirectory();
            else
                RootPath = System.IO.Path.GetDirectoryName(RootPath);

            var local = new Configuration(Directory.GetCurrentDirectory(), false);
            var global = new Configuration(_path, false);

            if (local.DefaultLanguage != null)
                DefaultLanguage = local.DefaultLanguage;
            else if (global.DefaultLanguage != null)
                DefaultLanguage = global.DefaultLanguage;

            if (local.EnabledLanguages != null)
                EnabledLanguages = local.EnabledLanguages;
            else if (global.EnabledLanguages != null)
                EnabledLanguages = global.EnabledLanguages;
        }
コード例 #5
0
 private void printClosestConfiguration(string path)
 {
     var file = new Configuration(path, true).ConfigurationFile;
     if (!File.Exists(file))
         return;
     Console.WriteLine("Configuration file: {0}", file);
     Console.WriteLine("");
     File.ReadAllLines(file).ToList()
         .ForEach(x =>
             {
                 Console.WriteLine("\t" + x);
             });
 }
コード例 #6
0
        private void updateConfiguration(string path, string[] arguments)
        {
            var args = parseArguments(arguments);
            if (args == null)
                return;

            if (args.Global)
                path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (!Configuration.IsConfigured(path))
            {
                Console.WriteLine("There is no config point at " + path);
                return;
            }

            var config = new Configuration(path, false);
            Console.WriteLine("Writing to " + config.ConfigurationFile);
            Console.WriteLine("\t{0} setting: {1}",
                args.Delete ? "Deleting" : "Updating",
                args.Setting);

            if (args.Delete)
                config.Delete(args.Setting);
            else
                config.Write(args.Setting);
        }
コード例 #7
0
        private void updateConfiguration(string path, string[] arguments)
        {
            var args = parseArguments(arguments);
            if (args == null)
                return;

            if (args.Global)
                path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (!Configuration.IsConfigured(path))
            {
                Console.WriteLine("There is no config point at " + path);
                return;
            }

            var config = new Configuration(path, false);
            if (args.Delete) {
                config.Delete(args.Settings[0]);
                _eventDispatcher(
                    string.Format(
                        "builtin configitem deleted \"{0}\" \"{1}\"",
                        path,
                        args.Settings[0]));
            } else {
                config.Write(args.Settings[0]);
                _eventDispatcher(
                    string.Format(
                        "builtin configitem updated \"{0}\" \"{1}\"",
                        path,
                        args.Settings[0]));
            }
        }
コード例 #8
0
        private void printClosestConfiguration(string path, string[] arguments)
        {
            var args = parseArguments(arguments);
            if (args == null)
                return;
            if (args.Global)
                path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var file = new Configuration(path, true).ConfigurationFile;
            if (!File.Exists(file))
                return;
            string pattern =  null;
            var wildcard = false;
            if (args.Settings.Length == 2)
                pattern = args.Settings[1];
            if (pattern == null) {
                Console.WriteLine("Configuration file: {0}", file);
                Console.WriteLine("");
                File.ReadAllLines(file).OrderBy(x => x).ToList()
                    .ForEach(x => {
                            Console.WriteLine("\t" + x);
                        });
                return;
            }
            if (pattern == "cfgpoint") {
                Console.Write(Path.GetDirectoryName(file));
                return;
            }
            if (pattern == "rootpoint") {
                Console.Write(Path.GetDirectoryName(new ProfileLocator(path).GetLocalProfilesRoot()));
                return;
            }
            if (pattern == "cfgfile") {
                Console.Write(file);
                return;
            }
            if (pattern.EndsWith("*")) {
                wildcard = true;
                pattern = pattern.Substring(0, pattern.Length - 1);
            }
            if (wildcard) {
                foreach (var item in new ConfigReader(Path.GetDirectoryName(file)).GetStartingWith(pattern).OrderBy(x => x.Key)) {
                    Console.WriteLine("{0}={1}", item.Key, item.Value);
                }
            } else {
                Console.WriteLine(new ConfigReader(Path.GetDirectoryName(file)).Get(pattern));
            }
        }
コード例 #9
0
ファイル: ConfigReader.cs プロジェクト: acken/OpenIDE
 private void valuesFromConfig(string path, string name, List<ConfigurationSetting> results)
 {
     var cfg = new Configuration(path, false);
     cfg.GetSettingsStartingWith(name).ToList()
         .ForEach(x => {
                 if (!results.Any(y => y.Key == x.Key))
                     results.Add(x);
             });
 }
コード例 #10
0
ファイル: ConfigReader.cs プロジェクト: acken/OpenIDE
 private string valueFromConfig(string path, string name)
 {
     var cfg = new Configuration(path, false);
     var setting = cfg.Get(name);
     if (setting == null)
         return null;
     return setting.Value;
 }
コード例 #11
0
ファイル: ConfigReader.cs プロジェクト: acken/OpenIDE
 private List<string> mergeKeys(string path, List<string> keys)
 {
     var cfg = new Configuration(path, false);
     var configKeys = cfg.GetKeys();
     if (configKeys == null)
         return keys;
     foreach (var key in configKeys) {
         if (!keys.Contains(key))
             keys.Add(key);
     }
     return keys;
 }
コード例 #12
0
ファイル: ConfigurationHandler.cs プロジェクト: acken/OpenIDE
 private void printConfigurationOptions(string path)
 {
     var file = new Configuration(path, true).ConfigurationFile;
     var paths = new List<string>();
     paths.Add(
         Path.Combine(
             Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
             "EditorEngine"));
     paths.Add(Path.GetDirectoryName(file));
     foreach (var plugin in _pluginLocator.Locate())
         paths.Add(plugin.GetPluginDir());
     var reader = new ConfigOptionsReader(paths.ToArray());
     reader.Parse();
     foreach (var line in reader.Options.OrderBy(x => x))
         Console.WriteLine(line);
 }
コード例 #13
0
 private void valuesFromConfig(string path, string name, List<ConfigurationSetting> results)
 {
     if (path == null)
         return;
     var cfgfile = Path.Combine(path, "oi.config");
     var cfg = new Configuration(cfgfile, false);
     cfg.GetSettingsStartingWith(name).ToList()
         .ForEach(x => {
                 if (!results.Any(y => y.Key == x.Key))
                     results.Add(x);
             });
 }
コード例 #14
0
 private string valueFromConfig(string path, string name)
 {
     if (path == null)
         return null;
     var cfgfile = Path.Combine(path, "oi.config");
     var cfg = new Configuration(cfgfile, false);
     var setting = cfg.Get(name);
     if (setting == null)
         return null;
     return setting.Value;
 }
コード例 #15
0
 private List<string> mergeKeys(string path, List<string> keys)
 {
     if (path == null)
         return keys;
     var cfgfile = Path.Combine(path, "oi.config");
     var cfg = new Configuration(cfgfile, false);
     Logger.Write("Reading: " + cfg.ConfigurationFile);
     var configKeys = cfg.GetKeys();
     if (configKeys == null)
         return keys;
     foreach (var key in configKeys) {
         if (!keys.Contains(key)) {
             Logger.Write("Adding key: " + key);
             keys.Add(key);
         }
     }
     return keys;
 }