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; } } }
private SourceItem CreateSourceItemTree(Entry mapForceEntry, XmlSchemaObject sourceXsdObject) { XmlSchemaType xsdType = GetXsdTypeForXsdObject(sourceXsdObject); var sourceItem = new SourceItem(mapForceEntry.Name, xsdType, mapForceEntry.XsdObjectType, mapForceMapping.GetMappingTargetKey(mapForceEntry.InputOutputKey.Value)); IEnumerable <XmlSchemaObject> childrenOfXsdType = GetChildElementsAndAttributesDefinedByXsdType(sourceItem.XsdType); //HashSet<string> childrenOfXsdTypeNames = new HashSet<string>(); //int unknownChildTypeCount = 0; //foreach (XmlSchemaObject xmlSchemaObject in childrenOfXsdType) //{ // if (xmlSchemaObject is XmlSchemaElement) // { // childrenOfXsdTypeNames.Add("E_" + ((XmlSchemaElement)xmlSchemaObject).QualifiedName.Name); // } // else if (xmlSchemaObject is XmlSchemaAttribute) // { // childrenOfXsdTypeNames.Add("A_" + ((XmlSchemaAttribute)xmlSchemaObject).QualifiedName.Name); // } // else // { // childrenOfXsdTypeNames.Add("Unknown Child Type["+(++unknownChildTypeCount)+"]: " + xmlSchemaObject.GetType().Name); // } //} //HashSet<string> childrenOfMapForceEntryNames = new HashSet<string>(); //foreach (Entry subEntry in mapForceEntry.SubEntries) //{ // switch (subEntry.XsdObjectType) // { // case XsdObjectType.Element: // childrenOfMapForceEntryNames.Add("E_" + subEntry.Name); // break; // case XsdObjectType.Attribute: // childrenOfMapForceEntryNames.Add("A_" + subEntry.Name); // break; // } //} //HashSet<string> mapForceEntriesNotFoundInXsd = new HashSet<string>(childrenOfMapForceEntryNames); //mapForceEntriesNotFoundInXsd.ExceptWith(childrenOfXsdTypeNames); //if (mapForceEntriesNotFoundInXsd.Count > 0) //{ // Console.Out.WriteLine("AAAHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!"); //} foreach (XmlSchemaObject childOfXsdType in childrenOfXsdType) { Entry mapForceSubEntry; if (childOfXsdType is XmlSchemaElement) { mapForceSubEntry = mapForceEntry.GetSubEntryForElement(((XmlSchemaElement)childOfXsdType).QualifiedName.Name); } else if (childOfXsdType is XmlSchemaAttribute) { mapForceSubEntry = mapForceEntry.GetSubEntryForAttribute(((XmlSchemaAttribute)childOfXsdType).QualifiedName.Name); } else { throw new Exception("Child of XSD Type is neither an XSD Element nor an XSD Attribute. The type of the Child is " + sourceXsdObject.GetType()); } if (mapForceSubEntry != null) { SourceItem sourceItemTreeForChild = CreateSourceItemTree(mapForceSubEntry, childOfXsdType); sourceItem.AddChild(sourceItemTreeForChild); } else { XmlSchemaType xsdTypeForChild = GetXsdTypeForXsdObject(childOfXsdType); if (childOfXsdType is XmlSchemaElement) { sourceItem.AddChild(new SourceItem(((XmlSchemaElement)childOfXsdType).QualifiedName.Name, xsdTypeForChild, XsdObjectType.Element, null)); } if (childOfXsdType is XmlSchemaAttribute) { sourceItem.AddChild(new SourceItem(((XmlSchemaAttribute)childOfXsdType).QualifiedName.Name, xsdTypeForChild, XsdObjectType.Attribute, null)); } } } return(sourceItem); }