1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Runtime.Serialization;
|
---|
5 | using System.ServiceModel;
|
---|
6 | using System.Text;
|
---|
7 | using System.IO;
|
---|
8 | using HeuristicLab.PluginInfrastructure.Manager;
|
---|
9 | using ICSharpCode.SharpZipLib.Zip;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Update.Service {
|
---|
12 | public class UpdateLocation : IUpdateLocation {
|
---|
13 |
|
---|
14 | #region IUpdateLocation Members
|
---|
15 |
|
---|
16 | public IEnumerable<PluginInformation> GetAvailablePluginsByName(string name) {
|
---|
17 | using (PluginStoreDataContext ctx = new PluginStoreDataContext()) {
|
---|
18 | return from plugin in ctx.Plugins
|
---|
19 | where MatchingName(name, plugin.Name)
|
---|
20 | select new PluginInformation(plugin.Name, new Version(plugin.Version), plugin.BuildDate);
|
---|
21 | }
|
---|
22 | }
|
---|
23 | public IEnumerable<byte[]> GetPluginFiles(PluginInformation info) {
|
---|
24 | using (PluginStoreDataContext ctx = new PluginStoreDataContext()) {
|
---|
25 | return from plugin in ctx.Plugins
|
---|
26 | from file in ctx.PluginFiles
|
---|
27 | where
|
---|
28 | plugin.Name == info.Name &&
|
---|
29 | plugin.BuildDate == info.BuildDate &&
|
---|
30 | plugin.Version == info.Version.ToString() &&
|
---|
31 | file.PluginId == plugin.Id
|
---|
32 | select file.Data.ToArray();
|
---|
33 | }
|
---|
34 | }
|
---|
35 | #endregion
|
---|
36 |
|
---|
37 |
|
---|
38 | private static bool MatchingName(string name, string pluginName) {
|
---|
39 | return name.Equals(pluginName, StringComparison.InvariantCultureIgnoreCase);
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|