コード例 #1
0
ファイル: Global.cs プロジェクト: wisaly/akira_bot
        public static bool msgFilter(Message msg, bool filterAt, Func <string, bool> filterText)
        {
            bool foundAt   = false;
            bool foundText = false;

            foreach (var ele in msg.data)
            {
                if (filterAt && ele is ElementAt)
                {
                    ElementAt ea = ele as ElementAt;
                    if (ea.data["qq"] == Global.botid.ToString())
                    {
                        foundAt = true;
                    }
                }
                if (ele is ElementText)
                {
                    ElementText et = ele as ElementText;
                    if (filterText(et.text))
                    {
                        foundText = true;
                    }
                }
            }
            return((filterAt ? foundAt : true) && foundText);
        }
コード例 #2
0
        // Get data by in HtmlElement by ElementText Enumeration
        public static string GetData(this WebBrowser wb, HtmlElement el, ElementText elText = ElementText.InnerText)
        {
            if (el.IsNull())
            {
                return("");
            }

            string text = "";

            switch (elText)
            {
            case ElementText.InnerHtml:
                text = el.InnerHtml ?? "";
                break;

            case ElementText.InnerText:
                text = el.InnerText ?? "";
                break;

            case ElementText.OuterHtml:
                text = el.OuterHtml ?? "";
                break;

            case ElementText.OuterText:
                text = el.OuterText ?? "";
                break;
            }

            return((text ?? "").Trim());
        }
コード例 #3
0
        private void UpdateText(ElementText elementText, Stack <IAbstractMarkupDataContainer> containers)
        {
            var text      = _segmentBuilder.Text(elementText.Text);
            var container = containers.Peek();

            container.Add(text);
        }
コード例 #4
0
        public void ElementImageSetFontSizeTest()
        {
            ElementText element     = new ElementText(text, fontSize, font, originPointX, originPointY, height, width, comentarysBoardElement);
            int         newFontSize = 12;

            element.setFontSize(newFontSize);
            Assert.AreEqual(element.getFontSize(), newFontSize);
        }
コード例 #5
0
        public void ElementImageSetTextTest()
        {
            ElementText element = new ElementText(text, fontSize, font, originPointX, originPointY, height, width, comentarysBoardElement);
            string      newText = "twoText";

            element.setText(newText);
            Assert.AreEqual(element.getText(), newText);
        }
コード例 #6
0
ファイル: Card.cs プロジェクト: persundholm/MindAndMatter
        public string getName()
        {
            //Extract name
            ElementText    nameElement  = Resources.Load("Data/Elements/Name") as ElementText;
            CardProperties nameProperty = SearchProperty(nameElement);
            string         cardName     = nameProperty.stringValue;

            return(cardName);
        }
