Example #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="ChannelProperties"/>
        /// describing the exact same channel as described by <paramref name="url"/>.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// An <see cref="ArgumentNullException"/> is thrown if the given <paramref name="url"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// An <see cref="ArgumentException"/> is thrown if the given <paramref name="url"/> is not a valid IPC channel url.
        /// </exception>
        /// <param name="url"></param>
        /// <returns></returns>
        public static ChannelProperties InitializeFromUrl(string url)
        {
            // Verify and split the argument.
            AssertParameterNotNull(url, "url");
            if (url.StartsWith(_UrlPrefix))
            {
                url = url.Substring(_UrlPrefix.Length);
            }
            var values = url.Split(new[] { _Seperator }, StringSplitOptions.None);

            if (values.Length != 2)
            {
                throw new ArgumentException("The provided url isn't valid.", "url");
            }
            // Extract properties.
            var    properties  = new ChannelProperties();
            var    channelName = values[0];
            string postFix;

            if (channelName.EndsWith(_PostfixInstantiatorSide))
            {
                postFix = _PostfixInstantiatorSide;
            }
            else if (channelName.EndsWith(_PostfixRemoteSide))
            {
                postFix = _PostfixRemoteSide;
            }
            else
            {
                throw new ArgumentException("The provided url isn't valid.", "url");
            }
            properties._localEndPointIsInstantiator = postFix == _PostfixInstantiatorSide;
            properties._channelName  = channelName.Substring(0, channelName.Length - postFix.Length);
            properties._endPointName = values[1];
            AssertLegalValues(properties._channelName, "url");
            AssertLegalValues(properties._endPointName, "url");
            return(properties);
        }
Example #2
0
 /// <summary>
 ///     Initializes a new instance of <see cref="ChannelProperties" />
 ///     describing the exact same channel as described by <paramref name="url" />.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 ///     An <see cref="ArgumentNullException" /> is thrown if the given <paramref name="url" /> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     An <see cref="ArgumentException" /> is thrown if the given <paramref name="url" /> is not a valid IPC channel url.
 /// </exception>
 /// <param name="url"></param>
 /// <returns></returns>
 public static ChannelProperties InitializeFromUrl(string url)
 {
     // Verify and split the argument.
     AssertParameterNotNull(url, "url");
     if (url.StartsWith(_UrlPrefix))
         url = url.Substring(_UrlPrefix.Length);
     var values = url.Split(new[] {_Seperator}, StringSplitOptions.None);
     if (values.Length != 2)
         throw new ArgumentException("The provided url isn't valid.", "url");
     // Extract properties.
     var properties = new ChannelProperties();
     var channelName = values[0];
     string postFix;
     if (channelName.EndsWith(_PostfixInstantiatorSide))
         postFix = _PostfixInstantiatorSide;
     else if (channelName.EndsWith(_PostfixRemoteSide))
         postFix = _PostfixRemoteSide;
     else
         throw new ArgumentException("The provided url isn't valid.", "url");
     properties._localEndPointIsInstantiator = postFix == _PostfixInstantiatorSide;
     properties._channelName = channelName.Substring(0, channelName.Length - postFix.Length);
     properties._endPointName = values[1];
     AssertLegalValues(properties._channelName, "url");
     AssertLegalValues(properties._endPointName, "url");
     return properties;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="DuplexChannel{TRemoteEndPoint}"/> based on the given data.
 /// </summary>
 /// <param name="localEndPointConfig"></param>
 /// <param name="serverChannelProperties"></param>
 internal DuplexChannel(EndPointConfigurationData <TRemoteEndPoint> localEndPointConfig, ChannelProperties serverChannelProperties)
 {
     AssertEndpointConfigurationData(localEndPointConfig, "localEndpointConfig");
     _localEndPointConfig     = localEndPointConfig;
     _localChannelProperties  = serverChannelProperties;
     _remoteChannelProperties = serverChannelProperties.GetRemoteEndpointChannelProperties();
 }
Example #4
0
 /// <summary>
 /// Creates a new full duplex channel, in which the remote endpoint's <see cref="AppDomain"/> is the instantiator.
 /// </summary>
 /// <param name="localEndPointConfig">Configuration for the local endpoint.</param>
 /// <param name="otherChannelUrl">The url to the remote endpoint, which is the channel instantiator.</param>
 public DuplexChannel(EndPointConfigurationData <TRemoteEndPoint> localEndPointConfig, string otherChannelUrl)
     : this(localEndPointConfig, ChannelProperties.InitializeFromUrl(otherChannelUrl).GetRemoteEndpointChannelProperties())
 {
 }
Example #5
0
 /// <summary>
 /// Creates a new full duplex channel, in which the current <see cref="AppDomain"/> is the instantiator.
 /// </summary>
 /// <param name="localEndPointConfig">Configuration for the local endpoint.</param>
 public DuplexChannel(EndPointConfigurationData <TRemoteEndPoint> localEndPointConfig)
     : this(localEndPointConfig, ChannelProperties.CreateRandomChannelProperties())
 {
 }
Example #6
0
 /// <summary>
 ///     Initializes a new instance of <see cref="SimplexChannel{TEndPoint}" /> using the given configuration data.
 /// </summary>
 /// <exception cref="ArgumentException"></exception>
 /// <param name="endPointConfigurationData"></param>
 public SimplexChannel(EndPointConfigurationData <TEndPoint> endPointConfigurationData)
 {
     AssertEndpointConfigurationData(endPointConfigurationData, "endPointConfigurationData");
     _channelProperties = ChannelProperties.CreateRandomChannelProperties();
     _endPointConfig    = endPointConfigurationData;
 }