Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/01/15 14:59:47 (9 years ago)
Author:
ascheibe
Message:

#2394 merged r12428, r12429, r12430, r12435, r12442, r12443, r12445, r12514, r12517, r12519, r12520, r12521, r12523, r12532, r12542, r12546, r12552, r12553, r12556, r12557, r12559, r12561, r12146, r12457 into stable

Location:
stable
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • 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
     22using System;
    223using System.Collections.Concurrent;
    324using System.Collections.Generic;
     
    526using System.Linq;
    627using System.Reflection;
    7 using System.Text;
    828using System.Web.Http;
    929using System.Web.Http.Controllers;
     
    1131namespace HeuristicLab.Services.WebApp {
    1232  public class Plugin {
    13     private HttpConfiguration configuration;
    1433    public string Name { get; set; }
    1534    public string Directory { get; set; }
    1635    public string AssemblyName { get; set; }
     36    public string Exception { get; set; }
    1737    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    }
    1849
    1950    private IDictionary<string, HttpControllerDescriptor> controllers;
     
    2253    }
    2354
    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;
    2959    }
    3060
     
    3767    public void ReloadControllers() {
    3868      AssemblyName = null;
     69      Exception = null;
    3970      Controllers.Clear();
    4071      LastReload = DateTime.Now;
     
    4778          return;
    4879        var assemblyPath = assemblies.First();
     80        AssemblyName = Path.GetFileName(assemblyPath);
    4981        var assembly = Assembly.Load(File.ReadAllBytes(assemblyPath));
    5082        var assemblyTypes = assembly.GetTypes();
     
    5486          Controllers.Add(controllerName, new HttpControllerDescriptor(configuration, controllerName, apiController));
    5587        }
    56         AssemblyName = Path.GetFileName(assemblyPath);
    5788      }
    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();
    7291        Controllers.Clear();
    7392      }
Note: See TracChangeset for help on using the changeset viewer.