/// <summary>
        /// Gets the image from file.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="file">The file.</param>
        /// <returns></returns>
        public static Image GetImageFromFile(Project project, ProjectEntity entity, ProjectEntityFile file)
        {
            _logger.Trace("ProjectController.GetImageFromFile()");

            var targetLocation = Path.Combine(project.SaveDirectory, "Files", entity.Name, file.File);

            if (File.Exists(targetLocation))
            {
                var icon = Icon.ExtractAssociatedIcon(targetLocation);

                return(icon.ToBitmap());
            }

            return(Resources.page_white_code);
        }
        /// <summary>
        /// Saves the code to disk.
        /// </summary>
        /// <param name="plugin">The plugin.</param>
        /// <param name="component">The component.</param>
        /// <param name="project">The project.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="code">The code.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns></returns>
        public static bool SaveCodeToProject(IGeneratorTemplate plugin, GeneratorComponent component, Project project, string tableName, string code, string fileName)
        {
            _logger.Trace("ProjectController.SaveCodeToDisk()");

            var targetDirectory = Path.Combine(project.SaveDirectory, "Files", tableName);

            if (!Directory.Exists(targetDirectory))
            {
                Directory.CreateDirectory(targetDirectory);
            }

            var entity = project.Entities.FirstOrDefault(e => e.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase));

            if (entity == null)
            {
                entity      = new ProjectEntity();
                entity.Name = tableName;
                project.Entities.Add(entity);
            }

            project.Entities = project.Entities.OrderBy(e => e.Name).ToList();

            string guid = ((GuidAttribute)(plugin.GetType().Assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0])).Value;

            var file = entity.Files.FirstOrDefault(f => f.Guid.Equals(guid, StringComparison.InvariantCultureIgnoreCase) && f.Plugin.Equals(plugin.GetType().ToString(), StringComparison.InvariantCultureIgnoreCase) && f.Component.Equals(component.Id));

            if (file == null)
            {
                file           = new ProjectEntityFile();
                file.Guid      = guid;
                file.Plugin    = plugin.GetType().ToString();
                file.Component = component.Id;
                file.File      = fileName;
                entity.Files.Add(file);
            }

            entity.Files = entity.Files.OrderBy(e => e.File).ToList();

            var targetLocation = Path.Combine(targetDirectory, fileName);

            File.WriteAllText(targetLocation, code, Encoding.UTF8);

            return(true);
        }