Type.IsContextful Özellik

Tanım

bir bağlamda barındırıp Type barındırılanamayrı belirten bir değer alır.

C#
public bool IsContextful { get; }

Özellik Değeri

Boolean

true bir Type bağlamda barındırılamayacaksa; barındırılamayacaksa, false .

Uygulamalar

Örnekler

Aşağıdaki örnek, IsContextful sınıfının IsMarshalByRef , ve özelliklerini IsPrimitive Type gösterir. Verilen türün bağlamda barındırıp barındırılanamay, başvuruya göre sıralanıp sıralanamayıp sıralanamayıp olmadığını ve türün ilkel bir veri türü olup olmadığını denetler.

C#
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.

Açıklamalar

Bağlam, sınıf üyelerine çağrılar arayalar ve eşitleme gibi sınıfa uygulanan ilkeleri zorlar. İletişim bağlamları hakkında daha ayrıntılı bilgi için bkz. Context .

Geçerli, genel Type bir türün veya genel yöntemin tanımında bir tür parametresini temsil ediyorsa, bu özellik her zaman false döndürür.

Şunlara uygulanır

Ürün Sürümler
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1

Ayrıca bkz.