Ejemplo n.º 1
0
        public void ParseOfflinePluginVersioning(PluginVersioning onlineVersion)
        {
            foreach (var plugin in onlineVersion.Plugins)
            {
                var offlinePlugin = new PluginDatastore();

                var strPluginNamesRaw = plugin.DownloadPath.Split('/');
                var strPluginName = strPluginNamesRaw[strPluginNamesRaw.Length - 1];

                offlinePlugin.DownloadPath = Path.Combine(Application.StartupPath, "Plugins", strPluginName);
                if (File.Exists(offlinePlugin.DownloadPath))
                {
                    offlinePlugin.Name = Path.GetFileNameWithoutExtension(offlinePlugin.DownloadPath);

                    if (offlinePlugin.DownloadPath.EndsWith(".lang"))
                    {
                        using (var sr = new StreamReader(offlinePlugin.DownloadPath))
                        {
                            var strVersionLine = sr.ReadLine();

                            if (strVersionLine != null)
                                offlinePlugin.Version = strVersionLine.Substring(1);
                        }
                    }

                    else
                    {
                        offlinePlugin.Version = FileVersionInfo.GetVersionInfo(offlinePlugin.DownloadPath).FileVersion;
                    }

                    offlinePlugin.Hash = Hashes.HashFromFile(offlinePlugin.DownloadPath, Hashes.HashAlgorithm.Md5);
                    Plugins.Add(offlinePlugin);
                }
            }
        }
Ejemplo n.º 2
0
        public void ParseOfflinePluginVersioning(PluginVersioning onlineVersion)
        {
            foreach (var plugin in onlineVersion.Plugins)
            {
                var offlinePlugin = new PluginDatastore();

                var strPluginNamesRaw = plugin.DownloadPath.Split('/');
                var strPluginName     = strPluginNamesRaw[strPluginNamesRaw.Length - 1];

                offlinePlugin.DownloadPath = Path.Combine(Application.StartupPath, "Plugins", strPluginName);
                if (File.Exists(offlinePlugin.DownloadPath))
                {
                    offlinePlugin.Name = Path.GetFileNameWithoutExtension(offlinePlugin.DownloadPath);

                    if (offlinePlugin.DownloadPath.EndsWith(".lang"))
                    {
                        using (var sr = new StreamReader(offlinePlugin.DownloadPath))
                        {
                            var strVersionLine = sr.ReadLine();

                            if (strVersionLine != null)
                            {
                                offlinePlugin.Version = strVersionLine.Substring(1);
                            }
                        }
                    }

                    else
                    {
                        offlinePlugin.Version = FileVersionInfo.GetVersionInfo(offlinePlugin.DownloadPath).FileVersion;
                    }

                    offlinePlugin.Hash = Hashes.HashFromFile(offlinePlugin.DownloadPath, Hashes.HashAlgorithm.Md5);
                    Plugins.Add(offlinePlugin);
                }
            }
        }