internal void ParseKnownAttributes(AttributesHelper attributes, ParseResult result, bool isBindingRootLevel)
        {
            // Max lines is supported on non-toasts, and adaptive toasts, and group/subgroups
            if (Context != NotificationType.Toast || SupportedFeatures.AdaptiveToasts || !isBindingRootLevel)
            {
                // hint-max-lines is optional
                int hintMaxLines;
                if (TryParse(result, attributes, ATTR_TEXT_HINT_MAX_LINES, out hintMaxLines))
                {
                    this.HintMaxLines = hintMaxLines;
                }
            }

            // These features are supported on non-toasts, and group/subgroups
            if (Context != NotificationType.Toast || !isBindingRootLevel)
            {
                // hint-align is optional
                HintAlign hintAlign;
                if (TryParseEnum(result, attributes, ATTR_TEXT_HINT_ALIGN, out hintAlign))
                {
                    this.HintAlign = hintAlign;
                }

                // hint-min-lines is optional
                int hintMinLines;
                if (TryParse(result, attributes, ATTR_TEXT_HINT_MIN_LINES, out hintMinLines))
                {
                    this.HintMinLines = hintMinLines;
                }

                // hint-style is optional
                HintStyle hintStyle;
                if (TryParseEnum(result, attributes, ATTR_TEXT_HINT_STYLE, out hintStyle))
                {
                    this.HintStyle = hintStyle;
                }

                // hint-wrap is optional
                bool hintWrap;
                if (TryParse(result, attributes, ATTR_TEXT_HINT_WRAP, out hintWrap))
                {
                    this.HintWrap = hintWrap;
                }
            }

            if (Context == NotificationType.Tile)
            {
                Id = attributes.PopAttributeValue(ATTR_TEXT_ID);
            }

            TextPlacement placement;

            if (TryParseEnum(result, attributes, ATTR_TEXT_PLACEMENT, out placement))
            {
                this.Placement = placement;
            }
        }
        protected virtual void ParseKnownAttributes(XElement node, AttributesHelper attributes, ParseResult result, string baseUri, bool addImageQuery)
        {
            // Template is required
            XAttribute attrTemplate = attributes.PopAttribute(ATTR_BINDING_TEMPLATE);

            if (attrTemplate == null)
            {
                result.AddWarning("template attribute wasn't provided on binding element.", GetErrorPositionInfo(node));
                throw new IncompleteElementException();
            }

            // If template is unknown, stop there
            Template template;

            if (!TryParseEnum(attrTemplate.Value, out template))
            {
                result.AddWarning($"template attribute \"{attrTemplate.Value}\" is not supported.", GetErrorPositionInfo(attrTemplate));
                throw new IncompleteElementException();
            }

            this.Template = template;

            switch (Template)
            {
            case Template.TileLarge:
            case Template.TileMedium:
            case Template.TileWide:
            case Template.TileSmall:
                Context = NotificationType.Tile;
                break;

            case Template.ToastGeneric:
                Context = NotificationType.Toast;
                break;

#if EXPERIMENTAL
            case Template.CortanaGeneric:
                Context = NotificationType.Cortana;
                break;

            case Template.NewsFeedGeneric:
                Context = NotificationType.NewsFeed;
                break;
#endif
            }

            if (Context != NotificationType.Toast)
            {
                // Branding is optional
                Branding branding;
                if (TryParseEnum(result, attributes, ATTR_BINDING_BRANDING, out branding, false)) // not case-sensitive
                {
                    this.Branding = branding;
                }

                // Display name is optional
                XAttribute attrDisplayName = attributes.PopAttribute(ATTR_BINDING_DISPLAY_NAME, false); // not case-sensitive
                if (attrDisplayName != null)
                {
                    this.DisplayName = attrDisplayName.Value;
                }

                // hint-overlay is optional
                double hintOverlay;
                if (TryParse(result, attributes, ATTR_BINDING_HINT_OVERLAY, out hintOverlay))
                {
                    this.HintOverlay = hintOverlay;
                }
            }

            if (Context == NotificationType.Tile)
            {
                if (SupportedFeatures.ChaseableTiles)
                {
                    // attributes is optional
                    XAttribute attrArguments = attributes.PopAttribute(ATTR_ARGUMENTS);
                    if (attrArguments != null)
                    {
                        this.Arguments = attrArguments.Value;
                    }
                }

                if (Template == Template.TileWide)
                {
                    HintLockDetailedStatus1 = attributes.PopAttributeValue(ATTR_BINDING_HINTLOCK1);
                    HintLockDetailedStatus2 = attributes.PopAttributeValue(ATTR_BINDING_HINTLOCK2);
                    HintLockDetailedStatus3 = attributes.PopAttributeValue(ATTR_BINDING_HINTLOCK3);
                }
            }

            // BaseUri is optional
            {
                XAttribute attrBaseUri = attributes.PopAttribute(ATTR_BINDING_BASEURI);
                if (attrBaseUri != null)
                {
                    baseUri = attrBaseUri.Value; // Overwrite cascaded value if it was specified
                    Uri uri;
                    if (Uri.TryCreate(baseUri, UriKind.RelativeOrAbsolute, out uri))
                    {
                        BaseUri = uri;
                    }
                }
            }

            // AddImageQuery is optional
            {
                bool val;
                if (TryParse(result, attributes, ATTR_BINDING_ADDIMAGEQUERY, out val))
                {
                    addImageQuery = val; // Overwrite cascaded value if it was specified
                    AddImageQuery = val;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns false if attribute not found. If attribute is using data binding, configures data binding. Otherwise, passes the attribute value to the provided method.
        /// </summary>
        /// <param name="attributes"></param>
        /// <param name="attributeName"></param>
        /// <param name="processValue"></param>
        internal bool TryPopAttributeValueWithBinding(ParseResult result, AttributesHelper attributes, string attributeName, out string bindingName, Action <string> processValue)
        {
            string attrValue = attributes.PopAttributeValue(attributeName);

            return(TryProcessBindableValue(result, attrValue, out bindingName, processValue));
        }