private static bool InitializeInstancePropertiesFrom(PropertyBag bag, object target)
{
bool completelyInitialized = true;
foreach (KeyValuePair<string, object> pair in bag.Properties)
{
string propertyName = pair.Key;
object propertyValue = pair.Value;
PropertyInfo targetProperty = target.GetType().GetProperty(propertyName);
if (IsPropertyWritable(targetProperty))
{
completelyInitialized &= SetPropertyValue(target, targetProperty, propertyValue);
}
}
return completelyInitialized;
}