Ejemplo n.º 1
0
        public void SetProperty(string name, DrawableProperty property)
        {
            var lastProperty = GetProperty(name);

            if (lastProperty != null)
            {
                Properties.Remove(lastProperty);
            }

            Properties.Add(property);
        }
Ejemplo n.º 2
0
        void reloadProperties(XElement element)
        {
            // Ensure we are drawables
            if (!IsDrawable)
            {
                throw new MarkupException($"Type '{DrawableType}' is not a drawable.");
            }

            // Parse properties
            Properties.Clear();

            foreach (var attribute in element.Attributes())
            {
                // Ignore namespace attributes
                if (attribute.Name.LocalName == "xmlns" ||
                    element.GetPrefixOfNamespace(attribute.Name.Namespace) == "xmlns")
                {
                    continue;
                }

                var property = DrawableType.GetFieldOrProperty(attribute.Name.LocalName);

                if (property == null)
                {
                    throw new MarkupException($"Drawable '{DrawableType}' [{GivenName}] does not contain a property named '{attribute.Name.LocalName}'.");
                }

                try
                {
                    Properties.Add(DrawableProperty.Parse(property, attribute.Value));
                }
                catch (Exception e)
                {
                    throw new MarkupException($"Could not parse property '{attribute.Name}' of Drawable '{DrawableType}' [{GivenName}].", e);
                }
            }
        }