private void GenerateBdtSpecsFromSimpleTypeMapping(SimpleTypeToCdtMapping simpleTypeMapping)
        {
            // NOTE: at this point there is only one simple type mapping which is the "SimpleTypeToCdtMapping".
            var bdtSpec = BdtSpec.CloneCdt(simpleTypeMapping.TargetCDT, simpleTypeMapping.BIEName);

            bdtSpec.Sups = new List <BdtSupSpec>();
            bdtSpecs.Add(bdtSpec);
        }
        /// <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.");
        }
Beispiel #3
0
 public bool Equals(SimpleTypeToCdtMapping other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.TargetCDT.Id, TargetCDT.Id) && Equals(other.SimpleTypeName, SimpleTypeName));
 }
        private SimpleTypeToCdtMapping MapSimpleType(SourceItem sourceElement, IBcc targetBcc)
        {
            var simpleTypeName = sourceElement.XsdTypeName;
            var cdt            = targetBcc.Cdt;

            foreach (SimpleTypeToCdtMapping simpleTypeMapping in simpleTypeMappings)
            {
                if (simpleTypeMapping.SimpleTypeName == simpleTypeName && simpleTypeMapping.TargetCDT.Id == cdt.Id)
                {
                    return(simpleTypeMapping);
                }
            }
            SimpleTypeToCdtMapping newMapping = new SimpleTypeToCdtMapping(simpleTypeName, cdt);

            simpleTypeMappings.Add(newMapping);
            return(newMapping);
        }
        /// <summary>
        /// Retrieves the BDT based on the given CDT from the BDT library. If the BDT does not yet exist, it is created.
        /// </summary>
        /// <param name="splitMapping"></param>
        /// <param name="targetBcc"></param>
        /// <returns></returns>
        private IBdt GetBdt(SplitMapping splitMapping, IBcc targetBcc)
        {
            SimpleTypeToCdtMapping cdtMapping = splitMapping.GetCdtMappingForTargetBcc(targetBcc);

            return(bdtLibrary.GetBdtByName(cdtMapping.BIEName));
        }