public MappingFunctionStore(MapForceMapping mapForceMapping, TargetElementStore targetElementStore) { foreach (FunctionComponent functionComponent in mapForceMapping.FunctionComponents) { switch (functionComponent.FunctionType) { case "split": { List <object> targetCcElements = new List <object>(); foreach (InputOutputKey outputKey in functionComponent.OutputKeys) { string targetElementKey = mapForceMapping.GetMappingTargetKey(outputKey.Value); if (targetElementKey != null) { targetCcElements.Add(targetElementStore.GetTargetCc(targetElementKey)); } } MappingFunction mappingFunction = new MappingFunction(targetCcElements); foreach (InputOutputKey inputKey in functionComponent.InputKeys) { mappingFunctions[inputKey.Value] = mappingFunction; } } break; } } }
/// <exception cref="MappingError">Simple typed element mapped to non-BCC CCTS element.</exception> private ElementMapping MapElement(SourceItem sourceElement, string path, Stack <XmlQualifiedName> parentComplexTypeNames) { if (sourceElement.HasSimpleType()) { if (!sourceElement.IsMapped) { // ignore element return(ElementMapping.NullElementMapping); } if (IsMappedToBcc(sourceElement)) { SimpleTypeToCdtMapping simpleTypeToCdtMapping = MapSimpleType(sourceElement); return(new AttributeOrSimpleElementOrComplexElementToBccMapping(sourceElement, (IBcc)GetTargetElement(sourceElement), simpleTypeToCdtMapping)); } if (IsMappedToSup(sourceElement)) { return(new AttributeOrSimpleElementToSupMapping(sourceElement, (ICdtSup)GetTargetElement(sourceElement))); } if (IsMappedToSplitFunction(sourceElement)) { List <SimpleTypeToCdtMapping> simpleTypeToCdtMappings = new List <SimpleTypeToCdtMapping>(); MappingFunction splitFunction = GetMappingFunction(sourceElement); foreach (IBcc targetBcc in splitFunction.TargetCcs) { simpleTypeToCdtMappings.Add(MapSimpleType(sourceElement, targetBcc)); } return(new SplitMapping(sourceElement, splitFunction.TargetCcs.Convert(cc => (IBcc)cc), simpleTypeToCdtMappings)); } throw new MappingError("Simple typed element '" + path + "' mapped to non-BCC CCTS element."); } if (sourceElement.HasComplexType()) { MapComplexType(sourceElement, path, parentComplexTypeNames); if (!sourceElement.IsMapped) { return(new AsmaMapping(sourceElement)); } if (IsMappedToAscc(sourceElement)) { IAscc targetAscc = (IAscc)GetTargetElement(sourceElement); return(new ComplexElementToAsccMapping(sourceElement, targetAscc)); } if (IsMappedToBcc(sourceElement)) { IBcc targetBcc = (IBcc)GetTargetElement(sourceElement); return(new AttributeOrSimpleElementOrComplexElementToBccMapping(sourceElement, targetBcc, null)); } throw new MappingError("Complex typed element '" + path + "' not mapped to either a BCC or an ASCC."); } throw new Exception("Source element '" + path + "' has neither simple nor complex type."); }
private bool IsMappedToSplitFunction(SourceItem element) { MappingFunction mappingFunction = GetMappingFunction(element); return(mappingFunction != null && mappingFunction.IsSplit); }