We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Runtime.Remoting.Channels
- {
- using System.Collections;
- using System.IO;
- using System.Runtime.Remoting;
- using System.Runtime.Remoting.Messaging;
- using System.Runtime.Remoting.Metadata;
- using System.Security.Permissions;
- using System;
- using System.Globalization;
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannel
- {
- int ChannelPriority {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
- string ChannelName {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- string Parse(string url, out string objectURI);
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannelSender : IChannel
- {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- IMessageSink CreateMessageSink(string url, object remoteChannelData, out string objectURI);
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannelReceiver : IChannel
- {
- object ChannelData {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- string[] GetUrlsForUri(string objectURI);
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void StartListening(object data);
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void StopListening(object data);
- }
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannelReceiverHook
- {
- string ChannelScheme {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- bool WantsToListen {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- IServerChannelSink ChannelSinkChain {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void AddHookChannelUri(string channelUri);
-
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IClientChannelSinkProvider
- {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- IClientChannelSink CreateSink(IChannelSender channel, string url, object remoteChannelData);
-
- IClientChannelSinkProvider Next {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- set;
- }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IServerChannelSinkProvider
- {
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void GetChannelData(IChannelDataStore channelData);
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- IServerChannelSink CreateSink(IChannelReceiver channel);
-
- IServerChannelSinkProvider Next {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- set;
- }
- }
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IClientFormatterSinkProvider : IClientChannelSinkProvider
- {
- }
-
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IServerFormatterSinkProvider : IServerChannelSinkProvider
- {
- }
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IClientChannelSink : IChannelSinkBase
- {
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream);
-
-
-
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream);
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream);
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- Stream GetRequestStream(IMessage msg, ITransportHeaders headers);
-
-
-
- IClientChannelSink NextChannelSink {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- }
-
-
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum ServerProcessing
- {
- Complete,
-
- OneWay,
-
- Async
-
-
- }
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IServerChannelSink : IChannelSinkBase
- {
-
-
-
-
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream);
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers, Stream stream);
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers);
-
-
-
- IServerChannelSink NextChannelSink {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- }
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannelSinkBase
- {
-
-
-
- IDictionary Properties {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
- }
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IClientFormatterSink : IMessageSink, IClientChannelSink
- {
- }
-
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IChannelDataStore
- {
- string[] ChannelUris {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- }
-
- object this[object key]
- {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- set;
- }
- }
-
-
-
- [Serializable(), SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure), SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ChannelDataStore : IChannelDataStore
- {
- string[] _channelURIs;
-
- DictionaryEntry[] _extraData;
-
-
- private ChannelDataStore(string[] channelUrls, DictionaryEntry[] extraData)
- {
- _channelURIs = channelUrls;
- _extraData = extraData;
- }
-
- public ChannelDataStore(string[] channelURIs)
- {
- _channelURIs = channelURIs;
- _extraData = null;
- }
-
- internal ChannelDataStore InternalShallowCopy()
- {
- return new ChannelDataStore(_channelURIs, _extraData);
- }
-
-
- public string[] ChannelUris {
- get { return _channelURIs; }
- set { _channelURIs = value; }
- }
-
-
- public object this[object key]
- {
- get {
-
- foreach (DictionaryEntry entry in _extraData) {
- if (entry.Key.Equals(key))
- return entry.Value;
- }
-
-
- return null;
- }
-
- set {
- if (_extraData == null) {
- _extraData = new DictionaryEntry[1];
- _extraData[0] = new DictionaryEntry(key, value);
- }
- else {
- int length = _extraData.Length;
- DictionaryEntry[] newList = new DictionaryEntry[length + 1];
- int co = 0;
- for (; co < length; co++)
- newList[co] = _extraData[co];
- newList[co] = new DictionaryEntry(key, value);
-
- _extraData = newList;
- }
- }
- }
-
-
- }
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface ITransportHeaders
- {
-
-
- object this[object key]
- {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get;
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- set;
- }
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- IEnumerator GetEnumerator();
- }
-
-
-
-
-
-
-
- [Serializable(), SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure), SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class TransportHeaders : ITransportHeaders
- {
- private ArrayList _headerList;
-
- public TransportHeaders()
- {
-
- _headerList = new ArrayList(6);
- }
-
-
-
- public object this[object key]
- {
- get {
- string strKey = (string)key;
-
-
- foreach (DictionaryEntry entry in _headerList) {
- if (String.Compare((string)entry.Key, strKey, StringComparison.OrdinalIgnoreCase) == 0)
- return entry.Value;
- }
-
-
- return null;
- }
-
- set {
- if (key == null)
- return;
-
- string strKey = (string)key;
-
-
- int co = _headerList.Count - 1;
- while (co >= 0) {
- string headerKey = (string)((DictionaryEntry)_headerList[co]).Key;
- if (String.Compare(headerKey, strKey, StringComparison.OrdinalIgnoreCase) == 0) {
- _headerList.RemoveAt(co);
- break;
- }
- co--;
- }
-
-
- if (value != null) {
- _headerList.Add(new DictionaryEntry(key, value));
- }
- }
- }
-
-
-
- public IEnumerator GetEnumerator()
- {
- return _headerList.GetEnumerator();
- }
-
- }
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public class SinkProviderData
- {
- private string _name;
- private Hashtable _properties = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
- private ArrayList _children = new ArrayList();
-
- public SinkProviderData(string name)
- {
- _name = name;
- }
-
- public string Name {
- get { return _name; }
- }
- public IDictionary Properties {
- get { return _properties; }
- }
- public IList Children {
- get { return _children; }
- }
- }
-
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure), SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class BaseChannelSinkWithProperties : BaseChannelObjectWithProperties
- {
- protected BaseChannelSinkWithProperties() : base()
- {
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure), SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class BaseChannelWithProperties : BaseChannelObjectWithProperties
- {
- protected IChannelSinkBase SinksWithProperties = null;
-
- protected BaseChannelWithProperties() : base()
- {
- }
-
-
-
- public override IDictionary Properties {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get {
-
-
- ArrayList dictionaries = new ArrayList();
-
-
- dictionaries.Add(this);
-
- if (SinksWithProperties != null) {
- IServerChannelSink srvSink = SinksWithProperties as IServerChannelSink;
- if (srvSink != null) {
- while (srvSink != null) {
- IDictionary dict = srvSink.Properties;
- if (dict != null)
- dictionaries.Add(dict);
-
- srvSink = srvSink.NextChannelSink;
- }
- }
- else {
-
- IClientChannelSink chnlSink = (IClientChannelSink)SinksWithProperties;
-
- while (chnlSink != null) {
- IDictionary dict = chnlSink.Properties;
- if (dict != null)
- dictionaries.Add(dict);
-
- chnlSink = chnlSink.NextChannelSink;
- }
- }
- }
-
-
- return new AggregateDictionary(dictionaries);
- }
- }
-
- }
-
-
-
-
-
-
-
-
-
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure), SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class BaseChannelObjectWithProperties : IDictionary
- {
- protected BaseChannelObjectWithProperties()
- {
- }
-
- public virtual IDictionary Properties {
- [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
- get { return this; }
- }
-
-
-
-
-
- public virtual object this[object key]
- {
- get { return null; }
- set {
- throw new NotImplementedException();
- }
- }
-
- public virtual ICollection Keys {
- get { return null; }
- }
-
- public virtual ICollection Values {
- get {
- ICollection keys = Keys;
- if (keys == null)
- return null;
-
- ArrayList values = new ArrayList();
- foreach (object key in keys) {
- values.Add(this[key]);
- }
-
- return values;
- }
- }
-
- public virtual bool Contains(object key)
- {
- if (key == null)
- return false;
-
- ICollection keySet = Keys;
- if (keySet == null)
- return false;
-
- string keyStr = key as string;
-
- foreach (object someKey in keySet) {
- if (keyStr != null) {
- string someKeyStr = someKey as string;
- if (someKeyStr != null) {
-
- if (String.Compare(keyStr, someKeyStr, StringComparison.OrdinalIgnoreCase) == 0)
- return true;
-
- continue;
- }
- }
-
- if (key.Equals(someKey))
- return true;
- }
-
- return false;
- }
-
- public virtual bool IsReadOnly {
- get { return false; }
- }
- public virtual bool IsFixedSize {
- get { return true; }
- }
-
-
-
-
- public virtual void Add(object key, object value)
- {
- throw new NotSupportedException();
- }
- public virtual void Clear()
- {
- throw new NotSupportedException();
- }
- public virtual void Remove(object key)
- {
- throw new NotSupportedException();
- }
-
- public virtual IDictionaryEnumerator GetEnumerator()
- {
- return new DictionaryEnumeratorByKeys(this);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public virtual void CopyTo(Array array, int index)
- {
- throw new NotSupportedException();
- }
-
- public virtual int Count {
- get {
- ICollection keySet = Keys;
- if (keySet == null)
- return 0;
-
- return keySet.Count;
- }
- }
-
- public virtual object SyncRoot {
- get { return this; }
- }
- public virtual bool IsSynchronized {
- get { return false; }
- }
-
-
-
-
-
-
- /// <internalonly/>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return new DictionaryEnumeratorByKeys(this);
- }
-
- }
-
-
-
-
- internal class DictionaryEnumeratorByKeys : IDictionaryEnumerator
- {
- IDictionary _properties;
- IEnumerator _keyEnum;
-
- public DictionaryEnumeratorByKeys(IDictionary properties)
- {
- _properties = properties;
- _keyEnum = properties.Keys.GetEnumerator();
- }
-
- public bool MoveNext()
- {
- return _keyEnum.MoveNext();
- }
- public void Reset()
- {
- _keyEnum.Reset();
- }
- public object Current {
- get { return Entry; }
- }
-
- public DictionaryEntry Entry {
- get { return new DictionaryEntry(Key, Value); }
- }
-
- public object Key {
- get { return _keyEnum.Current; }
- }
- public object Value {
- get { return _properties[Key]; }
- }
-
- }
-
-
-
-
- internal class AggregateDictionary : IDictionary
- {
- private ICollection _dictionaries;
-
- public AggregateDictionary(ICollection dictionaries)
- {
- _dictionaries = dictionaries;
- }
-
-
-
-
-
- public virtual object this[object key]
- {
- get {
- foreach (IDictionary dict in _dictionaries) {
- if (dict.Contains(key))
- return dict[key];
- }
-
- return null;
- }
-
- set {
- foreach (IDictionary dict in _dictionaries) {
- if (dict.Contains(key))
- dict[key] = value;
- }
- }
- }
-
- public virtual ICollection Keys {
- get {
- ArrayList keys = new ArrayList();
-
- foreach (IDictionary dict in _dictionaries) {
- ICollection dictKeys = dict.Keys;
- if (dictKeys != null) {
- foreach (object key in dictKeys) {
- keys.Add(key);
- }
- }
- }
-
- return keys;
- }
- }
-
- public virtual ICollection Values {
- get {
- ArrayList values = new ArrayList();
-
- foreach (IDictionary dict in _dictionaries) {
- ICollection dictValues = dict.Values;
- if (dictValues != null) {
- foreach (object value in dictValues) {
- values.Add(value);
- }
- }
- }
-
- return values;
- }
- }
-
- public virtual bool Contains(object key)
- {
- foreach (IDictionary dict in _dictionaries) {
- if (dict.Contains(key))
- return true;
- }
-
- return false;
- }
-
- public virtual bool IsReadOnly {
- get { return false; }
- }
- public virtual bool IsFixedSize {
- get { return true; }
- }
-
-
-
-
- public virtual void Add(object key, object value)
- {
- throw new