Changeset 12563 for stable/HeuristicLab.Services.WebApp/3.3/Plugin.cs
- Timestamp:
- 07/01/15 14:59:47 (9 years ago)
- Location:
- stable
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12146,12428-12430,12435,12442-12443,12445,12457,12514,12517,12519-12521,12523,12532,12542,12546,12552-12553,12556-12557,12559,12561 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Services.WebApp/3.3/Plugin.cs
r12428 r12563 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Concurrent; 3 24 using System.Collections.Generic; … … 5 26 using System.Linq; 6 27 using System.Reflection; 7 using System.Text;8 28 using System.Web.Http; 9 29 using System.Web.Http.Controllers; … … 11 31 namespace HeuristicLab.Services.WebApp { 12 32 public class Plugin { 13 private HttpConfiguration configuration;14 33 public string Name { get; set; } 15 34 public string Directory { get; set; } 16 35 public string AssemblyName { get; set; } 36 public string Exception { get; set; } 17 37 public DateTime? LastReload { get; set; } 38 39 private HttpConfiguration configuration; 40 public HttpConfiguration Configuration { 41 get { return configuration; } 42 set { 43 if (configuration != value) { 44 configuration = value; 45 ReloadControllers(); 46 } 47 } 48 } 18 49 19 50 private IDictionary<string, HttpControllerDescriptor> controllers; … … 22 53 } 23 54 24 public void Configure(HttpConfiguration configuration) { 25 if (this.configuration != configuration) { 26 this.configuration = configuration; 27 ReloadControllers(); 28 } 55 public Plugin(string name, string directory, HttpConfiguration configuration) { 56 Name = name; 57 Directory = directory; 58 Configuration = configuration; 29 59 } 30 60 … … 37 67 public void ReloadControllers() { 38 68 AssemblyName = null; 69 Exception = null; 39 70 Controllers.Clear(); 40 71 LastReload = DateTime.Now; … … 47 78 return; 48 79 var assemblyPath = assemblies.First(); 80 AssemblyName = Path.GetFileName(assemblyPath); 49 81 var assembly = Assembly.Load(File.ReadAllBytes(assemblyPath)); 50 82 var assemblyTypes = assembly.GetTypes(); … … 54 86 Controllers.Add(controllerName, new HttpControllerDescriptor(configuration, controllerName, apiController)); 55 87 } 56 AssemblyName = Path.GetFileName(assemblyPath);57 88 } 58 catch (ReflectionTypeLoadException ex) { 59 StringBuilder sb = new StringBuilder(); 60 foreach (Exception exSub in ex.LoaderExceptions) { 61 sb.AppendLine(exSub.Message); 62 FileNotFoundException exFileNotFound = exSub as FileNotFoundException; 63 if (exFileNotFound != null) { 64 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { 65 sb.AppendLine("Fusion Log:"); 66 sb.AppendLine(exFileNotFound.FusionLog); 67 } 68 } 69 sb.AppendLine(); 70 } 71 AssemblyName = "Error loading assembly: " + sb.ToString(); 89 catch (Exception e) { 90 Exception = e.ToString(); 72 91 Controllers.Clear(); 73 92 }
Note: See TracChangeset
for help on using the changeset viewer.