This documentation is archived and is not being maintained.
Type::IsContextfulImpl Method
Visual Studio 2008
Implements the IsContextful property and determines whether the Type can be hosted in a context.
Assembly: mscorlib (in mscorlib.dll)
The following example demonstrates a use of the IsContextfulImpl method.
using namespace System; using namespace System::Reflection; public ref class MyTypeDelegatorClass: public TypeDelegator { public: String^ myElementType; private: Type^ myType; public: MyTypeDelegatorClass( Type^ myType ) : TypeDelegator( myType ) { this->myType = myType; } protected: // Override IsContextfulImpl. virtual bool IsContextfulImpl() override { // Check whether the type is contextful. if ( myType->IsContextful ) { myElementType = " is contextful "; return true; } return false; } }; public ref class MyTypeDemoClass{}; // This class demonstrates IsContextfulImpl. public ref class MyContextBoundClass: public ContextBoundObject { public: String^ myString; }; int main() { try { MyTypeDelegatorClass^ myType; Console::WriteLine( "Check whether MyContextBoundClass can be hosted in a context." ); // Check whether MyContextBoundClass is contextful. myType = gcnew MyTypeDelegatorClass( MyContextBoundClass::typeid ); if ( myType->IsContextful ) { Console::WriteLine( "{0} can be hosted in a context.", MyContextBoundClass::typeid ); } else { Console::WriteLine( "{0} cannot be hosted in a context.", MyContextBoundClass::typeid ); } myType = gcnew MyTypeDelegatorClass( MyTypeDemoClass::typeid ); Console::WriteLine( "\nCheck whether MyTypeDemoClass can be hosted in a context." ); if ( myType->IsContextful ) { Console::WriteLine( "{0} can be hosted in a context.", MyTypeDemoClass::typeid ); } else { Console::WriteLine( "{0} cannot be hosted in a context.", MyTypeDemoClass::typeid ); } } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: