ChannelServices.SyncDispatchMessage メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ChannelServices.SyncDispatchMessage メソッドの意味・解説 

ChannelServices.SyncDispatchMessage メソッド

メッセージ埋め込まれURI基づいて受信メッセージサーバー側のチェイン (複数場合がある) に同期的ディスパッチます。

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

Public Shared Function SyncDispatchMessage
 ( _
    msg As IMessage _
) As IMessage
Dim msg As IMessage
Dim returnValue As IMessage

returnValue = ChannelServices.SyncDispatchMessage(msg)
public static IMessage SyncDispatchMessage
 (
    IMessage msg
)
public:
static IMessage^ SyncDispatchMessage (
    IMessage^ msg
)
public static IMessage SyncDispatchMessage
 (
    IMessage msg
)
public static function SyncDispatchMessage
 (
    msg : IMessage
) : IMessage

パラメータ

msg

ディスパッチするメッセージ

戻り値
サーバー側のチェインへの呼び出しによって、返信メッセージ返されます。

例外例外
例外種類条件

ArgumentNullException

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

SecurityException

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

使用例使用例
' Create a custom 'RealProxy'.
Public Class MyProxy
   Inherits RealProxy
   Private myURIString As String
   Private myMarshalByRefObject As MarshalByRefObject

   <PermissionSet(SecurityAction.LinkDemand)> _
   Public Sub New(ByVal
 myType As Type)
      MyBase.New(myType)
      ' RealProxy uses the Type to generate a transparent proxy.
      myMarshalByRefObject = CType(Activator.CreateInstance(myType), MarshalByRefObject)
      ' Get 'ObjRef', for transmission serialization between application
 domains.
      Dim myObjRef As ObjRef = RemotingServices.Marshal(myMarshalByRefObject)
      ' Get the 'URI' property of 'ObjRef' and store it.
      myURIString = myObjRef.URI
      Console.WriteLine("URI :{0}", myObjRef.URI)
   End Sub 'New

<SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags:=SecurityPermissionFlag.Infrastructure)>
 _
   Public Overrides Function
 Invoke(ByVal myIMessage As IMessage) As
 IMessage
      Console.WriteLine("MyProxy.Invoke Start")
      Console.WriteLine("")

      If TypeOf myIMessage Is
 IMethodCallMessage Then
         Console.WriteLine("IMethodCallMessage")
      End If
      If TypeOf myIMessage Is
 IMethodReturnMessage Then
         Console.WriteLine("IMethodReturnMessage")
      End If
      Dim msgType As Type
      msgType = CObj(myIMessage).GetType
      Console.WriteLine("Message Type: {0}", msgType.ToString())
      Console.WriteLine("Message Properties")
      Dim myIDictionary As IDictionary = myIMessage.Properties
      ' Set the '__Uri' property of 'IMessage' to 'URI' property of
 'ObjRef'.
      myIDictionary("__Uri") = myURIString
      Dim myIDictionaryEnumerator As IDictionaryEnumerator
 = CType(myIDictionary.GetEnumerator(), _
                                                                    IDictionaryEnumerator)

      While myIDictionaryEnumerator.MoveNext()
         Dim myKey As Object
 = myIDictionaryEnumerator.Key
         Dim myKeyName As String
 = myKey.ToString()
         Dim myValue As Object
 = myIDictionaryEnumerator.Value

         Console.WriteLine(ControlChars.Tab + "{0} : {1}",
 myKeyName, myIDictionaryEnumerator.Value)
         If myKeyName = "__Args"
 Then
            Dim myObjectArray As Object()
 = CType(myValue, Object())
            Dim aIndex As Integer
            For aIndex = 0 To myObjectArray.Length
 - 1
               Console.WriteLine(ControlChars.Tab + ControlChars.Tab + "arg:
 {0} myValue: {1}", _
                                                              aIndex, myObjectArray(aIndex))
             Next aIndex
         End If

         If myKeyName = "__MethodSignature"
 And Not Nothing Is
 myValue Then
            Dim myObjectArray As Object()
 = CType(myValue, Object())
            Dim aIndex As Integer
            For aIndex = 0 To myObjectArray.Length
 - 1
               Console.WriteLine(ControlChars.Tab + ControlChars.Tab + "arg:
 {0} myValue: {1}", _
                                                           aIndex, myObjectArray(aIndex))
            Next aIndex
         End If
      End While

        Dim myReturnMessage As IMessage

        myIDictionary("__Uri") = myURIString
        Console.WriteLine("__Uri {0}", myIDictionary("__Uri"))

        Console.WriteLine("ChannelServices.SyncDispatchMessage")
        myReturnMessage = ChannelServices.SyncDispatchMessage(CObj(myIMessage))

        ' Push return value and OUT parameters back onto stack.
        Dim myMethodReturnMessage As IMethodReturnMessage
 = CType(myReturnMessage, IMethodReturnMessage)
        Console.WriteLine("IMethodReturnMessage.ReturnValue: {0}",
 myMethodReturnMessage.ReturnValue)

        Console.WriteLine("MyProxy.Invoke - Finish")

        Return myReturnMessage
    End Function 'Invoke
End Class 'MyProxy
// Create a custom 'RealProxy'.
public class MyProxy : RealProxy
{
   String myURIString;
   MarshalByRefObject myMarshalByRefObject;   

   [PermissionSet(SecurityAction.LinkDemand)]
   public MyProxy(Type myType) : base(myType)
   {
      // RealProxy uses the Type to generate a transparent proxy.
      myMarshalByRefObject = (MarshalByRefObject)Activator.CreateInstance((myType));
      // Get 'ObjRef', for transmission serialization between application
 domains.
      ObjRef myObjRef = RemotingServices.Marshal(myMarshalByRefObject);
      // Get the 'URI' property of 'ObjRef' and store it.
      myURIString = myObjRef.URI;
      Console.WriteLine("URI :{0}", myObjRef.URI);
   }

   [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)]
   public override IMessage Invoke(IMessage myIMessage)
   {
      Console.WriteLine("MyProxy.Invoke Start");
      Console.WriteLine("");

      if (myIMessage is IMethodCallMessage)
         Console.WriteLine("IMethodCallMessage");

      if (myIMessage is IMethodReturnMessage)
         Console.WriteLine("IMethodReturnMessage");

      Type msgType = myIMessage.GetType();
      Console.WriteLine("Message Type: {0}", msgType.ToString());
      Console.WriteLine("Message Properties");
      IDictionary myIDictionary = myIMessage.Properties;
      // Set the '__Uri' property of 'IMessage' to 'URI' property of
 'ObjRef'.
      myIDictionary["__Uri"] = myURIString;
      IDictionaryEnumerator myIDictionaryEnumerator = 
         (IDictionaryEnumerator) myIDictionary.GetEnumerator();

      while (myIDictionaryEnumerator.MoveNext())
      {
         Object myKey = myIDictionaryEnumerator.Key;
         String myKeyName = myKey.ToString();
         Object myValue = myIDictionaryEnumerator.Value;

         Console.WriteLine("\t{0} : {1}", myKeyName, 
            myIDictionaryEnumerator.Value);
         if (myKeyName == "__Args")
         {
            Object[] myObjectArray = (Object[])myValue;
            for (int aIndex = 0; aIndex <
 myObjectArray.Length; aIndex++)
               Console.WriteLine("\t\targ: {0} myValue: {1}", aIndex, 
                  myObjectArray[aIndex]);
         }

         if ((myKeyName == "__MethodSignature") &&
 (null != myValue))
         {
            Object[] myObjectArray = (Object[])myValue;
            for (int aIndex = 0; aIndex <
 myObjectArray.Length; aIndex++)
               Console.WriteLine("\t\targ: {0} myValue: {1}", aIndex, 
                  myObjectArray[aIndex]);
         }
      }
      
      IMessage myReturnMessage;

      myIDictionary["__Uri"] = myURIString;
      Console.WriteLine("__Uri {0}", myIDictionary["__Uri"]);

      Console.WriteLine("ChannelServices.SyncDispatchMessage");
      myReturnMessage = ChannelServices.SyncDispatchMessage(myIMessage);

      // Push return value and OUT parameters back onto stack.

      IMethodReturnMessage myMethodReturnMessage = (IMethodReturnMessage)
         myReturnMessage;
      Console.WriteLine("IMethodReturnMessage.ReturnValue: {0}", 
         myMethodReturnMessage.ReturnValue);

      Console.WriteLine("MyProxy.Invoke - Finish");

      return myReturnMessage;
   }
}
// Create a custom 'RealProxy'.
/** @attribute SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)
 */
