This documentation is archived and is not being maintained.
Type::IsContextfulImpl Method
Visual Studio 2010
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 SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: