How do I determine if a property is a user-defined type? I tried to use IsClass as shown below but its value was true for String properties (and who knows what else).
foreach (var property in type.GetProperties()) {
if (property.PropertyType.IsClass) {
// do something with property
}
}
* Updated for more clarity *
I am trying to traverse a given type's definition and if the given type or any of its public properties are defined within the assembly, I am searching for an embedded JavaScript document. I just don't want to waste processing resources and time on native .NET types.
string
is a class. How do you distinguish between a "user-defined" type and another? Is a type from an external non-standard library "user-defined"? – WhizIsClass
is not relevant. Guess one valid option instead would be checking the type namespace: for instance, if it belongs to "System.*" it is definitely NOT user-defined, and so on... – UnderglazeSystem
namespace that I'm aware of... – Skunk