コード例 #7
0
        /// <summary>
        /// Check if data is contained in the HtmlElement by ElementText Enumeration
        /// </summary>
        public static bool ContainsData(this HtmlElement el, string value, ElementText elText = ElementText.InnerText)
        {
            if (el.IsNull())
            {
                return(false);
            }

            return(el.GetData(elText).Contains(value));
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        public static string DocText(this WebBrowser wb, ElementText elText = ElementText.InnerText)
        {
            if (wb.Document.IsNull() ||
                wb.Document.Body.IsNull())
            {
                return("");
            }

            return(wb.Document.Body.GetData(elText));
        }
コード例 #9
0
ファイル: Global.cs プロジェクト: wisaly/akira_bot
        public static string msgText(Message msg)
        {
            string txt = "";

            foreach (var ele in msg.data)
            {
                if (ele is ElementText)
                {
                    ElementText et = ele as ElementText;
                    txt += et.text.Trim();
                }
            }

            return(txt);
        }
コード例 #10
0
        private ServiceExport.DTO_Element ElementConvert(PageElement srcElement, ImageDataDTO Data)
        {
            ServiceExport.DTO_Element ElOut = null;

            if (srcElement != null)
            {
                if (srcElement.GetType() == typeof(ElementText))
                {
                    ServiceExport.DTO_ElementText OutText = new ServiceExport.DTO_ElementText();

                    ElementText src = (ElementText)srcElement;
                    if (src != null)
                    {
                        OutText.IsHTML = src.IsHTML;
                        OutText.Text   = src.Text;
                    }
                    ElOut = OutText;
                }

                if (srcElement.GetType() == typeof(ElementImage))
                {
                    ServiceExport.DTO_ElementImage OutImg = new ServiceExport.DTO_ElementImage();
                    ElementImage src = (ElementImage)srcElement;
                    if (src != null)
                    {
                        OutImg.Height = src.Height;
                        OutImg.Path   = ImageHelper.GetImageUrl(Data, src.Path);
                        OutImg.Width  = src.Width;
                    }
                    ElOut = OutImg;
                }

                if (srcElement.GetType() == typeof(ElementVoid))
                {
                    ElOut = null;
                }

                if (ElOut != null)
                {
                    ElOut.Id        = srcElement.Id;
                    ElOut.Alignment = srcElement.Alignment;
                }
            }
            return(ElOut);
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        public static bool ContainsData(this WebBrowser wb, ElementText elText, params string[] values)
        {
            //if (wb.IsNull())
            //    throw new ArgumentNullException("wb", "Web Browser is null");

            if (values.Length == 0)
            {
                return(false);
            }

            foreach (string value in values.ToList())
            {
                if (!wb.DocText(elText).ToLower().Contains(value.ToLower()))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #12
0
        async Task <Kv> processDefine(Message msg, Sender sender)
        {
            string ques   = "";
            string ans    = "";
            string ansimg = "";

            foreach (var ele in msg.data)
            {
                if (ele is ElementText)
                {
                    ElementText elet = ele as ElementText;
                    if (!elet.text.TrimStart().StartsWith(keyword))
                    {
                        continue;
                    }
                    string   defstr = elet.text.Trim().Substring(keyword.Length).Replace(":", ":");
                    string[] defarr = defstr.Split(':', options: StringSplitOptions.RemoveEmptyEntries);

                    if (defarr.Length == 0)
                    {
                        return(null);
                    }

                    ques = defarr[0];

                    if (ques.Contains(keyword))
                    {
                        return(null);
                    }

                    if (defstr.EndsWith(':') && defarr.Length == 1)
                    {
                        // define image
                        continue;
                    }
                    if (defarr.Length != 2)
                    {
                        return(null);
                    }

                    ans = defarr[1];
                    break;
                }
                if (ele is ElementImage && ques != "")
                {
                    ElementImage elei = ele as ElementImage;
                    if (!await elei.Fix())
                    {
                        return(null);
                    }
                    ansimg = elei.data["file"];
                    break;
                }
            }
            if (ques == "" || (ans == "" && ansimg == ""))
            {
                return(null);
            }

            Tag tag = new Tag
            {
                anstype     = ans != "" ? Tag.ansenum.text : Tag.ansenum.image,
                trainerid   = sender.user_id,
                trainername = sender.nickname
            };

            Kv kv = new Kv
            {
                k = ques,
                v = ans != "" ? ans : ansimg,
                r = JsonConvert.SerializeObject(tag)
            };

            return(kv);
        }
コード例 #13
0
        private Source ReadSource(XmlReader xmlReader)
        {
            var segment = new Source();

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (string.Compare(xmlReader.Name, "bpt", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadOpeningElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ept", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadClosingElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ph", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadElementPlaceholder(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "x", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadElementGenericPlaceholder(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "mrk", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        var elements     = ReadElements(xmlReaderSub);
                        if (elements?.Count > 0)
                        {
                            segment.Elements.AddRange(elements);
                        }
                    }
                    break;

                case XmlNodeType.Whitespace:
                {
                    var whiteSpace = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(whiteSpace);
                }
                break;

                case XmlNodeType.Text:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(text);
                }
                break;

                case XmlNodeType.CDATA:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(text);
                }
                break;

                case XmlNodeType.EntityReference:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Name
                    };

                    segment.Elements.Add(text);
                }
                break;
                }
            }

            return(segment);
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        public static HtmlElement GetElementInCollection(this WebBrowser wb, HtmlElementCollection elCol, string value, ElementText elText = ElementText.InnerText)
        {
            if (wb.IsNull() ||
                elCol.IsNull())
            {
                return(null);
            }

            foreach (HtmlElement elItem in elCol)
            {
                if (wb.GetData(elItem, elText).Contains(value))
                {
                    return(elItem);
                }
            }

            return(null);
        }
コード例 #15
0
        public void ElementImageGetFontTest()
        {
            ElementText element = new ElementText(text, fontSize, font, originPointX, originPointY, height, width, comentarysBoardElement);

            Assert.AreEqual(element.getFont(), font);
        }
コード例 #16
0
        /// <summary>

        /// Check if data is contained in the HtmlElement by ElementText Enumeration
        /// </summary>
        public static bool ContainsData(this WebBrowser wb, HtmlElement el, string value, ElementText elText = ElementText.InnerText)
        {
            //if (wb.IsNull())
            //    throw new ArgumentNullException("wb", "Web Browser is null");

            return(wb.GetData(el, elText).Contains(value));
        }
コード例 #17
0
        /// <summary>
        /// Recupera una versione specifica
        /// </summary>
        /// <param name="TempalteID">L'ID del Template</param>
        /// <param name="VersionID">L'ID della versione. Se more o uguale a 0 </param>
        /// <returns>La versione specificata di un Template</returns>
        /// /// <remarks>
        /// Al momento ho scelto di utilizzare SOLO le versioni "disponibili".
        /// Per le versioni in Draft o con Active = false, sarà necessario fornire l'ID Version.
        /// In quel caso verrà utilizzata la versione specificata, indipendentemente dal suo stato.
        /// </remarks>
        public ServiceExport.DTO_Template TemplateGet(Int64 TemplateID, Int64 VersionID, String BasePath)
        {
            TemplateVersion srcVersion = null;

            if (VersionID > 0)
            {
                srcVersion = Manager.Get <TemplateVersion>(VersionID);
            }
            else
            {
                Template srcTemplate = Manager.Get <Template>(TemplateID);
                if (srcTemplate == null)
                {
                    return(null);
                }

                srcVersion = (from TemplateVersion tmpVers in srcTemplate.Versions
                              where tmpVers.IsDraft == false && tmpVers.IsActive == true
                              orderby tmpVers.Version descending
                              select tmpVers).FirstOrDefault();

                if (srcVersion == null)
                {
                    srcVersion = (from TemplateVersion tmpVers in srcTemplate.Versions
                                  where tmpVers.IsDraft == false && tmpVers.IsActive == false
                                  orderby tmpVers.Version descending
                                  select tmpVers).FirstOrDefault();
                }

                if (srcVersion == null)
                {
                    //SE non ci sono altre versioni definitive,
                    //prendo quella in bozza (ne è prevista una sola!)
                    srcVersion = (from TemplateVersion tmpVers in srcTemplate.Versions
                                  where tmpVers.IsDraft == true
                                  select tmpVers).FirstOrDefault();
                }
            }

            if (srcVersion == null || srcVersion.Id <= 0)
            {
                return(null);
            }

            ServiceExport.DTO_Template expTemplate = new ServiceExport.DTO_Template();

            expTemplate.TemplateId = srcVersion.Template.Id;
            expTemplate.Name       = srcVersion.Template.Name;
            expTemplate.VersionId  = srcVersion.Id;
            expTemplate.Version    = srcVersion.Version;

            expTemplate.UseSkinHeaderFooter = (srcVersion.Template.Type == TemplateType.Skin);

            expTemplate.IsSystem = srcVersion.Template.IsSystem;

            expTemplate.IsEditable = !srcVersion.Template.IsSystem && srcVersion.Template.HasDraft;

            // MODULES
            expTemplate.Modules = new List <ServiceExport.DTO_Modules>();
            if (srcVersion.Template != null)
            {
                var queryService = (from s in Manager.GetIQ <ServiceContent>() where s.Deleted == BaseStatusDeleted.None select s);
                expTemplate.Modules = queryService.Where(s => s.Template.Id == srcVersion.Template.Id).Select(s => new ServiceExport.DTO_Modules()
                {
                    Id = s.Id, ModuleName = s.ModuleName, IdModule = s.ModuleId, IsActive = s.IsActive, ModuleCode = s.ModuleCode
                }).ToList();
                ////Template tmpl = (Template)srcVersion.Template;
                //////List<ServiceContent> Services = tmpl.Services.ToList();

                ////if (srcVersion.Template.Services != null && tmpl.Services.Count() > 0)
                ////{
                //foreach(ServiceContent srvc in srcVersion.Template.Services.Where(srv => srv.IsActive))
                //{
                //    ServiceExport.DTO_Modules srv = new ServiceExport.DTO_Modules();
                //    srv.Id = srvc.Id;
                //    srv.IdModule = srv.IdModule;
                //    srv.IsActive = srv.IsActive;
                //    srv.ModuleCode = srv.ModuleCode;
                //    srv.ModuleName = srv.ModuleName;
                //    expTemplate.Modules.Add(srv);
                //}
                ////}
            }

            PageElement BodyEl = (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.Body && el.IsActive)
                                  orderby PgEl.SubVersion descending
                                  select PgEl).FirstOrDefault();

            ServiceExport.DTO_ElementText Body = new ServiceExport.DTO_ElementText();

            if (BodyEl != null && BodyEl.GetType() == typeof(ElementText))
            {
                ElementText src = (ElementText)BodyEl;
                if (src != null)
                {
                    Body.Alignment = src.Alignment;
                    Body.Id        = src.Id;
                    Body.IsHTML    = src.IsHTML;
                    Body.Text      = src.Text;
                }
            }
            else
            {
                Body        = new ServiceExport.DTO_ElementText();
                Body.Id     = -1;
                Body.IsHTML = true;
                Body.Text   = "<p></p>";
            }
            expTemplate.Body = Body;

            // HEADER
            ImageDataDTO Data = new ImageDataDTO {
                BaseUrl = BasePath, TemplateId = expTemplate.TemplateId, VersionId = expTemplate.VersionId
            };

            expTemplate.Header      = new ServiceExport.DTO_HeaderFooter();
            expTemplate.Header.Left = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.HeaderLeft && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);
            expTemplate.Header.Center = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.HeaderCenter && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);
            expTemplate.Header.Right = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.HeaderRight && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);

            // FOOTER
            expTemplate.Footer      = new ServiceExport.DTO_HeaderFooter();
            expTemplate.Footer.Left = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.FooterLeft && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);
            expTemplate.Footer.Center = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.FooterCenter && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);
            expTemplate.Footer.Right = ElementConvert(
                (from PageElement PgEl in srcVersion.Elements.Where(el => el.Position == ElementPosition.FooterRight && el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby PgEl.SubVersion descending
                 select PgEl).FirstOrDefault()
                , Data);

            // SETTING
            expTemplate.Settings = SettingsConvert(
                (from DocTemplateVers.Settings Sett
                 in srcVersion.Settings.Where(el => el.IsActive && el.Deleted == BaseStatusDeleted.None)
                 orderby Sett.SubVersion descending
                 select Sett
                ).FirstOrDefault()
                );

            if (expTemplate.Settings != null &&
                !string.IsNullOrEmpty(expTemplate.Settings.BackgroundImagePath) &&
                !expTemplate.Settings.BackgroundImagePath.StartsWith("http"))
            {
                expTemplate.Settings.BackgroundImagePath = lm.Comol.Core.DomainModel.DocTemplateVers.Business.ImageHelper.GetImageUrl(expTemplate.Settings.BackgroundImagePath, BasePath, expTemplate.TemplateId, expTemplate.VersionId);
            }

            // SIGNATURES
            //IList<Signature> SignTEST = srcVersion.Signatures.ToList();


            expTemplate.Signatures = (
                from Signature srcSigns
                in srcVersion.Signatures.Where(srv => srv.IsActive)
                select SignatureConver(srcSigns, Data)).ToList();

            return(expTemplate);
        }
