diff --git a/XAML conversion/Parsers/ObjectParser.cs b/XAML conversion/Parsers/ObjectParser.cs index 5e6d066..6150c02 100644 --- a/XAML conversion/Parsers/ObjectParser.cs +++ b/XAML conversion/Parsers/ObjectParser.cs @@ -1,5 +1,6 @@ using System; using System.Xml.Linq; +using System.Windows.Markup; namespace XamlConversion.Parsers { @@ -7,7 +8,7 @@ class ObjectParser : XamlParser { public ObjectParser(XamlConvertor.State state) : base(state) - {} + { } public string VariableName { get; protected set; } @@ -24,9 +25,16 @@ protected override void ParseAttribute(XAttribute attribute) { if (attribute.IsNamespaceDeclaration) return; + try + { + var propertyName = attribute.Name.LocalName; + SetProperty(VariableName, Type, propertyName, attribute.Value); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(attribute.Name); + } - var propertyName = attribute.Name.LocalName; - SetProperty(VariableName, Type, propertyName, attribute.Value); } protected override void ParseElement(XElement element) @@ -39,11 +47,23 @@ protected override void ParseElement(XElement element) } else { - throw new NotImplementedException(); + var propertyParser = new PropertyParser(State, this); + object[] attributes = Type.GetCustomAttributes(typeof(ContentPropertyAttribute), true); + + if (attributes.Length > 0) + { + XElement e = new XElement(VariableName + "." + + (attributes[0] as ContentPropertyAttribute).Name, element); + propertyParser.Parse(e); + } + else + { + throw new NotImplementedException(); + } } } protected override void ParseEnd() - {} + { } } -} \ No newline at end of file +}