Skip to content

Commit

Permalink
Removed breaking change on interface.
Browse files Browse the repository at this point in the history
Refactored configuration of services so prefix, settings and whitelist are set immediately after creation.
  • Loading branch information
lars-erik committed Mar 31, 2017
1 parent 6b3a830 commit 3c5fdaa
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,43 +304,16 @@ private void LoadImageServices()
IImageService imageService = Activator.CreateInstance(type) as IImageService;
if (imageService != null)
{
if (!string.IsNullOrWhiteSpace(config.Prefix))
{
imageService.Prefix = config.Prefix;
}
if (!string.IsNullOrWhiteSpace(config.Name))
imageService.Name = config.Name;
else
imageService.Name = type.Name;
var name = config.Name ?? imageService.GetType().Name;
imageService.Prefix = config.Prefix;
imageService.Settings = GetServiceSettings(name);
imageService.WhiteList = GetServiceWhitelist(name);
}


this.ImageServices.Add(imageService);
}

// Add the available settings.
foreach (IImageService service in this.ImageServices)
{
string name = service.Name;
Dictionary<string, string> settings = this.GetServiceSettings(name);
if (settings.Any())
{
service.Settings = settings;
}
else if (service.Settings == null)
{
// I've noticed some developers are not initializing
// the settings in their implentations.
service.Settings = new Dictionary<string, string>();
}

Uri[] whitelist = this.GetServiceWhitelist(name);

if (whitelist.Any())
{
service.WhiteList = this.GetServiceWhitelist(name);
}
}
}

/// <summary>
Expand Down
8 changes: 0 additions & 8 deletions src/ImageProcessor.Web/Services/CloudImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public CloudImageService()
/// </summary>
public string Prefix { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the name for the given instance.
/// <remarks>
/// This value is used as an identifier for the service.
/// </remarks>
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down
2 changes: 0 additions & 2 deletions src/ImageProcessor.Web/Services/IImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public interface IImageService
/// </summary>
string Prefix { get; set; }

string Name { get; set; }

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down
8 changes: 0 additions & 8 deletions src/ImageProcessor.Web/Services/LocalFileImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ public class LocalFileImageService : IImageService
/// </summary>
public string Prefix { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the name for the given instance.
/// <remarks>
/// This value is used as an identifier for the service.
/// </remarks>
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down
8 changes: 0 additions & 8 deletions src/ImageProcessor.Web/Services/RemoteImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ public RemoteImageService()
/// </summary>
public string Prefix { get; set; } = "remote.axd";

/// <summary>
/// Gets or sets the name for the given instance.
/// <remarks>
/// This value is used as an identifier for the service.
/// </remarks>
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public class AppDataImageService : IImageService
/// </summary>
public string Prefix { get; set; } = "appdata.axd";

/// <summary>
/// Gets or sets the name for the given instance.
/// <remarks>
/// This value is used as an identifier for the service.
/// </remarks>
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ public class DatabaseImageService : IImageService
/// </summary>
public string Prefix { get; set; } = "database.axd";

/// <summary>
/// Gets or sets the name for the given instance.
/// <remarks>
/// This value is used as an identifier for the service.
/// </remarks>
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Gets a value indicating whether the image service requests files from
/// the locally based file system.
Expand Down

0 comments on commit 3c5fdaa

Please sign in to comment.