private unsafe bool LookupPropertyObject (Value* top_level, Value* parent_value, string xmlns, string name, int dot, bool create, out Value value)
{
string prop_name = name.Substring (dot + 1);
object parent = Value.ToObject (null, parent_value);
if (parent == null) {
value = Value.Empty;
return false;
}
PropertyInfo pi = null;
bool is_attached = true;
string type_name = name.Substring (0, dot);
Type t = parent.GetType ();
while (t != typeof (object)) {
if (t.Name == type_name) {
is_attached = false;
break;
}
t = t.BaseType;
}
if (is_attached) {
Type attach_type = null;
string full_type_name = type_name;
if (xmlns != null) {
string ns = ClrNamespaceFromXmlns (xmlns);
full_type_name = String.Concat (ns, ".", type_name);
}
MethodInfo get_method = GetGetMethodForAttachedProperty (top_level, xmlns, type_name, full_type_name, prop_name);
if (get_method != null)
attach_type = get_method.ReturnType;
if (attach_type == null) {
value = Value.Empty;
return false;
}
ManagedType mt = Deployment.Current.Types.Find (attach_type);
value = Value.Empty;
value.IsNull = true;
value.k = mt.native_handle;
return true;
} else {
pi = parent.GetType ().GetProperty (name.Substring (dot + 1), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);
if (pi == null) {
value = Value.Empty;
return false;
}
ManagedType mt = Deployment.Current.Types.Find (pi.PropertyType);
value = Value.Empty;
value.k = mt.native_handle;
value.IsNull = true;
return true;
}
}