Registering Pipe Mappings
The pipe mappings define how data is transformed when moving through the pipe. The mappings are part of PipeSettings.
Creating pipe mappings
To create default pipe mappings from the build-in Content pipe, use the following code:
List<Mapping> inboundMappingsList = PublishingSystemFactory.GetDefaultInboundMappingForContent();
List<Mapping> outboundMappingsList = PublishingSystemFactory.GetDefaultOutboundMappingForContent();
To create custom pipe mappings, use the following code:
List<Mapping> mappingsList = new System.Collections.Generic.List<Mapping>();
var contentMapping =
new Mapping()
{
DestinationPropertyName = "Content",
IsRequired = true,
SourcePropertyNames = new[] { "Title" }
};
mappingsList.Add(contentMapping);
var linkMapping =
new Mapping()
{
DestinationPropertyName = "Link",
IsRequired = true,
SourcePropertyNames = new[] { "Link" }
};
linkMapping.Translations.Add(new PipeMappingTranslation()
{
TranslatorName = UrlShortenerTranslator.TranslatorName
}
);
mappingsList.Add(linkMapping);
You use the translator to combine multiple properties into a single.
Registering pipe mappings
After you create the pipe mappings, you must register them. Use the following code:
PublishingSystemFactory.RegisterPipeMappings("MyCustomPipeName", true, mappingsList);
One pipe can be used for both purposes - to pass data to a publishing point or to take data from a publishing point. The both cases may require different mappings. The RegisterPipeMappingsmethod accepts an extra parameter that specifies whether the pipe is inbound or outbound.
Modifying pipe mappings
You can modify the mappings of a build-in pipe or custom pipe.
To modify the pipe mappings you use the GetPipeMappings method:
var mappings = PublishingSystemFactory.GetPipeMappings( ContentInboundPipe.PipeName, true );
The method GetPipeMappings accepts the name and whether inbound or outbound is the pipe as parameters. The method returns a copy of the registered mappings. After your modifications, you must register them again to apply the changes:
PublishingSystemFactory.RegisterPipeMappings( ContentInboundPipe.PipeName, true, mappings );