Exemple #1
0
 public Entry(string name, InputOutputKey inputOutputKey, XsdObjectType xsdObjectType, IEnumerable <Entry> subEntries)
 {
     this.inputOutputKey = inputOutputKey;
     this.XsdObjectType  = xsdObjectType;
     Name       = name;
     SubEntries = new List <Entry>(subEntries);
 }
        /// <summary>
        /// Takes an <see cref="XDocument"/> representing the whole MapForce mapping model as input and returns a set
        /// of ConstantComponents.
        /// </summary>
        /// <param name="mappingFiles"></param>
        /// <returns></returns>
        private static IEnumerable <ConstantComponent> ImportConstantComponents(string[] mappingFiles)
        {
            foreach (var mappingFile in mappingFiles)
            {
                var mappingDocument = XDocument.Load(mappingFile);
                IEnumerable <XElement> constantComponentElements = from c in mappingDocument.Descendants("component")
                                                                   where (string)c.Attribute("name") == "constant"
                                                                   select c;

                foreach (XElement constantComponentElement in constantComponentElements)
                {
                    var constantElement = constantComponentElement.XPathSelectElement("data/constant");

                    if (constantElement == null)
                    {
                        // TODO report error
                    }
                    else
                    {
                        var            datapointElement = constantComponentElement.XPathSelectElement("targets/datapoint");
                        InputOutputKey outputKey        = datapointElement != null?InputOutputKey.Output(mappingFile, (string)datapointElement.Attribute("key")) : InputOutputKey.None;

                        yield return(new ConstantComponent((string)constantElement.Attribute("value"), outputKey));
                    }
                }
            }
        }
 public FunctionComponent(string functionType, InputOutputKey functionNameKey, InputOutputKey[] inputKeys, InputOutputKey[] outputKeys)
 {
     FunctionType    = functionType;
     FunctionNameKey = functionNameKey;
     InputKeys       = inputKeys;
     OutputKeys      = outputKeys;
 }
        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)));
        }
 public Vertex(string key, IEnumerable <Edge> edges, string mappingFile)
 {
     Key   = InputOutputKey.PrependPrefix(mappingFile, key);
     Edges = new List <Edge>(edges);
 }
Exemple #7
0
 public Entry(string name, InputOutputKey inputOutputKey, XsdObjectType xsdObjectType)
     : this(name, inputOutputKey, xsdObjectType, new Entry[0])
 {
 }
 public Edge(string edgeKey, string targetVertexKey, string mappingFile)
 {
     EdgeKey         = InputOutputKey.PrependPrefix(mappingFile, edgeKey);
     TargetVertexKey = InputOutputKey.PrependPrefix(mappingFile, targetVertexKey);
 }
 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")));
 }
 public ConstantComponent(string value, InputOutputKey outputKey)
 {
     Value     = value;
     OutputKey = outputKey;
 }