public override void SetValue (XamlObjectElement obj, object value)
{
// We do this first to cover the case where you are setting a list to a list or
// a resource dictionary to a resource dictionary, binding to a binding, ect
// as opposed to adding items to the list or dictionary.
if (Type.IsAssignableFrom (value.GetType ())) {
prop.SetValue (target, ConvertValue (Type, value), null);
return;
}
{
Binding binding = value as Binding;
if (binding != null) {
SetBinding (binding);
return;
}
}
{
TemplateBindingExpression tb = value as TemplateBindingExpression;
if (tb != null) {
SetTemplateBinding (tb);
return;
}
}
if (typeof (IList).IsAssignableFrom (Type)) {
AddToCollection (obj, value);
return;
}
if (typeof (IDictionary).IsAssignableFrom (Type)) {
AddToDictionary (obj, value);
return;
}
throw Parser.ParseException ("Unable to set property {0} to value {1}.", Name, value);
}