void ParseObjectContent(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, XamlTextValue initializeFromTextValueInsteadOfConstructor)
{
bool isDefaultValueSet = false;
object defaultPropertyValue = null;
XamlProperty defaultCollectionProperty = null;
if (defaultProperty != null && defaultProperty.IsCollection && !element.IsEmpty)
{
defaultPropertyValue = defaultProperty.GetValue(obj.Instance);
obj.AddProperty(defaultCollectionProperty = new XamlProperty(obj, defaultProperty));
}
foreach (XmlNode childNode in GetNormalizedChildNodes(element))
{
XmlElement childElement = childNode as XmlElement;
if (childElement != null)
{
if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
{
continue;
}
if (ObjectChildElementIsPropertyElement(childElement))
{
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty, defaultPropertyValue);
continue;
}
}
if (initializeFromTextValueInsteadOfConstructor != null)
{
continue;
}
XamlPropertyValue childValue = ParseValue(childNode);
if (childValue != null)
{
if (defaultProperty != null && defaultProperty.IsCollection)
{
defaultCollectionProperty.ParserAddCollectionElement(null, childValue);
CollectionSupport.AddToCollection(defaultProperty.ReturnType, defaultPropertyValue, childValue);
}
else
{
if (defaultProperty == null)
{
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
}
if (isDefaultValueSet)
{
throw new XamlLoadException("default property may have only one value assigned");
}
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
isDefaultValueSet = true;
}
}
}
}