Browse Source

Better error handling in bootstrapper

Former-commit-id: 005a7e795e74e6ccb3ca5e3c6a40b4c2770f67e6
pull/17/head
James South 12 years ago
parent
commit
dc462edf6c
  1. 18
      src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs
  2. 4
      src/ImageProcessorConsole/Program.cs
  3. 2
      src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id
  4. BIN
      src/ImageProcessorConsole/images/output/120430.gif
  5. 1
      src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id
  6. BIN
      src/ImageProcessorConsole/images/output/Tl4Yb.gif
  7. 1
      src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id
  8. BIN
      src/ImageProcessorConsole/images/output/circle.png
  9. BIN
      src/ImageProcessorConsole/images/output/nLpfllv.gif
  10. 1
      src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id
  11. BIN
      src/ImageProcessorConsole/images/output/rotate.jpg

18
src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs

@ -13,6 +13,7 @@ namespace ImageProcessor.Configuration
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -69,8 +70,6 @@ namespace ImageProcessor.Configuration
private void LoadSupportedImageFormats() private void LoadSupportedImageFormats()
{ {
if (this.SupportedImageFormats == null) if (this.SupportedImageFormats == null)
{
try
{ {
Type type = typeof(ISupportedImageFormat); Type type = typeof(ISupportedImageFormat);
@ -83,6 +82,8 @@ namespace ImageProcessor.Configuration
HashSet<string> found = new HashSet<string>(); HashSet<string> found = new HashSet<string>();
foreach (FileInfo fileInfo in files) foreach (FileInfo fileInfo in files)
{
try
{ {
AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName); AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName);
@ -91,9 +92,17 @@ namespace ImageProcessor.Configuration
{ {
// In a web app, this assembly will automatically be bound from the // In a web app, this assembly will automatically be bound from the
// Asp.Net Temporary folder from where the site actually runs. // Asp.Net Temporary folder from where the site actually runs.
Assembly.Load(assemblyName);
this.LoadReferencedAssemblies(found, Assembly.Load(assemblyName)); this.LoadReferencedAssemblies(found, Assembly.Load(assemblyName));
} }
} }
catch (Exception ex)
{
// Log the exception for debugging only. There could be any old junk
// thrown in to the bin folder by someone else.
Debug.WriteLine(ex.Message);
}
}
List<Type> availableTypes = AppDomain.CurrentDomain List<Type> availableTypes = AppDomain.CurrentDomain
.GetAssemblies() .GetAssemblies()
@ -104,11 +113,6 @@ namespace ImageProcessor.Configuration
this.SupportedImageFormats = availableTypes this.SupportedImageFormats = availableTypes
.Select(f => (Activator.CreateInstance(f) as ISupportedImageFormat)).ToList(); .Select(f => (Activator.CreateInstance(f) as ISupportedImageFormat)).ToList();
} }
catch (Exception ex)
{
throw new ImageFormatException(ex.Message, ex.InnerException);
}
}
} }
/// <summary> /// <summary>

4
src/ImageProcessorConsole/Program.cs

@ -40,8 +40,8 @@ namespace ImageProcessorConsole
di.Create(); di.Create();
} }
IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".webp"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".jpg");
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png"); IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png");
foreach (FileInfo fileInfo in files) foreach (FileInfo fileInfo in files)
{ {

2
src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id

@ -1 +1 @@
406a6a7916628c0c0bea8243565a7162ebd5a505 166cc5e22c4caf8740e5771fe7b52e23637dd7fa

BIN
src/ImageProcessorConsole/images/output/120430.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

1
src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id

@ -0,0 +1 @@
30ec5c05548fd350f9b7c699715848b9fbfb8ca9

BIN
src/ImageProcessorConsole/images/output/Tl4Yb.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

1
src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id

@ -0,0 +1 @@
fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43

BIN
src/ImageProcessorConsole/images/output/circle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
src/ImageProcessorConsole/images/output/nLpfllv.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

1
src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id

@ -0,0 +1 @@
23a1c81a2d1422076373796e0c47f5d968c56d0b

BIN
src/ImageProcessorConsole/images/output/rotate.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Loading…
Cancel
Save