using System;
namespace Core.Common.Gui
{
///
/// Extensions of
///
public static class PropertyInfoExtensions
{
///
/// Creates object properties based on the combination of and
///
/// The property information used for creating the object properties
/// The data that will be set to the created object properties instance
public static IObjectProperties CreateObjectProperties(this PropertyInfo propertyInfo, object sourceData)
{
var objectProperties = (IObjectProperties) Activator.CreateInstance(propertyInfo.PropertyType);
objectProperties.Data = propertyInfo.GetObjectPropertiesData != null
? propertyInfo.GetObjectPropertiesData(sourceData)
: sourceData;
if (propertyInfo.AfterCreate != null)
{
propertyInfo.AfterCreate(objectProperties);
}
return objectProperties;
}
}
}