UrlAttribute Sınıf

Tanım

Etkinleştirmenin gerçekleşeceği URL'yi belirtmek için çağrı sitesinde kullanılabilecek bir öznitelik tanımlar. Bu sınıf devralınamaz.

public ref class UrlAttribute sealed : System::Runtime::Remoting::Contexts::ContextAttribute
[System.Serializable]
public sealed class UrlAttribute : System.Runtime.Remoting.Contexts.ContextAttribute
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class UrlAttribute : System.Runtime.Remoting.Contexts.ContextAttribute
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public sealed class UrlAttribute : System.Runtime.Remoting.Contexts.ContextAttribute
[<System.Serializable>]
type UrlAttribute = class
    inherit ContextAttribute
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type UrlAttribute = class
    inherit ContextAttribute
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type UrlAttribute = class
    inherit ContextAttribute
Public NotInheritable Class UrlAttribute
Inherits ContextAttribute
Devralma
Öznitelikler

Örnekler

Aşağıdaki kod örneği, istemci tarafından etkinleştirilen uzaktan iletişimin ayarlanmasında öğesinin UrlAttribute kullanımını göstermektedir. Örnek üç bölümden oluşur: istemci, sunucu ve istemci ile sunucu tarafından kullanılan uzak nesne.

Aşağıdaki kod örneği bir istemciyi gösterir:

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using "RemoteObject.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Activation;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

[STAThread]
int main()
{
   
   // Report initial status.
   Console::WriteLine( "Client starting." );
   
   // Register TCP channel.
   ChannelServices::RegisterChannel( gcnew TcpChannel );
   
   // Create UrlAttribute.
   UrlAttribute^ attribute = gcnew UrlAttribute( "tcp://localhost:1234/RemoteApp" );
   Console::WriteLine( "UrlAttribute value: {0}", attribute->UrlValue );
   
   array<Object^>^activationAttributes = {attribute};
   
   // Use UrlAttribute to register for client activated remote object.
   RemotingConfiguration::RegisterActivatedClientType( RemoteObject::typeid, "tcp://localhost:1234/RemoteApp" );
   
   // Activate remote object.
   Console::WriteLine( "Activating remote object." );
   RemoteObject ^ obj = dynamic_cast<RemoteObject^>(Activator::CreateInstance( RemoteObject::typeid, nullptr, activationAttributes ));
   
   // Invoke a method on it.
   Console::WriteLine( "Invoking Hello() on remote object." );
   obj->Hello();
   
   // Inform user of termination.
   Console::WriteLine( "Terminating client." );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class Client
{
    [STAThread]
    public static void Main()
    {
        // Report the initial status.
        Console.WriteLine("Starting client.");

        // Register the TCP channel.
        ChannelServices.RegisterChannel(new TcpChannel());

        // Create a url attribute object.
        UrlAttribute attribute =
            new UrlAttribute("tcp://localhost:1234/RemoteApp");
        Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue);
        object[] activationAttributes = new object[] { attribute };

        // Register the client for the remote object.
        RemotingConfiguration.RegisterActivatedClientType(
            typeof(RemoteObject),
            "tcp://localhost:1234/RemoteApp");

        // Activate the remote object.
        Console.WriteLine("Activating remote object.");
        RemoteObject obj = (RemoteObject) Activator.CreateInstance(
            typeof(RemoteObject), null, activationAttributes);

        // Invoke a method on the remote object.
        Console.WriteLine("Invoking Hello() on remote object.");
        obj.Hello();

        // Inform the user that the program is exiting.
        Console.WriteLine("The client is exiting.");
    }
}

Aşağıdaki kod örneği bu istemci için bir sunucu gösterir:

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using "RemoteObject.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

[STAThread]
int main()
{
   
   // Report status to user.
   Console::WriteLine( "Server starting." );
   
   // Register the TCP channel.
   ChannelServices::RegisterChannel( gcnew TcpChannel( 1234 ) );
   
   // Set application name.
   RemotingConfiguration::ApplicationName = "RemoteApp";
   
   // Register object for client activated remoting.
   RemotingConfiguration::RegisterActivatedServiceType( RemoteObject::typeid );
   
   // Wait until termination.
   Console::WriteLine( "Press enter to end." );
   Console::ReadLine();
   Console::WriteLine( "Terminating server." );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class Server
{
    [STAThread]
    public static void Main()
    {
        // Report the status to the user.
        Console.WriteLine("Starting server.");

        // Register the TCP channel.
        ChannelServices.RegisterChannel(new TcpChannel(1234));

        // Set the application name.
        RemotingConfiguration.ApplicationName = "RemoteApp";

        // Register the object for remoting.
        RemotingConfiguration.RegisterActivatedServiceType(
            typeof(RemoteObject));

        // Wait until the user presses ENTER.
        Console.WriteLine("Press ENTER to exit.");
        Console.ReadLine();
        Console.WriteLine("The server is exiting.");
    }
}

Aşağıdaki kod örneği, istemci ve sunucu tarafından kullanılan uzak nesneyi gösterir:

using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;

[assembly:AllowPartiallyTrustedCallersAttribute];
public ref class RemoteObject: public MarshalByRefObject
{
public:
   RemoteObject()
   {
      
      // Report object construction to server's console.
      Console::WriteLine( "You have called the constructor." );
   }

   void Hello()
   {
      
      // Report method invocation to server's console.
      Console::WriteLine( "You have called Hello()." );
   }

};
using System;
using System.Security;
using System.Security.Permissions;

public class RemoteObject : MarshalByRefObject
{
    public RemoteObject()
    {
        Console.WriteLine("You have called the constructor.");
    }

    public void Hello()
    {
        Console.WriteLine("You have called Hello().");
    }
}

Açıklamalar

UrlAttribute, yöntemiyle etkinleştirilmiş nesneler oluşturulurken parametresi Activator.CreateInstance olarak etkinleştirme öznitelikleri dizisinde CreateInstance geçirilir.

Öznitelikleri kullanma hakkında daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

UrlAttribute(String)

UrlAttribute sınıfının yeni bir örneğini oluşturur.

Alanlar

AttributeName

Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir.

Bağlam özniteliğinin adını gösterir.

(Devralındığı yer: ContextAttribute)

Özellikler

Name

Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir.

Bağlam özniteliğinin adını alır.

(Devralındığı yer: ContextAttribute)
TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)
UrlValue

URL değerini UrlAttributealır.

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli örnekle aynı URL'ye başvurup göndermediğini denetler.

Freeze(Context)

Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir.

Bağlam dondurulmuşsa çağırılır.

(Devralındığı yer: ContextAttribute)
GetHashCode()

Geçerli UrlAttributeiçin karma değerini döndürür.

GetPropertiesForNewContext(IConstructionCallMessage)

Bağlamın ve sunucu nesnesinin belirtilen URL'de bağlam içinde oluşturulmasını zorlar.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsContextOK(Context, IConstructionCallMessage)

Belirtilen Context öğesinin gereksinimlerini karşılayıp karşılamadığını UrlAttributegösteren bir Boole değeri döndürür.

IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
IsNewContextOK(Context)

Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir.

Bağlam özelliğinin yeni bağlamla uyumlu olup olmadığını gösteren bir Boole değeri döndürür.

(Devralındığı yer: ContextAttribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.