internal Element_ToastVisual ConvertToElement() { var visual = new Element_ToastVisual() { Language = Language, BaseUri = BaseUri, AddImageQuery = AddImageQuery }; if (BindingGeneric == null) { throw new NullReferenceException("BindingGeneric must be initialized"); } Element_ToastBinding binding = BindingGeneric.ConvertToElement(); // TODO: If a BaseUri wasn't provided, we can potentially optimize the payload size by calculating the best BaseUri visual.Bindings.Add(binding); if (BindingShoulderTap != null) { visual.Bindings.Add(BindingShoulderTap.ConvertToElement()); } return(visual); }
internal Element_ToastVisual ConvertToElement() { var visual = new Element_ToastVisual() { Language = Language, BaseUri = BaseUri, AddImageQuery = AddImageQuery }; Element_ToastBinding binding; // If BindingGeneric is provided, we'll ignore all the other properties if (BindingGeneric != null) { binding = BindingGeneric.ConvertToElement(); } else { binding = new Element_ToastBinding(ToastTemplateType.ToastGeneric); if (TitleText == null) { // If there's subsequent text, add a blank line of text if (BodyTextLine1 != null || BodyTextLine2 != null) { binding.Children.Add(new Element_ToastText()); } } else { binding.Children.Add(TitleText.ConvertToElement()); } if (BodyTextLine1 == null) { // If there's subsequent text, add a blank line of text if (BodyTextLine2 != null) { binding.Children.Add(new Element_ToastText()); } } else { binding.Children.Add(BodyTextLine1.ConvertToElement()); } if (BodyTextLine2 != null) { binding.Children.Add(BodyTextLine2.ConvertToElement()); } // Add inline images foreach (var img in InlineImages) { binding.Children.Add(img.ConvertToElement()); } // And if there's an app logo override, add it if (AppLogoOverride != null) { binding.Children.Add(AppLogoOverride.ConvertToElement()); } } // TODO: If a BaseUri wasn't provided, we can potentially optimize the payload size by calculating the best BaseUri visual.Bindings.Add(binding); return(visual); }