private void ParseWord(Sentence sentence, ConfigurationPair item)
        {
            var newWord = ObjectCopier.Clone(wordPrototype);

            AddAttributesToElement(item, newWord);

            sentence.Words.Add(newWord);
        }
        private void AddAttributesToElement(ConfigurationPair item, Element elementToModify)
        {
            foreach (var itemAttributes in item.Attributes)
            {
                foreach (var itemAttribute in itemAttributes)
                {
                    var attrib0 = elementToModify.Attributes.FirstOrDefault(a => a.Name == itemAttribute.Key);

                    if (attrib0 != null)
                    {
                        attrib0.Value = itemAttribute.Value;
                    }
                    else
                    {
                        elementToModify.Attributes.Add(
                            new Attribute
                            {
                                Name = itemAttribute.Key,
                                DisplayName = itemAttribute.Key,
                                Value = itemAttribute.Value,
                                IsOptional = true,
                                IsEditable = true
                            });
                    }
                }
            }
        }
        private Sentence ParseSentence(ConfigurationPair item)
        {
            var newSentence = ObjectCopier.Clone(sentencePrototype);

            AddAttributesToElement(item, newSentence);

            return newSentence;
        }
        private void ParseWord(Document document, ConfigurationPair item)
        {
            var newWord = ObjectCopier.Clone(wordPrototype);

            AddAttributesToElement(item, newWord);
            NotifyIfAnyNonOptionalAttributeIsMissing(document, wordPrototype, newWord);

            var lastSentence = document.Sentences.Last();
            lastSentence.Words.Add(newWord);
        }
        private void ParseSentence(Document document, ConfigurationPair item)
        {
            ProcessPreviousSentence(document);

            var newSentence = ObjectCopier.Clone(sentencePrototype);

            AddAttributesToElement(item, newSentence);
            NotifyIfAnyNonOptionalAttributeIsMissing(document, sentencePrototype, newSentence);

            document.Sentences.Add(newSentence);
        }
 private void ParseDocument(Document document, ConfigurationPair item)
 {
     AddAttributesToElement(item, document);
     NotifyIfAnyNonOptionalAttributeIsMissing(document, documentPrototype, document);
 }
        private async Task ParseDocument(string filepath, DataStructure dataStructure, Document document)
        {
            using (var reader = new XmlTextReader(filepath))
            {
                var queue = new List<ConfigurationPair>();

                while (await Task.Run(() => reader.Read()))
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element :
                            var pair = new ConfigurationPair {ElementName = reader.Name};

                            var entityAttributes = new Dictionary<string, string>();

                            while (reader.MoveToNextAttribute())
                            {
                                entityAttributes.Add(reader.Name, reader.Value);
                            }

                            pair.Attributes.Add(entityAttributes);
                            queue.Add(pair);
                            break;
                        case XmlNodeType.EndElement :
                            AddElementsToDocument(document, queue, dataStructure);
                            break;
                    }
                }
            }

            ProcessPreviousSentence(document);
        }
        private Sentence CreateSentence(string filepath, string sentenceId, DataStructure dataStructure)
        {
            using (var reader = new XmlTextReader(filepath))
            {
                var queue = new List<ConfigurationPair>();
                Sentence sentence = null;

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element :
                            var pair = new ConfigurationPair {ElementName = reader.Name};

                            var entityAttributes = new Dictionary<string, string>();

                            while (reader.MoveToNextAttribute())
                            {
                                entityAttributes.Add(reader.Name, reader.Value);
                            }

                            pair.Attributes.Add(entityAttributes);
                            queue.Add(pair);
                            break;
                        case XmlNodeType.EndElement :
                            sentence = CreateSentence(queue, dataStructure, sentenceId);
                            break;
                    }

                    if (sentence != null)
                    {
                        ProcessPreviousSentence(sentence);

                        return sentence;
                    }
                }
            }

            return null;
        }
 private static string GetEntityNameByElementName(DataStructure dataStructure, ConfigurationPair item)
 {
     var element = dataStructure.Elements.FirstOrDefault(e => e.Name.Equals(item.ElementName));
     return element!=null? element.Entity:string.Empty;
 }