コード例 #18
0
        private List <Element> ReadElements(XmlReader xmlReader)
        {
            var mtype = string.Empty;
            var mid   = string.Empty;
            var cid   = string.Empty;

            var elements = new List <Element>();

            var index = 0;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (index == 0 && string.Compare(xmlReader.Name, "mrk", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        index++;
                        while (xmlReader.MoveToNextAttribute())
                        {
                            if (string.Compare(xmlReader.Name, "mid", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                mid = xmlReader.Value;
                            }
                            if (string.Compare(xmlReader.Name, "cid", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                cid = xmlReader.Value;
                            }
                            if (string.Compare(xmlReader.Name, "mtype", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                mtype = xmlReader.Value;
                            }
                        }
                    }
                    if (string.Compare(xmlReader.Name, "bpt", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        elements.Add(ReadOpeningElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ept", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        elements.Add(ReadClosingElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ph", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        elements.Add(ReadElementPlaceholder(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "mrk", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        var subElements  = ReadElements(xmlReaderSub);
                        if (subElements?.Count > 0)
                        {
                            elements.AddRange(subElements);
                        }

                        xmlReaderSub.Close();
                    }
                    break;

                case XmlNodeType.Whitespace:
                {
                    var whiteSpace = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    elements.Add(whiteSpace);
                }
                break;

                case XmlNodeType.Text:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    elements.Add(text);
                }
                break;

                case XmlNodeType.CDATA:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    elements.Add(text);
                }
                break;

                case XmlNodeType.EntityReference:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Name
                    };

                    elements.Add(text);
                }
                break;
                }
            }


            if (string.Compare(mtype, "protected", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                elements.Insert(0, new ElementLocked
                {
                    Type = Element.TagType.OpeningTag
                });
                elements.Add(new ElementLocked
                {
                    Type = Element.TagType.ClosingTag
                });
            }
            if (string.Compare(mtype, "seg", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                elements.Insert(0, new ElementSegment
                {
                    Id   = mid,
                    Type = Element.TagType.OpeningTag
                });
                elements.Add(new ElementSegment
                {
                    Id   = cid,
                    Type = Element.TagType.ClosingTag
                });
            }
            if (string.Compare(mtype, "x-sdl-comment", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                elements.Insert(0, new ElementComment
                {
                    Id   = cid,
                    Type = Element.TagType.OpeningTag
                });
                elements.Add(new ElementComment
                {
                    Id   = cid,
                    Type = Element.TagType.ClosingTag
                });
            }

            return(elements);
        }
コード例 #19
0
        private Target ReadTargetSegment(XmlReader xmlReader)
        {
            var segment = new Target();
            var index   = 0;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (index == 0 && string.Compare(xmlReader.Name, "mrk", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        index++;
                        while (xmlReader.MoveToNextAttribute())
                        {
                            if (string.Compare(xmlReader.Name, "mid", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                segment.Id = xmlReader.Value;
                            }
                        }
                    }
                    if (string.Compare(xmlReader.Name, "bpt", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadOpeningElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ept", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadClosingElementTagPair(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "ph", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        segment.Elements.Add(ReadElementPlaceholder(xmlReaderSub));
                        xmlReaderSub.Close();
                    }
                    else if (string.Compare(xmlReader.Name, "mrk", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var xmlReaderSub = xmlReader.ReadSubtree();
                        var elements     = ReadElements(xmlReaderSub);
                        if (elements?.Count > 0)
                        {
                            segment.Elements.AddRange(elements);
                        }

                        xmlReaderSub.Close();
                    }
                    break;

                case XmlNodeType.Whitespace:
                {
                    var whiteSpace = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(whiteSpace);
                }
                break;

                case XmlNodeType.Text:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(text);
                }
                break;

                case XmlNodeType.CDATA:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Value
                    };

                    segment.Elements.Add(text);
                }
                break;

                case XmlNodeType.EntityReference:
                {
                    var text = new ElementText
                    {
                        Text = xmlReader.Name
                    };

                    segment.Elements.Add(text);
                }
                break;
                }
            }

            return(segment);
        }