Exemplo n.º 1
0
        private GameInfo ResolveInfo()
        {
            var instance = CreateInstance();

            instance.Load();

            GameInfo info = new GameInfo()
            {
                Name    = string.IsNullOrWhiteSpace(instance.Config?.Name) ? GameType.Name : instance.Config.Name,
                Author  = string.Empty,
                Version = string.Empty,
                Maps    = instance.Config.RequiresMap ? instance.Config.Maps : null
            };

            var gameAttribute = GameType.GetCustomAttribute <GameAttribute>();

            if (gameAttribute != null)
            {
                if (!string.IsNullOrWhiteSpace(gameAttribute.Name))
                {
                    info.Name = gameAttribute.Name;
                }

                if (!string.IsNullOrWhiteSpace(gameAttribute.Author))
                {
                    info.Author = gameAttribute.Author;
                }

                if (!string.IsNullOrWhiteSpace(gameAttribute.Version))
                {
                    info.Version = gameAttribute.Version;
                }
            }

            instance.Dispose();

            return(info);
        }