private static void CompileActionImport(ImportManager imports, ControllerContext context, MvcAction actionInfo) { FetchFunctionDescriptor fetchDescriptor = context.FetchFunctionResolver.Resolve(actionInfo.RequestMethod.Name); string funcKey = "fetch-" + fetchDescriptor.FetchModulePath; if (!imports.ContainsImportPath(funcKey)) { imports.AddImport(funcKey, new ImportStatement(context.OutputPath, fetchDescriptor.FetchModulePath, false)); } ImportStatement ajaxImport = imports.GetImportAtPath(funcKey); ajaxImport.AddItem(fetchDescriptor.FunctionName); AddActionImports(imports, actionInfo); TryAddAdditionalImports(imports, context, fetchDescriptor.AdditionalImports); }
private static void TryAddAdditionalImports(ImportManager imports, ControllerContext context, IEnumerable <ImportDefinition> additionalImports) { // Additional imports foreach (ImportDefinition def in additionalImports) { string importPath = PathUtils.ResolveRelativePath(context.OutputPath, def.Path); string key = "custom" + importPath; if (!imports.ContainsImportPath(key)) { imports.AddImport(key, new ImportStatement(context.OutputPath, importPath, def.UseAlias)); } ImportStatement statement = imports.GetImportAtPath(key); if (def.Items != null) { foreach (var item in def.Items) { statement.AddItem(item); } } } }