public void OnProvidersExecuting(ApplicationModelProviderContext context) { var attrList = new List <string>(); var sources = _scriptsProvider.EnumerateFiles("/controllers"); var reflector = new TypeReflectionEngine(); foreach (var virtualPath in sources) { var codeSrc = _scriptsProvider.Get(virtualPath); var module = LoadControllerCode(codeSrc); var baseFileName = System.IO.Path.GetFileNameWithoutExtension(codeSrc.SourceDescription); var type = reflector.Reflect(module, baseFileName); var cm = new ControllerModel(typeof(ScriptedController).GetTypeInfo(), attrList.AsReadOnly()); cm.ControllerName = type.Name; cm.Properties.Add("module", module); cm.Properties.Add("type", type); FillActions(cm, type, GetExportedMethods(module)); context.Result.Controllers.Add(cm); } }
public void OnProvidersExecuting(ApplicationModelProviderContext context) { IEnumerable <string> files; bool standardHandling = true; _app.OnControllersCreation(out files, ref standardHandling); var sources = new List <string>(); if (files != null) { sources.AddRange(files); } if (standardHandling) { var filesystemSources = _scriptsProvider.EnumerateFiles("/controllers"); sources.AddRange(filesystemSources); } FillContext(sources, context); }