internal Element_AdaptiveProgressBar ConvertToElement()
        {
            // If Value not provided, we use 0
            var val = Value;

            if (val == null)
            {
                val = AdaptiveProgressBarValue.FromValue(0);
            }

            var answer = new Element_AdaptiveProgressBar();

#if WINRT
            answer.Title = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Title, Title);
            answer.Value = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Value, val.ToXmlString());
            answer.ValueStringOverride = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.ValueStringOverride, ValueStringOverride);
            answer.Status = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Status, Status);
#else
            answer.Title = Title?.ToXmlString();
            answer.Value = val.ToXmlString();
            answer.ValueStringOverride = ValueStringOverride?.ToXmlString();
            answer.Status = Status?.ToXmlString();
#endif

            if (answer.Status == null)
            {
                throw new NullReferenceException("Status property is required.");
            }

            return(answer);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves the notification XML content as a string.
        /// </summary>
        /// <returns>The notification XML content as a string.</returns>
        public string GetContent()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stream, new System.Xml.XmlWriterSettings()
                {
                    Encoding = Encoding.UTF8, // Use UTF-8 encoding to save space (it defaults to UTF-16 which is 2x the size)
                    Indent = false,
                    NewLineOnAttributes = false
                }))
                {
                    XmlWriterHelper.Write(writer, this);
                }

                stream.Position = 0;

                using StreamReader reader = new(stream);
                return(reader.ReadToEnd());
            }
        }
Esempio n. 3
0
        internal Element_AdaptiveText ConvertToElement()
        {
            var answer = new Element_AdaptiveText()
            {
                Lang     = Language,
                Style    = HintStyle,
                Wrap     = HintWrap,
                MaxLines = HintMaxLines,
                MinLines = HintMinLines,
                Align    = HintAlign
            };

#if WINRT
            answer.Text = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveTextBindableProperty.Text, Text);
#else
            answer.Text = Text?.ToXmlString();
#endif

            return(answer);
        }