internal static object GetMemberValue(this XamlObject xobj, XamlMember xm) { if (xm.IsUnknown) { return(null); } if (xm.IsAttachable) { return(xobj.GetRawValue()); // attachable property value } // FIXME: this looks like an ugly hack. Is this really true? What if there's MarkupExtension that uses another MarkupExtension type as a member type. var obj = xobj.Context.GetRawValue(); if (xm == XamlLanguage.Initialization) { return(obj); } if (xm == XamlLanguage.Items) // collection itself. { return(obj); } if (xm == XamlLanguage.Arguments) // object itself { return(obj); } if (xm == XamlLanguage.PositionalParameters) { return(xobj.GetRawValue()); // dummy value } TypeConverter tc = null; var cas = xm.GetCustomAttributeProvider().GetCustomAttributes(true); foreach (var ca in cas) { tc = TypeDescriptor.GetConverter(ca); if (tc != null) { break; } } if (tc != null) { return(xm.UnderlyingGetter.Invoke(xobj.GetRawValue(), new object[] {})); } return(xm.Invoker.GetValue(xobj.GetRawValue())); }
public static string ConstructorArgumentName(this XamlMember xm) { var caa = xm.GetCustomAttributeProvider().GetCustomAttribute <ConstructorArgumentAttribute>(false); return(caa.ArgumentName); }
internal static bool IsConstructorArgument(this XamlMember xm) { var ap = xm.GetCustomAttributeProvider(); return(ap != null && ap.GetCustomAttributes(typeof(ConstructorArgumentAttribute), false).Length > 0); }