public class MyProxy extends RealProxy
{
    private String myURIString;
    private MarshalByRefObject myMarshalByRefObject;

    public MyProxy(Type myType)
    {
        super(myType);

        // RealProxy uses the Type to generate a transparent proxy.
        myMarshalByRefObject = 
            (MarshalByRefObject)(Activator.CreateInstance(myType));

        // Get 'ObjRef', for transmission serialization between 
        // application domains.
        ObjRef myObjRef = RemotingServices.Marshal(myMarshalByRefObject);

        // Get the 'URI' property of 'ObjRef' and store it.
        myURIString = myObjRef.get_URI();
        Console.WriteLine("URI :{0}", myObjRef.get_URI());
    } //MyProxy

    public IMessage Invoke(IMessage myIMessage)
    {
        Console.WriteLine("MyProxy.Invoke Start");
        Console.WriteLine("");
        if (myIMessage instanceof IMethodCallMessage) {
            Console.WriteLine("IMethodCallMessage");
        }

        if (myIMessage instanceof IMethodReturnMessage) {
            Console.WriteLine("IMethodReturnMessage");
        }

        Type msgType = myIMessage.GetType();

        Console.WriteLine("Message Type: {0}", msgType.ToString());
        Console.WriteLine("Message Properties");

        IDictionary myIDictionary = myIMessage.get_Properties();

        // Set the '__Uri' property of 'IMessage' to 'URI' property of
 'ObjRef'.
        myIDictionary.set_Item("__Uri", myURIString);

        IDictionaryEnumerator myIDictionaryEnumerator = 
            (IDictionaryEnumerator)(myIDictionary.GetEnumerator());
        while (myIDictionaryEnumerator.MoveNext()) {
            Object myKey = myIDictionaryEnumerator.get_Key();
            String myKeyName = myKey.ToString();
            Object myValue = myIDictionaryEnumerator.get_Value();
            Console.WriteLine("\t{0} : {1}", myKeyName, 
                myIDictionaryEnumerator.get_Value());

            if (myKeyName.Equals("__Args")) {
                Object myObjectArray[] = (Object[])myValue;
                for (int aIndex = 0; aIndex
 < myObjectArray.length; aIndex++) {
                    Console.WriteLine("\t\targ: {0} myValue: {1}", 
                        (Int32)aIndex, myObjectArray.get_Item(aIndex));
                }
            }

            if (myKeyName.Equals("__MethodSignature")
 && null != myValue) {
                Object myObjectArray[] = (Object[])myValue;
                for (int aIndex = 0; aIndex
 < myObjectArray.length; aIndex++) {
                    Console.WriteLine("\t\targ: {0} myValue: {1}", 
                        (Int32)aIndex, myObjectArray.get_Item(aIndex));
                }
            }
        }

        IMessage myReturnMessage;
        myIDictionary.set_Item("__Uri", myURIString);
        Console.WriteLine("__Uri {0}", myIDictionary.get_Item("__Uri"));
        Console.WriteLine("ChannelServices.SyncDispatchMessage");
        myReturnMessage = ChannelServices.SyncDispatchMessage(myIMessage);

        // Push return value and OUT parameters back onto stack.
        IMethodReturnMessage myMethodReturnMessage = 
            (IMethodReturnMessage)myReturnMessage;
        Console.WriteLine("IMethodReturnMessage.ReturnValue: {0}", 
            myMethodReturnMessage.get_ReturnValue());
        Console.WriteLine("MyProxy.Invoke - Finish");
        return myReturnMessage;
    } //Invoke
} //MyProxy
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ChannelServices クラス
ChannelServices メンバ
System.Runtime.Remoting.Channels 名前空間



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

辞書ショートカット

すべての辞書の索引

「ChannelServices.SyncDispatchMessage メソッド」の関連用語

ChannelServices.SyncDispatchMessage メソッドのお隣キーワード
検索ランキング

   

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



ChannelServices.SyncDispatchMessage メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS