本文整理汇总了VB.NET中System.Type.IsContextfulImpl方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Type.IsContextfulImpl方法的具体用法?VB.NET Type.IsContextfulImpl怎么用?VB.NET Type.IsContextfulImpl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.IsContextfulImpl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyTypeDelegatorClass
' 导入命名空间
Imports System.Reflection
Public Class MyTypeDelegatorClass
Inherits TypeDelegator
Public myElementType As String = Nothing
Private myType As Type = Nothing
Public Sub New(ByVal myType As Type)
MyBase.New(myType)
Me.myType = myType
End Sub
' Override IsContextfulImpl.
Protected Overrides Function IsContextfulImpl() As Boolean
' Check whether the type is contextful.
If myType.IsContextful Then
myElementType = " is contextful "
Return True
End If
Return False
End Function 'IsContextfulImpl
End Class
Public Class MyTypeDemoClass
Public Shared Sub Main()
Try
Dim myType As MyTypeDelegatorClass
Console.WriteLine("Check whether MyContextBoundClass can be hosted in a context.")
' Check whether MyContextBoundClass is contextful.
myType = New MyTypeDelegatorClass(GetType(MyContextBoundClass))
If myType.IsContextful Then
Console.WriteLine(GetType(MyContextBoundClass).ToString() + " can be hosted in a context.")
Else
Console.WriteLine(GetType(MyContextBoundClass).ToString() + " cannot be hosted in a context.")
End If
' Check whether the int type is contextful.
myType = New MyTypeDelegatorClass(GetType(MyTypeDemoClass))
Console.WriteLine(ControlChars.NewLine + "Check whether MyTypeDemoClass can be hosted in a context.")
If myType.IsContextful Then
Console.WriteLine(GetType(MyTypeDemoClass).ToString() + " can be hosted in a context.")
Else
Console.WriteLine(GetType(MyTypeDemoClass).ToString() + " cannot be hosted in a context.")
End If
Catch e As Exception
Console.WriteLine("Exception: {0}", e.Message.ToString())
End Try
End Sub
End Class
' This class demonstrates the IsContextfulImpl method.
Public Class MyContextBoundClass
Inherits ContextBoundObject
Public myString As String = "This class is used to demonstrate members of the Type class."
End Class