Ncqrs.Eventing.Storage.PropertyBagConverter.SetPropertyValue C# (CSharp) Method

SetPropertyValue() private static method

private static SetPropertyValue ( object instance, PropertyInfo targetProperty, object value ) : bool
instance object
targetProperty System.Reflection.PropertyInfo
value object
return bool
        private static bool SetPropertyValue(object instance, PropertyInfo targetProperty, object value)
        {
            try
            {
                if (RequiresConversion(targetProperty, value))
                {
                    value = System.Convert.ChangeType(value, targetProperty.PropertyType);
                }

                targetProperty.SetValue(instance, value, null);

                return true;
            }
            catch (InvalidCastException)
            {
                // If the conversion is not possible, ignore the exception
                return false;
            }
        }