C# Type IsContextfulImpl

Description

Type IsContextfulImpl implements the IsContextful property and determines whether the Type can be hosted in a context.

Syntax

Type.IsContextfulImpl has the following syntax.


protected virtual bool IsContextfulImpl()

Returns

Type.IsContextfulImpl method returns true if the Type can be hosted in a context; otherwise, false.

Example

The following example demonstrates a use of the IsContextfulImpl method.


/* w ww  . j  av  a  2  s  .co m*/
using System;
using System.Reflection;
public class MyTypeDelegatorClass : TypeDelegator
{
    public string myElementType = null;
    private Type myType = null ; 

    public MyTypeDelegatorClass(Type myType) : base(myType)
    {
        this.myType = myType;
    }
    protected override bool IsContextfulImpl()
    {
        if(myType.IsContextful)
        { 
            myElementType = " is contextful ";
            return true;
        }
        return false;
    }
}
public class MyTypeDemoClass
{
    public static void Main()
    {
        MyTypeDelegatorClass myType;
        Console.WriteLine ("Check whether MyContextBoundClass can be hosted in a context.");
        myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass));
        Console.WriteLine(myType.IsContextful);
    }
}
public class MyContextBoundClass : ContextBoundObject
{
    public string myString = "This class is used to demonstrate members of the Type class.";
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version