More in this section

Forums / Developing with Sitefinity / Reflecting DynamicContent ‘Values’ (fields)

Reflecting DynamicContent ‘Values’ (fields)

3 posts, 0 answered
  1. Richard
    Richard avatar
    15 posts
    Registered:
    17 Aug 2012
    31 Jul 2012
    Link to this post

    Hello,

    In order to write a generic class, I would like to get all of the field names of a DynamicContent type, so I can convert them into a class that can be used by .NET JSON deserialization methods.

    Is this possible, or will I have to write an individual method for each data type? Are there any other ways to do this, that are better than this current idea?

    Thanks in advance for your help!
    Rich

  2. Stephen2
    Stephen2 avatar
    94 posts
    Registered:
    05 Feb 2012
    05 Sep 2012
    Link to this post
    Hi Sitefinity community!

    It would be great if anyone has worked out how to do this, or similar... I'm right now on a breakpoint with a DynamicContent item, trying to figure out:

    "How do I figure out what the field name for the Identifying FIeld on a DynamicContent is?"  or even better, a complete list of fields available using .GetValue<>

    Any insight will be great
  3. Stephen2
    Stephen2 avatar
    94 posts
    Registered:
    05 Feb 2012
    05 Sep 2012
    Link to this post
    So, to get all fields you can use:
    var properties = System.ComponentModel.TypeDescriptor.GetProperties(dataItem);

    Reviewing this will give you everything you need, EXCEPT for any method of identifying which field is the "Identifying Field" unfortunately, from my investigation.

    If anyone (Sitefinity?) has more insight, that would be great.
3 posts, 0 answered