Type.IsContextful Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che indica se è possibile includere Type in un contesto.
public:
property bool IsContextful { bool get(); };
public bool IsContextful { get; }
member this.IsContextful : bool
Public ReadOnly Property IsContextful As Boolean
Valore della proprietà
true
se Type può essere contenuto in un contesto; in caso contrario, false
.
Implementazioni
Esempio
Nell'esempio seguente vengono IsContextful
illustrate le proprietà , e della classe IsMarshalByRef IsPrimitive Type . Controlla se il tipo specificato può essere ospitato nel contesto, se può essere sottoposto a marshalling per riferimento e se il tipo è un tipo di dati primitivo.
using namespace System;
using namespace System::Runtime::Remoting::Contexts;
public ref class ContextBoundClass: public ContextBoundObject
{
public:
String^ Value;
};
public ref class Example
{
public:
void Demo()
{
// Determine whether the types can be hosted in a Context.
Console::WriteLine("The IsContextful property for the {0} type is {1}.",
Example::typeid->Name, Example::typeid->IsContextful);
Console::WriteLine("The IsContextful property for the {0} type is {1}.",
ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsContextful);
// Determine whether the types are marshalled by reference.
Console::WriteLine("The IsMarshalByRef property of {0} is {1}.",
Example::typeid->Name, Example::typeid->IsMarshalByRef );
Console::WriteLine("The IsMarshalByRef property of {0} is {1}.",
ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsMarshalByRef );
// Determine whether the types are primitive datatypes.
Console::WriteLine("{0} is a primitive data type: {1}.",
int::typeid->Name, int::typeid->IsPrimitive );
Console::WriteLine("{0} is a primitive data type: {1}.",
String::typeid->Name, String::typeid->IsPrimitive );
}
};
int main()
{
Example^ ex = gcnew Example;
ex->Demo();
}
// The example displays the following output:
// The IsContextful property for the Example type is False.
// The IsContextful property for the ContextBoundClass type is True.
// The IsMarshalByRef property of Example is False.
// The IsMarshalByRef property of ContextBoundClass is True.
// Int32 is a primitive data type: True.
// String is a primitive data type: False.
using System;
using System.Runtime.Remoting.Contexts;
public class ContextBoundClass: ContextBoundObject
{
public string Value = "The Value property.";
}
public class Example
{
public static void Main()
{
// Determine whether the types can be hosted in a Context.
Console.WriteLine("The IsContextful property for the {0} type is {1}.",
typeof(Example).Name, typeof(Example).IsContextful);
Console.WriteLine("The IsContextful property for the {0} type is {1}.",
typeof(ContextBoundClass).Name, typeof(ContextBoundClass).IsContextful);
// Determine whether the types are marshalled by reference.
Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
typeof(Example).Name, typeof(Example).IsMarshalByRef);
Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
typeof(ContextBoundClass).Name, typeof(ContextBoundClass).IsMarshalByRef);
// Determine whether the types are primitive datatypes.
Console.WriteLine("{0} is a primitive data type: {1}.",
typeof(int).Name, typeof(int).IsPrimitive);
Console.WriteLine("{0} is a primitive data type: {1}.",
typeof(string).Name, typeof(string).IsPrimitive);
}
}
// The example displays the following output:
// The IsContextful property for the Example type is False.
// The IsContextful property for the ContextBoundClass type is True.
// The IsMarshalByRef property of Example is False.
// The IsMarshalByRef property of ContextBoundClass is True.
// Int32 is a primitive data type: True.
// String is a primitive data type: False.
Imports System.Runtime.Remoting.Contexts
Public Class ContextBoundClass : Inherits ContextBoundObject
Public Value As String = "The Value property."
End Class
Public Class Example
Public Shared Sub Main()
' Determine whether the types can be hosted in a Context.
Console.WriteLine("The IsContextful property for the {0} type is {1}.",
GetType(Example).Name, GetType(Example).IsContextful)
Console.WriteLine("The IsContextful property for the {0} type is {1}.",
GetType(ContextBoundClass).Name, GetType(ContextBoundClass).IsContextful)
' Determine whether the types are marshalled by reference.
Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
GetType(Example).Name, GetType(Example).IsMarshalByRef)
Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
GetType(ContextBoundClass).Name, GetType(ContextBoundClass).IsMarshalByRef)
' Determine whether the types are primitive datatypes.
Console.WriteLine("{0} is a primitive data type: {1}.",
GetType(Integer).Name, GetType(Integer).IsPrimitive)
Console.WriteLine("{0} is a primitive data type: {1}.",
GetType(String).Name, GetType(String).IsPrimitive)
End Sub
End Class
' The example displays the following output:
' The IsContextful property for the Example type is False.
' The IsContextful property for the ContextBoundClass type is True.
' The IsMarshalByRef property of Example is False.
' The IsMarshalByRef property of ContextBoundClass is True.
' Int32 is a primitive data type: True.
' String is a primitive data type: False.
Commenti
Un contesto intercetta le chiamate ai membri della classe e applica i criteri applicati alla classe, ad esempio la sincronizzazione. Per informazioni più dettagliate sui contesti remoti, vedere Context .
Se l'oggetto corrente rappresenta un parametro di tipo nella definizione di un tipo o di un metodo Type generico, questa proprietà restituisce sempre false
.