private static InputOutputKey ImportFunctionNameKey(string mappingFile, XElement component) { var entries = component.Descendants("entry"); var inputEntries = entries.Where(entry => entry.Attribute("inpkey") != null); var namedInputEntries = inputEntries.Where(inputEntry => inputEntry.Attribute("name") != null); var tokenizerInputEntries = namedInputEntries.Where(namedInputEntry => ((string)namedInputEntry.Attribute("name")) == "Tokenizer"); XElement tokenizerInputEntry = tokenizerInputEntries.First(); return(InputOutputKey.Input(mappingFile, (string)tokenizerInputEntry.Attribute("inpkey"))); //return component.Descendants("entry") // .Where(entry => // entry.Attribute("inpkey") != null && // entry.Attribute("name") != null && // ((string)entry.Attribute("name"))== "Tokenizer") // .Select(entry => InputOutputKey.Input(mappingFile, (string) entry.Attribute("inpkey"))) // .First(); }
/// <summary> /// Takes an <see cref="XElement"/> representing the root entry as input and returns the root Entry object with all its children /// by recursively calling itself. /// </summary> /// <param name="entryElement"></param> /// <param name="mappingFile"></param> /// <returns></returns> private static Entry ImportEntry(XElement entryElement, string mappingFile) { InputOutputKey inputOutputKey; var inputKey = (string)entryElement.Attribute("inpkey"); if (string.IsNullOrEmpty(inputKey)) { var outputKey = (string)entryElement.Attribute("outkey"); inputOutputKey = string.IsNullOrEmpty(outputKey) ? InputOutputKey.None : InputOutputKey.Output(mappingFile, outputKey); } else { inputOutputKey = InputOutputKey.Input(mappingFile, inputKey); } var entryTypeStr = (string)entryElement.Attribute("type"); XsdObjectType xsdObjectType = XsdObjectType.Element; if (entryTypeStr == "attribute") { xsdObjectType = XsdObjectType.Attribute; } return(new Entry((string)entryElement.Attribute("name"), inputOutputKey, xsdObjectType, from childElement in entryElement.Elements("entry") select ImportEntry(childElement, mappingFile))); }
private static IEnumerable <InputOutputKey> ImportFunctionInputKeys(string mappingFile, XElement component) { return(from entry in component.Descendants("entry") where entry.Attribute("inpkey") != null && entry.Attribute("name") != null && ((string)entry.Attribute("name")) != "Tokenizer" select InputOutputKey.Input(mappingFile, (string)entry.Attribute("inpkey"))); }
private static IEnumerable <InputOutputKey> ImportFunctionOutputKeys(string mappingFile, XElement component) { return(from entry in component.Descendants("entry") where entry.Attribute("outkey") != null select InputOutputKey.Input(mappingFile, (string)entry.Attribute("outkey"))); }