static int GetClassDepth(Type type) { int depth = 0; Type objectType = Types.Object; while (type != objectType) { type = type.BaseType; ++depth; } return depth; }