Exemplo n.º 1
0
        public Executable AddExecutable(string path = null)
        {
            Executable new_executable = new Executable()
            {
                Settings      = this,
                Name          = L.NewExecutableName,
                Path          = path,
                AllowCommands = false
            };

            Executables.Add(new_executable);
            return(new_executable);
        }
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var moniker    = "STOCK";
            var taskTypeId = itemTypeName + "Task";
            var monikers   = new[] { "clsid", "progid" };

            if (monikers.Contains(itemTypeName.ToLowerInvariant()))
            {
                moniker    = itemTypeName.ToUpperInvariant();
                taskTypeId = newItemValue.ToString();
            }


            var item = (TaskHost)_items.Add(moniker + ":" + taskTypeId);

            item.Name = path;

            var resolvedItem = context.ResolvePath(context.Path);

            return(resolvedItem.GetNodeValue());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses all games for a given system.
        /// </summary>
        ///
        /// <remarks>
        /// "Parsing" means reading and unmarshalling the given XML file in the
        /// system's database folder.
        /// </remarks>
        ///
        /// <param name="databaseFile">XML file to parse</param>
        /// <returns>Parsed games</returns>
        private List <PinballXGame> ParseGames([NotNull] string databaseFile)
        {
            var xmlPath = Path.Combine(DatabasePath, databaseFile);
            var games   = new List <PinballXGame>();

            if (_dir.Exists(DatabasePath))
            {
                var menu = _marshallManager.UnmarshallXml(xmlPath);
                var remainingExecutables = Executables.ToList();
                menu.Games.ForEach(game => {
                    // update links
                    game.System       = this;
                    game.DatabaseFile = databaseFile;

                    // update executables
                    var executable = game.AlternateExe != null && game.AlternateExe.Trim() != "" ? game.AlternateExe : DefaultExecutableLabel;
                    if (!Executables.Contains(executable))
                    {
                        _logger.Debug("Adding new alternate executable \"{0}\" to system \"{1}\"", executable, Name);
                        _threadManager.MainDispatcher.Invoke(() => Executables.Add(executable));
                    }
                    else
                    {
                        if (remainingExecutables.Contains(executable))
                        {
                            remainingExecutables.Remove(executable);
                        }
                    }
                });
                _logger.Debug("Removing alternate executables [ \"{0}\" ] from system \"{1}\"", string.Join("\", \"", remainingExecutables), Name);
                _threadManager.MainDispatcher.Invoke(() => Executables.RemoveAll(remainingExecutables));
                _threadManager.MainDispatcher.Invoke(() => Executables.Sort(string.Compare));

                games.AddRange(menu.Games);
            }
            _logger.Debug("Parsed {0} games from {1}.", games.Count, xmlPath);
            return(games);
        }
Exemplo n.º 4
0
        public void Read(string path)
        {
            FileEntity f = new FileEntity(path, "UTF-8");

            f.Read();
            foreach (string l in f.Get)
            {
                if (0 > l.IndexOf("\t"))
                {
                    continue;
                }
                string left  = l.Split("\t".ToCharArray())[0];
                string right = l.Split("\t".ToCharArray())[1];
                switch (left)
                {
                case DEFINE_FUNCTION:
                    Functions.Add(right);
                    break;

                case DEFINE_PACKAGEBODY:
                    PackageBodies.Add(right);
                    break;

                case DEFINE_PACKAGE:
                    Packages.Add(right);
                    break;

                case DEFINE_PROCEDURE:
                    Procedures.Add(right);
                    break;

                case DEFINE_TABLE:
                    Tables.Add(right);
                    break;

                case DEFINE_TRIGGER:
                    Triggers.Add(right);
                    break;

                case DEFINE_VIEW:
                    Views.Add(right);
                    break;

                default:
                    break;
                }
            }
            foreach (string item in Functions)
            {
                Executables.Add(item);
            }
            foreach (string item in PackageBodies)
            {
                Executables.Add(item);
            }
            foreach (string item in Packages)
            {
                Executables.Add(item);
            }
            foreach (string item in Procedures)
            {
                Executables.Add(item);
            }
            foreach (string item in Tables)
            {
                Selectables.Add(item);
            }
            foreach (string item in Views)
            {
                Selectables.Add(item);
            }
        }