protected void HandleChild(ParseResult result, XElement child, string baseUri, bool addImageQuery) { switch (child.Name.LocalName.ToLower()) { case "text": AdaptiveTextField text = new AdaptiveTextField(Context, SupportedFeatures); text.Parse(result, child, true); if (!result.IsOkForRender()) { return; } if (text.Placement == TextPlacement.Inline && Context == NotificationType.Toast) { if (Children.OfType <AdaptiveTextField>().Where(i => i.Placement == TextPlacement.Inline).Count() >= 3) { if (!_hasWarnedAboutTooManyTextElements) { string warningMessage; if (SupportedFeatures.RS1_Style_Toasts) { warningMessage = "Toasts can only display up to 3 text elements outside of a group/subgroup. Place your additional text elements inside a group/subgroup."; } else { warningMessage = "Toasts can only display up to 3 text elements."; } result.AddWarning(warningMessage, GetErrorPositionInfo(child)); _hasWarnedAboutTooManyTextElements = true; } return; } } this.Add(text); return; case "image": AdaptiveImage image = new AdaptiveImage(Context, SupportedFeatures); image.Parse(result, child, baseUri, addImageQuery); if (!result.IsOkForRender()) { return; } if (Context == NotificationType.Toast && !SupportedFeatures.AdaptiveToasts && image.Placement == Placement.Inline ) { if (Children.OfType <AdaptiveImage>().Where(i => i.Placement == Placement.Inline).Count() >= 6) { if (!_hasWarnedAboutTooManyInlineImages) { result.AddWarning("Toasts can only display up to 6 inline images.", GetErrorPositionInfo(child)); _hasWarnedAboutTooManyInlineImages = true; } return; } } this.Add(image); return; case "group": if (Context != NotificationType.Toast || SupportedFeatures.AdaptiveToasts ) { AdaptiveGroup group = new AdaptiveGroup(Context, SupportedFeatures); group.Parse(result, child, baseUri, addImageQuery); if (!result.IsOkForRender()) { return; } if (group != null) { this.Add(group); } return; } break; case "progress": if (Context == NotificationType.Toast && SupportedFeatures.ToastProgressBar) { AdaptiveProgress progress = new AdaptiveProgress(Context, SupportedFeatures); progress.Parse(result, child); if (!result.IsOkForRender()) { return; } this.Add(progress); return; } break; } result.AddWarning($"Invalid child \"{child.Name.LocalName}\" under binding element. It will be ignored.", GetErrorPositionInfo(child)); }
private void Add(AdaptiveProgress child) { AddHelper(child); }