How to determine and check whether a type in assembly is Custom type or Primitive type using reflection in .NET?
-
Hello, Is it possible to check at runtime whether given type is Custom data type or one of primitive data types of .NET? I have defined user defined types in assembly and those all types are some structs. I need to call the methods of user defined types of whome parameters are those structs. So this needs to fill the data accordingly before calling those function at runtime using reflection. Now Is there any method available in reflection by which we can track that given data type is custom or primitive data type. I know about IsClass attribute, but my targeted user defined data types are not classes , these public are STRUCTS. Regard
-
Hello, Is it possible to check at runtime whether given type is Custom data type or one of primitive data types of .NET? I have defined user defined types in assembly and those all types are some structs. I need to call the methods of user defined types of whome parameters are those structs. So this needs to fill the data accordingly before calling those function at runtime using reflection. Now Is there any method available in reflection by which we can track that given data type is custom or primitive data type. I know about IsClass attribute, but my targeted user defined data types are not classes , these public are STRUCTS. Regard
Perhaps I'm not getting your issue. If you need to call a method on your type then you need to verify it exists before attempting to call it so what does it matter if its an intrinsic .net type or not. Unless you have overridden methods your method won't exist.
I know the language. I've read a book. - _Madmatt
-
Hello, Is it possible to check at runtime whether given type is Custom data type or one of primitive data types of .NET? I have defined user defined types in assembly and those all types are some structs. I need to call the methods of user defined types of whome parameters are those structs. So this needs to fill the data accordingly before calling those function at runtime using reflection. Now Is there any method available in reflection by which we can track that given data type is custom or primitive data type. I know about IsClass attribute, but my targeted user defined data types are not classes , these public are STRUCTS. Regard
-
Hello, Is it possible to check at runtime whether given type is Custom data type or one of primitive data types of .NET? I have defined user defined types in assembly and those all types are some structs. I need to call the methods of user defined types of whome parameters are those structs. So this needs to fill the data accordingly before calling those function at runtime using reflection. Now Is there any method available in reflection by which we can track that given data type is custom or primitive data type. I know about IsClass attribute, but my targeted user defined data types are not classes , these public are STRUCTS. Regard
Maybe see if it's in the System namespace? Perhaps check to see if it's in a System Assembly? Perchance even access the Attributes of the Assembly to check the creator? But I don't think it would be 100% accurate. You could also compare it to a known built-in type; if the type says it's a System.Int32, compare it to the System.Int32 type. Just guessing, I haven't tried it.
-
Maybe see if it's in the System namespace? Perhaps check to see if it's in a System Assembly? Perchance even access the Attributes of the Assembly to check the creator? But I don't think it would be 100% accurate. You could also compare it to a known built-in type; if the type says it's a System.Int32, compare it to the System.Int32 type. Just guessing, I haven't tried it.
-
PIEBALDconsult wrote:
Maybe see if it's in the System namespace?
I think a form object in the windows application gives namespace as the application namespace and notSystem.Windows.Forms. So I guess this won't work.
Riiight... that's kinda what I said. Custom types wouldn't (or shouldn't) be in the System namespace.