public string Generate() { List <ControllerInfo> controllers = ControllerAssembly.GetTypes() .Where(type => typeof(Controller).IsAssignableFrom(type) && !type.IsAbstract) .Select(x => new ControllerInfo { Controller = x, RouteAttribute = x.GetCustomAttribute(typeof(RouteAttribute)) as RouteAttribute }) .OrderByDescending(x => x.Areas.Length).ThenBy(x => x.Route) .ToList(); _result = GetNode(0, controllers); return("var URLs = " + _result.GetUrls(BaseUrl) + ";"); }
// Loads a controller plugin. public static IVirtualMachineController LoadController(string ControllerAssemblyPath) { Assembly ControllerAssembly; IVirtualMachineController vm = null; try { ControllerAssembly = Assembly.LoadFrom(ControllerAssemblyPath); } catch (Exception ex) { Logger.Log($"Error loading controller {ControllerAssemblyPath}", Logger.Severity.Error); Logger.Log($"Exception message: {ex.Message}", Logger.Severity.Error); return(null); } foreach (Type AssemblyType in ControllerAssembly.GetTypes()) { if (typeof(IVirtualMachineController).GetTypeInfo().IsAssignableFrom(AssemblyType.GetTypeInfo())) { object ControllerInstance = Activator.CreateInstance(AssemblyType); try { vm = (IVirtualMachineController)ControllerInstance; Logger.Log("VM Controller \"" + vm.DescribingName + "\" loaded successfully!"); } catch (Exception ex) { Logger.Log($"Error loading controller {ControllerAssemblyPath}", Logger.Severity.Error); Logger.Log($"Exception message: {ex.Message}", Logger.Severity.Error); return(null); } return(vm); } } // Return a nullref if there is an error. return(null); }
/// <summary> /// Loads controller types from specified <paramref name="controllerAssembly"/>. /// </summary> /// <param name="controllerAssembly">The assembly to load controller types from.</param> public SilentHunterParsersConfigurer FromAssembly(ControllerAssembly controllerAssembly) { return(FromAssembly(() => controllerAssembly)); }