Caching of ICustomeTypeProvider

2 posts, 0 answers
  1. Franz
    Franz avatar
    4 posts
    Member since:
    Mar 2013

    Posted 15 Jul 2013 Link to this post

    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?

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 Jul 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top