This is a migrated thread and some comments may be shown as answers.

Caching of ICustomeTypeProvider

1 Answer 34 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Franz
Top achievements
Rank 1
Franz asked on 15 Jul 2013, 10:22 AM
Hi,

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?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Jul 2013, 02:00 PM
Hello Franz,

I have just replied to the other thread you started on the same topic. 

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PropertyGrid
Asked by
Franz
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or