IChannelDataStore 인터페이스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
원격 채널에 대한 채널 데이터를 저장합니다.
public interface class IChannelDataStore
public interface IChannelDataStore
[System.Runtime.InteropServices.ComVisible(true)]
public interface IChannelDataStore
type IChannelDataStore = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type IChannelDataStore = interface
Public Interface IChannelDataStore
- 파생
- 특성
예제
#using <System.Runtime.Remoting.dll>
#using <System.dll>
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
using namespace System::Runtime::Remoting::Services;
// Marshal ByRef Object class.
public ref class MyServiceClass: public MarshalByRefObject
{
public:
String^ HelloWorld()
{
return "Hello World";
}
};
int main()
{
TcpChannel^ myChannel = gcnew TcpChannel( 8085 );
ChannelServices::RegisterChannel( myChannel );
MyServiceClass^ myService = gcnew MyServiceClass;
// After the channel is registered, register the object
// with remoting infrastructure by calling Marshal method.
ObjRef^ myObjRef = RemotingServices::Marshal( myService, "TcpService" );
// Get the information contributed by active channel.
IChannelInfo^ myChannelInfo = myObjRef->ChannelInfo;
IChannelDataStore^ myIChannelData;
System::Collections::IEnumerator^ myEnum = myChannelInfo->ChannelData->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ myChannelData = safe_cast<Object^>(myEnum->Current);
if ( dynamic_cast<IChannelDataStore^>(myChannelData) )
{
myIChannelData = dynamic_cast<IChannelDataStore^>(myChannelData);
System::Collections::IEnumerator^ myEnum1 = myIChannelData->ChannelUris->GetEnumerator();
while ( myEnum1->MoveNext() )
{
String^ myUri = safe_cast<String^>(myEnum1->Current);
Console::WriteLine( "Channel Uris are -> {0}", myUri );
}
String^ myKey = "Key1";
myIChannelData[ myKey ] = "My Data";
Console::WriteLine( myIChannelData[ myKey ] );
}
}
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Services;
using System.Security.Permissions;
public class ServerProcess
{
public static void Main()
{
TcpChannel myChannel = new TcpChannel(8085);
ChannelServices.RegisterChannel(myChannel);
MyServiceClass myService = new MyServiceClass();
// After the channel is registered, register the object
// with remoting infrastructure by calling Marshal method.
ObjRef myObjRef = RemotingServices.Marshal(myService,"TcpService");
// Get the information contributed by active channel.
IChannelInfo myChannelInfo = myObjRef.ChannelInfo;
IChannelDataStore myIChannelData;
foreach(object myChannelData in myChannelInfo.ChannelData)
{
if(myChannelData is IChannelDataStore)
{
myIChannelData = (IChannelDataStore)myChannelData;
foreach(string myUri in myIChannelData.ChannelUris)
Console.WriteLine("Channel Uris are -> " + myUri);
// Add custom data.
string myKey = "Key1";
myIChannelData[myKey] = "My Data";
Console.WriteLine(myIChannelData[myKey].ToString());
}
}
}
}
// Marshal ByRef Object class.
public class MyServiceClass : MarshalByRefObject
{
public string HelloWorld()
{
return "Hello World";
}
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Services
Imports System.Security.Permissions
Public Class ServerProcess
<PermissionSet(SecurityAction.LinkDemand)> _
Public Shared Sub Main()
Dim myChannel As New TcpChannel(8085)
ChannelServices.RegisterChannel(myChannel)
Dim myService As New MyServiceClass()
' After the channel is registered, register the object
' with remoting infrastructure by calling Marshal method.
Dim myObjRef As ObjRef = RemotingServices.Marshal(myService, "TcpService")
' Get the information contributed by active channel.
Dim myChannelInfo As IChannelInfo = myObjRef.ChannelInfo
Dim myIChannelData As IChannelDataStore
Dim myChannelData As Object
For Each myChannelData In myChannelInfo.ChannelData
If TypeOf myChannelData Is IChannelDataStore Then
myIChannelData = CType(myChannelData, IChannelDataStore)
Dim myUri As String
For Each myUri In myIChannelData.ChannelUris
Console.WriteLine("Channel Uris are -> " + myUri)
Next myUri ' Add custom data.
Dim myKey As String = "Key1"
myIChannelData(myKey) = "My Data"
Console.WriteLine(myIChannelData(myKey).ToString())
End If
Next myChannelData
End Sub
End Class
' Marshal ByRef Object class.
Public Class MyServiceClass
Inherits MarshalByRefObject
Public Function HelloWorld() As String
Return "Hello World"
End Function 'HelloWorld
End Class
설명
채널 싱크 아키텍처를 사용 하려는 채널에서이 인터페이스를 구현 해야 해당 ChannelData
개체입니다.
속성
ChannelUris |
현재 채널이 매핑된 채널 URI로 이루어진 배열을 가져옵니다. |
Item[Object] |
구현 채널에 대한 지정된 키와 관련된 데이터 개체를 가져오거나 설정합니다. |
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET