Crainiate Community

Support and discussion for users of Crainiate component software products
Welcome to Crainiate Community Sign in | Join | Help
in Search

Whats the best way...

Last post 12-23-2006 4:52 PM by Archer. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-18-2006 5:30 PM

    Whats the best way...

    1. To determine if there are changes to the object
    2. To revert back to the original values

    Regards
    • 82.45.255.253
  • 12-18-2006 7:52 PM In reply to

    Re: Whats the best way...

    The Concurrency property for any persisted object will provide you with a concurrency object. The HasChanged property will determine if any values have changed.

    Resetting the values is a bit trickier. You will need to use reflection to reset each property value to the value contained in the concurrency collection. You can use a ReflectionCacheItem from the reflection cache which contains lots of useful cached properties for a type:

    ReflectionCacheItem cache = Component.Instance.ReflectionCache.Lookup(type);

    Then loop through the value properties for the type:

    foreach (PropertyInfo valueprop in cache.ValueProperties)

    and use SetValue to set the property value. You can get the name of the property from the collection by using the static Formatter.GetPropertyName method. You can use an empty string as a seperator for this method as you are not interested in reference properties.

    • 81.153.80.231
  • 12-21-2006 6:25 PM In reply to

    Re: Whats the best way...

    How can I use the "HasChanged" Method? It takes an argument and I'm not clear on what I should use.

    • 82.45.255.253
  • 12-23-2006 4:39 PM In reply to

    Re: Whats the best way...

    The parameter is an IPersistable object graph, eg the object that you want to check against the concurrency collection.
    • 81.153.80.231
  • 12-23-2006 4:52 PM In reply to

    Re: Whats the best way...

    I tried following and it works:

    P.Concurrency.HasChanged(P)



    • 82.45.255.253
Page 1 of 1 (5 items)