private IEnumerable<PropertyInfo> GetPropertiesInOrder()
{
var baseType = this.Type;
var declaringTypes = new Stack<Type>();
while (baseType != null)
{
declaringTypes.Push(baseType);
baseType = baseType.BaseType;
}
while (declaringTypes.Count > 0)
{
var declaringType = declaringTypes.Pop();
foreach (var propertyInfo in declaringType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly))
{
yield return this.Type.GetProperties().First(c => c.Name == propertyInfo.Name);
}
}
}