Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / ManagedLibraries / Remoting / Channels / IPC / IpcChannel.cs / 1305376 / IpcChannel.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//============================================================================
// File: IpcChannel.cs
// Author: [....]@Microsoft.Com
// Summary: Implements a combined ipc channel
//
//=========================================================================
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Globalization;
using System.Security.AccessControl;
using System.Security.Permissions;
namespace System.Runtime.Remoting.Channels.Ipc
{
public class IpcChannel : IChannelReceiver, IChannelSender, ISecurableChannel
{
private IpcClientChannel _clientChannel = null; // client channel
private IpcServerChannel _serverChannel = null; // server channel
private int _channelPriority = 20; // channel priority
private String _channelName = "ipc"; // channel name
public IpcChannel()
{
_clientChannel = new IpcClientChannel();
// server channel will not be activated.
} // IpcChannel
public IpcChannel(String portName) : this()
{
_serverChannel = new IpcServerChannel(portName);
} // IpcChannel
public IpcChannel(IDictionary properties,
IClientChannelSinkProvider clientSinkProvider,
IServerChannelSinkProvider serverSinkProvider)
: this(properties, clientSinkProvider, serverSinkProvider, null)
{
}
public IpcChannel(IDictionary properties,
IClientChannelSinkProvider clientSinkProvider,
IServerChannelSinkProvider serverSinkProvider,
CommonSecurityDescriptor securityDescriptor)
{
Hashtable clientData = new Hashtable();
Hashtable serverData = new Hashtable();
bool portFound = false;
// divide properties up for respective channels
if (properties != null)
{
foreach (DictionaryEntry entry in properties)
{
switch ((String)entry.Key)
{
// general channel properties
case "name": _channelName = (String)entry.Value; break;
case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;
case "portName":
{
serverData["portName"] = entry.Value;
portFound = true;
break;
}
default:
clientData[entry.Key] = entry.Value;
serverData[entry.Key] = entry.Value;
break;
}
}
}
_clientChannel = new IpcClientChannel(clientData, clientSinkProvider);
if (portFound)
_serverChannel = new IpcServerChannel(serverData, serverSinkProvider, securityDescriptor);
} // IpcChannel
//
// ISecurableChannel implementation
//
public bool IsSecured
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get {
if (_clientChannel != null)
return _clientChannel.IsSecured;
if (_serverChannel != null)
return _serverChannel.IsSecured;
return false;
}
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
set {
if (((IList)ChannelServices.RegisteredChannels).Contains(this))
throw new InvalidOperationException(CoreChannel.GetResourceString("Remoting_InvalidOperation_IsSecuredCannotBeChangedOnRegisteredChannels"));
if (_clientChannel != null)
_clientChannel.IsSecured = value;
if (_serverChannel != null)
_serverChannel.IsSecured = value;
}
}
//
// IChannel implementation
//
public int ChannelPriority
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get { return _channelPriority; }
} // ChannelPriority
public String ChannelName
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get { return _channelName; }
} // ChannelName
// returns channelURI and places object uri into out parameter
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public String Parse(String url, out String objectURI)
{
return IpcChannelHelper.ParseURL(url, out objectURI);
} // Parse
//
// end of IChannel implementation
//
//
// IChannelSender implementation
//
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public IMessageSink CreateMessageSink(String url, Object remoteChannelData,
out String objectURI)
{
return _clientChannel.CreateMessageSink(url, remoteChannelData, out objectURI);
} // CreateMessageSink
//
// end of IChannelSender implementation
//
//
// IChannelReceiver implementation
//
public Object ChannelData
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get
{
if (_serverChannel != null)
return _serverChannel.ChannelData;
else
return null;
}
} // ChannelData
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public String[] GetUrlsForUri(String objectURI)
{
if (_serverChannel != null)
return _serverChannel.GetUrlsForUri(objectURI);
else
return null;
} // GetUrlsforURI
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public void StartListening(Object data)
{
if (_serverChannel != null)
_serverChannel.StartListening(data);
} // StartListening
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public void StopListening(Object data)
{
if (_serverChannel != null)
_serverChannel.StopListening(data);
} // StopListening
//
// IChannelReceiver implementation
//
} // class IpcChannel
} // namespace System.Runtime.Remoting.Channels.Ipc
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//============================================================================
// File: IpcChannel.cs
// Author: [....]@Microsoft.Com
// Summary: Implements a combined ipc channel
//
//=========================================================================
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Globalization;
using System.Security.AccessControl;
using System.Security.Permissions;
namespace System.Runtime.Remoting.Channels.Ipc
{
public class IpcChannel : IChannelReceiver, IChannelSender, ISecurableChannel
{
private IpcClientChannel _clientChannel = null; // client channel
private IpcServerChannel _serverChannel = null; // server channel
private int _channelPriority = 20; // channel priority
private String _channelName = "ipc"; // channel name
public IpcChannel()
{
_clientChannel = new IpcClientChannel();
// server channel will not be activated.
} // IpcChannel
public IpcChannel(String portName) : this()
{
_serverChannel = new IpcServerChannel(portName);
} // IpcChannel
public IpcChannel(IDictionary properties,
IClientChannelSinkProvider clientSinkProvider,
IServerChannelSinkProvider serverSinkProvider)
: this(properties, clientSinkProvider, serverSinkProvider, null)
{
}
public IpcChannel(IDictionary properties,
IClientChannelSinkProvider clientSinkProvider,
IServerChannelSinkProvider serverSinkProvider,
CommonSecurityDescriptor securityDescriptor)
{
Hashtable clientData = new Hashtable();
Hashtable serverData = new Hashtable();
bool portFound = false;
// divide properties up for respective channels
if (properties != null)
{
foreach (DictionaryEntry entry in properties)
{
switch ((String)entry.Key)
{
// general channel properties
case "name": _channelName = (String)entry.Value; break;
case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;
case "portName":
{
serverData["portName"] = entry.Value;
portFound = true;
break;
}
default:
clientData[entry.Key] = entry.Value;
serverData[entry.Key] = entry.Value;
break;
}
}
}
_clientChannel = new IpcClientChannel(clientData, clientSinkProvider);
if (portFound)
_serverChannel = new IpcServerChannel(serverData, serverSinkProvider, securityDescriptor);
} // IpcChannel
//
// ISecurableChannel implementation
//
public bool IsSecured
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get {
if (_clientChannel != null)
return _clientChannel.IsSecured;
if (_serverChannel != null)
return _serverChannel.IsSecured;
return false;
}
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
set {
if (((IList)ChannelServices.RegisteredChannels).Contains(this))
throw new InvalidOperationException(CoreChannel.GetResourceString("Remoting_InvalidOperation_IsSecuredCannotBeChangedOnRegisteredChannels"));
if (_clientChannel != null)
_clientChannel.IsSecured = value;
if (_serverChannel != null)
_serverChannel.IsSecured = value;
}
}
//
// IChannel implementation
//
public int ChannelPriority
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get { return _channelPriority; }
} // ChannelPriority
public String ChannelName
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get { return _channelName; }
} // ChannelName
// returns channelURI and places object uri into out parameter
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public String Parse(String url, out String objectURI)
{
return IpcChannelHelper.ParseURL(url, out objectURI);
} // Parse
//
// end of IChannel implementation
//
//
// IChannelSender implementation
//
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public IMessageSink CreateMessageSink(String url, Object remoteChannelData,
out String objectURI)
{
return _clientChannel.CreateMessageSink(url, remoteChannelData, out objectURI);
} // CreateMessageSink
//
// end of IChannelSender implementation
//
//
// IChannelReceiver implementation
//
public Object ChannelData
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
get
{
if (_serverChannel != null)
return _serverChannel.ChannelData;
else
return null;
}
} // ChannelData
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public String[] GetUrlsForUri(String objectURI)
{
if (_serverChannel != null)
return _serverChannel.GetUrlsForUri(objectURI);
else
return null;
} // GetUrlsforURI
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public void StartListening(Object data)
{
if (_serverChannel != null)
_serverChannel.StartListening(data);
} // StartListening
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure, Infrastructure=true)]
public void StopListening(Object data)
{
if (_serverChannel != null)
_serverChannel.StopListening(data);
} // StopListening
//
// IChannelReceiver implementation
//
} // class IpcChannel
} // namespace System.Runtime.Remoting.Channels.Ipc
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntitySqlException.cs
- TemplateAction.cs
- WebPartConnectionsCancelVerb.cs
- DataReceivedEventArgs.cs
- NetSectionGroup.cs
- ContractBase.cs
- GridViewSelectEventArgs.cs
- UmAlQuraCalendar.cs
- InvalidOleVariantTypeException.cs
- StylusPointPropertyInfoDefaults.cs
- ParameterElement.cs
- PropagatorResult.cs
- ComAwareEventInfo.cs
- DbBuffer.cs
- XLinq.cs
- Point.cs
- XmlCharCheckingWriter.cs
- NativeMethods.cs
- DocumentViewerAutomationPeer.cs
- TreeNodeEventArgs.cs
- SafeNativeMethods.cs
- CustomErrorsSection.cs
- CompositionTarget.cs
- PackagingUtilities.cs
- GridViewPageEventArgs.cs
- ChannelToken.cs
- RecommendedAsConfigurableAttribute.cs
- OperationResponse.cs
- PassportIdentity.cs
- ZipIOLocalFileBlock.cs
- SchemaElement.cs
- PagesChangedEventArgs.cs
- SafeRegistryKey.cs
- TypeCollectionPropertyEditor.cs
- StorageEntitySetMapping.cs
- IntSumAggregationOperator.cs
- SQLByteStorage.cs
- SystemInfo.cs
- RenderDataDrawingContext.cs
- AdapterUtil.cs
- ToolStripPanelSelectionGlyph.cs
- ViewSimplifier.cs
- LineBreak.cs
- OneOf.cs
- EntityDataSourceReferenceGroup.cs
- LookupBindingPropertiesAttribute.cs
- MenuItemStyleCollection.cs
- QilExpression.cs
- GlyphCache.cs
- MultilineStringConverter.cs
- LoginUtil.cs
- ExceptionWrapper.cs
- InheritablePropertyChangeInfo.cs
- ColorMatrix.cs
- RSAProtectedConfigurationProvider.cs
- UpdatePanelTrigger.cs
- TrueReadOnlyCollection.cs
- SQLInt16.cs
- HtmlShim.cs
- TextInfo.cs
- FixedSOMImage.cs
- Int32CollectionConverter.cs
- ToolboxComponentsCreatingEventArgs.cs
- Visitor.cs
- TypeUtils.cs
- OuterGlowBitmapEffect.cs
- TaskDesigner.cs
- Token.cs
- DemultiplexingClientMessageFormatter.cs
- CompositeActivityDesigner.cs
- TemplatePartAttribute.cs
- XsltException.cs
- XmlTextReaderImplHelpers.cs
- ObjectSerializerFactory.cs
- NativeMethods.cs
- EventWaitHandleSecurity.cs
- _BufferOffsetSize.cs
- HtmlInputRadioButton.cs
- ObjectItemLoadingSessionData.cs
- XmlDictionaryReader.cs
- ActivityExecutor.cs
- ForwardPositionQuery.cs
- DataSpaceManager.cs
- ClaimSet.cs
- Propagator.cs
- HttpListenerException.cs
- MutableAssemblyCacheEntry.cs
- embossbitmapeffect.cs
- ObjectViewEntityCollectionData.cs
- StaticFileHandler.cs
- WebInvokeAttribute.cs
- DataGridViewTopRowAccessibleObject.cs
- ExceptionValidationRule.cs
- DoubleIndependentAnimationStorage.cs
- DialogWindow.cs
- RSACryptoServiceProvider.cs
- BufferAllocator.cs
- IsolatedStorageFile.cs
- Bold.cs
- GridViewUpdateEventArgs.cs