Ejemplo n.º 1
0
        private BindingManager()
        {
            var bindingList = new List <Binding>();

            foreach (string fileName in Directory.GetFiles(Config.Config.BindingsDirectory + "\\", "*.txt"))
            {
                var bindingEntryList = new List <BindingEntry>();
                var orderOutput      = true;
                foreach (string line in File.ReadAllLines(fileName))
                {
                    // Skip comments
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    string[] parts = line.Split(' ');
                    // try to read first two words
                    if (parts.Length < 2)
                    {
                        continue;
                    }
                    var entry = new BindingEntry(parts);
                    if (entry.Type == BindingType.IGNORE_ORDER)
                    {
                        orderOutput = false;
                    }
                    else if (entry.Type != BindingType.UNKNOWN)
                    {
                        bindingEntryList.Add(entry);
                    }
                }
                if (bindingEntryList.Count == 0)
                {
                    continue;
                }
                var binding = new Binding(fileName, bindingEntryList, orderOutput);
                bindingList.Add(binding);
                Logger.Info($"Loaded binding {fileName} with {bindingEntryList.Count} fields.");
            }
            _bindings = bindingList;
            Logger.Info($"Loaded {bindingList.Count} bindings.");
        }
Ejemplo n.º 2
0
        private BindingManager()
        {
            var bindingList = new List <Binding>();
            var currentDir  = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

            foreach (string fileName in Directory.GetFiles(currentDir + "\\" + BindingsFolderName + "\\", "*.txt"))
            {
                var bindingEntryList = new List <BindingEntry>();
                foreach (string line in File.ReadAllLines(fileName))
                {
                    // Skip comments
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    string[] parts = line.Split(' ');
                    // try to read first two words
                    if (parts.Length < 2)
                    {
                        continue;
                    }
                    var entry = new BindingEntry(parts);
                    if (entry.Type != BindingType.UNKNOWN)
                    {
                        bindingEntryList.Add(entry);
                    }
                }
                if (bindingEntryList.Count == 0)
                {
                    continue;
                }
                var binding = new Binding(fileName, bindingEntryList);
                bindingList.Add(binding);
                Console.WriteLine($"Loaded binding {fileName} with {bindingEntryList.Count} fields.");
            }
            _bindings = bindingList;
            Console.WriteLine($"Loaded {bindingList.Count} bindings.");
        }