Ejemplo n.º 1
0
 protected PluginData(PluginData original, Cloner cloner)
   : base(original, cloner) {
   if (original.Data != null) {
     this.Data = new byte[original.Data.Length];
     Array.Copy(original.Data, this.Data, original.Data.Length);
   }
   this.FileName = original.FileName;
   this.PluginId = original.PluginId;
 }
Ejemplo n.º 2
0
    public static List<PluginData> CreatePluginDatas(IPluginDescription plugin) {
      List<PluginData> pluginDatas = new List<PluginData>();

      foreach (IPluginFile pf in plugin.Files) {
        PluginData pluginData = new PluginData();

        pluginData.Data = File.ReadAllBytes(pf.Name);
        pluginData.FileName = Path.GetFileName(pf.Name);
        pluginDatas.Add(pluginData);
      }
      return pluginDatas;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Uploads the local configuration file as plugin
    /// </summary>
    private static Plugin UploadConfigurationFile(IHiveService service, List<Plugin> onlinePlugins) {
      string exeFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.HLBinaryName);
      string configFileName = Path.GetFileName(ConfigurationManager.OpenExeConfiguration(exeFilePath).FilePath);
      string configFilePath = ConfigurationManager.OpenExeConfiguration(exeFilePath).FilePath;
      byte[] hash;

      byte[] data = File.ReadAllBytes(configFilePath);
      using (SHA1 sha1 = SHA1.Create()) {
        hash = sha1.ComputeHash(data);
      }

      Plugin configPlugin = new Plugin() { Name = "Configuration", Version = new Version(), Hash = hash };
      PluginData configFile = new PluginData() { FileName = configFileName, Data = data };

      IEnumerable<Plugin> onlineConfig = onlinePlugins.Where(p => p.Hash.SequenceEqual(hash));

      if (onlineConfig.Count() > 0) {
        return onlineConfig.First();
      } else {
        configPlugin.Id = service.AddPlugin(configPlugin, new List<PluginData> { configFile });
        return configPlugin;
      }
    }