示例#1
0
        private void loadDynamicAssemblies(List <PluginAssemblyContainer> pluginAssemblies, string baseFolder, string currentFolder)
        {
            foreach (string fileName in Directory.GetFiles(currentFolder).Where(f => SupportedFileExtensions.Contains(Path.GetExtension(f))))
            {
                pluginAssemblies.Add(compileAssembly("~" + fileName.Replace(baseFolder, "").Replace("\\", "/"), null));
            }

            foreach (string directoryName in Directory.GetDirectories(currentFolder))
            {
                loadDynamicAssemblies(pluginAssemblies, baseFolder, directoryName);
            }
        }
示例#2
0
        // moved method to a separate class since overriding [Authorize] attribute of base class was not working?
        // [AllowAnonymous]
        // [HttpGet]
        // [Route("download")]
        // public IActionResult DownloadFile(int id) {

        //     Filespec ent = Logic.GetById(id, true);
        //     string mimeType = GetMimeTypeByFilename(ent.Filename);
        //     return File(ent.Filecontent, mimeType);
        // }

        #region helper

        // private string GetMimeTypeByFilename(string fileName)
        // {
        //     var provider = new FileExtensionContentTypeProvider();
        //     string contentType;
        //     if(!provider.TryGetContentType(fileName, out contentType))
        //     {
        //         contentType = "application/octet-stream";
        //     }
        //     return contentType;
        // }

        private bool FileIsSupported(string fileName)
        {
            string ext = Path.GetExtension(fileName).TrimStart('.');

            return(SupportedFileExtensions.Contains(ext));
        }