Created
March 31, 2016 10:55
-
-
Save MatthewBarker/ea39848d9e30592c5b384aa179a9d84a to your computer and use it in GitHub Desktop.
Automap service behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WcfService | |
{ | |
using System.Collections.ObjectModel; | |
using System.ServiceModel; | |
using System.ServiceModel.Channels; | |
using System.ServiceModel.Description; | |
using Logic.Mappers; | |
/// <summary> | |
/// Registers AutoMapper for the calls to business logic methods. | |
/// </summary> | |
public class AutomapServiceBehavior : IServiceBehavior | |
{ | |
/// <summary> | |
/// The mapper configuration | |
/// </summary> | |
private IMapperConfig mapperConfig; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="AutomapServiceBehavior"/> class. | |
/// </summary> | |
/// <param name="mapperConfig">The mapper configuration.</param> | |
public AutomapServiceBehavior(IMapperConfig mapperConfig) | |
{ | |
this.mapperConfig = mapperConfig; | |
} | |
/// <summary> | |
/// Provides the ability to pass custom data to binding elements to support the contract implementation. | |
/// </summary> | |
/// <param name="serviceDescription">The service description of the service.</param> | |
/// <param name="serviceHostBase">The host of the service.</param> | |
/// <param name="endpoints">The service endpoints.</param> | |
/// <param name="bindingParameters">Custom objects to which binding elements have access.</param> | |
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) | |
{ | |
this.mapperConfig.RegisterMap(); | |
} | |
/// <summary> | |
/// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects. | |
/// </summary> | |
/// <param name="serviceDescription">The service description.</param> | |
/// <param name="serviceHostBase">The host that is currently being built.</param> | |
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) | |
{ | |
} | |
/// <summary> | |
/// Provides the ability to inspect the service host and the service description to confirm that the service can run successfully. | |
/// </summary> | |
/// <param name="serviceDescription">The service description.</param> | |
/// <param name="serviceHostBase">The service host that is currently being constructed.</param> | |
public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment