I implement an application, where some objects, which exist on server, are edited remotely in a Silverlight application.
For editing of properties of an object I use the RadPropertyGrid control. Because there is no actual type of the edited object in the Silverlight app, I implemented a class, which implement the ICustomTypeProvider interface, and which returns all necessary metadata.
Everything works fine until I need to edit an object of another type. The RadPropertyGrid always shows property of the first type.
I analyzed your code, and found the following:
internal static IEnumerable<ItemPropertyInfo> RetrieveItemPropertiesFromPropertyDescriptors(object item)
{
if (item != null && ShouldCacheProertyDescriptorsForType(item.GetType()) && ItemPropertiesCache.ContainsKey(item.GetType().AssemblyQualifiedName))
{
return ItemPropertiesCache[item.GetType().AssemblyQualifiedName];
}
if (ItemPropertiesCache.ContainsKey(item.GetType().AssemblyQualifiedName))
{
return ItemPropertiesCache[item.GetType().AssemblyQualifiedName];
}
else
{
var result = CreateItemPropertyInfoFromDescriptor(GetPropertyDescriptors(item));
if (item != null && ShouldCacheProertyDescriptorsForType(item.GetType()))
{
ItemPropertiesCache.Add(item.GetType().AssemblyQualifiedName, result);
}
return result;
}
}
First of all, in the code the to ifs check actually the same. If the first one is false because the item implements IDynamicMetaObjectProvider, anyway the second if is always true.
So, because I have only one class, which implement the ICustomTypeProvider interface, the first set of properties is always cached.
What can I do in this situation? Could you please fix it in you next version?