Ejemplo n.º 1
0
        public static Dictionary <int, AppInfo> LoadApps(string path)
        {
            Dictionary <int, AppInfo>      appInfos = new Dictionary <int, AppInfo>();
            Dictionary <uint, AppInfoNode> appInfoNodes;

            try
            {
                appInfoNodes = new AppInfoReader(path).Items;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            try
            {
                foreach (AppInfoNode appInfoNode in appInfoNodes.Values)
                {
                    AppInfo appInfo = FromNode(appInfoNode);
                    if (appInfo != null)
                    {
                        appInfos.Add(appInfo.AppId, appInfo);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(appInfos);
        }
Ejemplo n.º 2
0
        public static Dictionary <int, AppInfo> LoadApps(string path)
        {
            Dictionary <int, AppInfo>      appInfos = new Dictionary <int, AppInfo>();
            Dictionary <uint, AppInfoNode> appInfoNodes;

            try
            {
                /*
                 * string currentHash = Utility.CalculateMD5(path);
                 *
                 * if (!File.Exists(Location.File.AppInfoCache) || !File.Exists(Location.File.AppInfoHash) || (File.ReadAllText(Location.File.AppInfoHash) != currentHash))
                 * {
                 */
                appInfoNodes = new AppInfoReader(path).Items;

                /*
                 *      File.WriteAllText(Location.File.AppInfoCache, JsonConvert.SerializeObject(appInfoNodes));
                 *      File.WriteAllText(Location.File.AppInfoHash, currentHash);
                 * }
                 * else
                 * {
                 *      appInfoNodes = JsonConvert.DeserializeObject<Dictionary<uint, AppInfoNode>>(File.ReadAllText(Location.File.AppInfoCache));
                 * }
                 */
            }
            catch (Exception e)
            {
                SentryLogger.Log(e);
                throw;
            }

            try
            {
                foreach (AppInfoNode appInfoNode in appInfoNodes.Values)
                {
                    AppInfo appInfo = FromNode(appInfoNode);
                    if (appInfo != null)
                    {
                        appInfos.Add(appInfo.AppId, appInfo);
                    }
                }
            }
            catch (Exception e)
            {
                SentryLogger.Log(e);
                throw;
            }

            return(appInfos);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Parses the appinfo.vdf file and converts it into a dictionary where the key equals the AppId and value is the
        ///     AppInfo object.
        /// </summary>
        /// <param name="path">
        ///     Path to the appinfo.vdf file.
        /// </param>
        /// <returns>
        ///     Returns a dictionary where the key equals the AppId and value is the AppInfo object.
        /// </returns>
        public static Dictionary <int, AppInfo> LoadApps(string path)
        {
            Dictionary <int, AppInfo> appInfos = new Dictionary <int, AppInfo>();

            if (string.IsNullOrWhiteSpace(path) || !File.Exists(path))
            {
                return(appInfos);
            }

            Dictionary <uint, AppInfoNode> appInfoNodes = new AppInfoReader(path).Items;

            foreach (AppInfoNode appInfoNode in appInfoNodes.Values)
            {
                AppInfo appInfo = FromNode(appInfoNode);
                if (appInfo != null)
                {
                    appInfos.Add(appInfo.Id, appInfo);
                }
            }

            return(appInfos);
        }