The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Type::IsContextfulImpl Method ()
.NET Framework (current version)
Implements the IsContextful property and determines whether the Type can be hosted in a context.
Assembly: mscorlib (in mscorlib.dll)
This method can be overridden by a derived class.
A context intercepts calls to the class members and enforce policies that are applied to the class, such as synchronization.
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 ); } }
.NET Framework
Available since 1.1
Available since 1.1
Show: