UrlAttributeとは? わかりやすく解説

UrlAttribute クラス

アクティブ化が発生するところで URL指定するために、呼び出し側で使用できる属性定義します。このクラス継承できません。

名前空間: System.Runtime.Remoting.Activation
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 UrlAttribute
    Inherits ContextAttribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class UrlAttribute : ContextAttribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class UrlAttribute sealed : public
 ContextAttribute
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class UrlAttribute extends ContextAttribute
SerializableAttribute 
ComVisibleAttribute(true) 
public final class UrlAttribute extends
 ContextAttribute
解説解説
使用例使用例

UrlAttribute使用してクライアント側アクティブ化されるリモート処理設定するコード例次に示します。この例には、クライアントサーバー、およびクライアントサーバーから使用されるリモート オブジェクト3 つの部分含まれます。

クライアントコード例次に示します

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Permissions;

public class Client
{
[SecurityPermission(SecurityAction.Demand)]
    [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.");
    }
}
#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.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.");
    }
}
#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.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().");
    }
}
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()." );
   }

};

継承階層継承階層
System.Object
   System.Attribute
     System.Runtime.Remoting.Contexts.ContextAttribute
      System.Runtime.Remoting.Activation.UrlAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UrlAttribute メンバ
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute コンストラクタ

UrlAttribute クラス新しインスタンス作成します

名前空間: System.Runtime.Remoting.Activation
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    callsiteURL As String _
)
Dim callsiteURL As String

Dim instance As New UrlAttribute(callsiteURL)
public UrlAttribute (
    string callsiteURL
)
public:
UrlAttribute (
    String^ callsiteURL
)
public UrlAttribute (
    String callsiteURL
)
public function UrlAttribute (
    callsiteURL : String
)

パラメータ

callsiteURL

呼び出し側の URL

例外例外
例外種類条件

ArgumentNullException

callsiteURL パラメータnull 参照 (Visual Basic では Nothing) です。

SecurityException

直前呼び出し元にインフラストラクチャ アクセス許可がありません。

使用例使用例

UrlAttribute コンストラクタ使用方法次のコード例示します

// Create a url attribute object.
UrlAttribute attribute = 
    new UrlAttribute("tcp://localhost:1234/RemoteApp");
Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue);
// Create UrlAttribute.
UrlAttribute^ attribute = gcnew UrlAttribute( "tcp://localhost:1234/RemoteApp"
 );
Console::WriteLine( "UrlAttribute value: {0}", attribute->UrlValue );

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UrlAttribute クラス
UrlAttribute メンバ
System.Runtime.Remoting.Activation 名前空間

UrlAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Name  コンテキスト属性の名前を取得します。 ( ContextAttribute から継承されます。)
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
パブリック プロパティ UrlValue UrlAttribute の URL 値を取得します
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます。  
パブリック メソッド Freeze  コンテキスト固定されるときに呼び出されます。 ( ContextAttribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます現在の UrlAttribute のハッシュ値返します
パブリック メソッド GetPropertiesForNewContext オーバーライドされます指定した URL で、コンテキストと、そのコンテキスト内のサーバー オブジェクトの作成強制します。
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsContextOK オーバーライドされます指定した ContextUrlAttribute要件満たしているかどうかを示すブール値を返します
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド IsNewContextOK  コンテキスト プロパティ新しコンテキストとの間に互換性があるかどうかを示す Boolean 値を返します。 ( ContextAttribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute メンバ

アクティブ化が発生するところで URL指定するために、呼び出し側で使用できる属性定義します。このクラス継承できません。

UrlAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド UrlAttribute UrlAttribute クラス新しインスタンス作成します
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Name  コンテキスト属性の名前を取得します。(ContextAttribute から継承されます。)
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。(Attribute から継承されます。)
パブリック プロパティ UrlValue UrlAttributeURL 値を取得します
パブリック メソッドパブリック メソッド
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます。  
パブリック メソッド Freeze  コンテキスト固定されるときに呼び出されます。 (ContextAttribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます現在の UrlAttributeハッシュ値返します
パブリック メソッド GetPropertiesForNewContext オーバーライドされます指定した URL で、コンテキストと、そのコンテキスト内のサーバー オブジェクトの作成強制します。
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsContextOK オーバーライドされます指定した ContextUrlAttribute要件満たしているかどうかを示すブール値を返します
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラス既定値かどうか示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド IsNewContextOK  コンテキスト プロパティ新しコンテキストとの間に互換性があるかどうかを示す Boolean 値を返します。 (ContextAttribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「UrlAttribute」の関連用語

UrlAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



UrlAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS