RegisterChannel() private method

private RegisterChannel ( IChannel chnl ) : void
chnl IChannel
return void
        internal static void RegisterChannelConfig(ChannelData channel)
        {
            IServerChannelSinkProvider serverChannelSinkProvider = null;
            IClientChannelSinkProvider clientChannelSinkProvider = null;

            for (int i = channel.ServerProviders.Count - 1; i >= 0; i--)
            {
                ProviderData prov = channel.ServerProviders[i] as ProviderData;
                IServerChannelSinkProvider serverChannelSinkProvider2 = (IServerChannelSinkProvider)ChannelServices.CreateProvider(prov);
                serverChannelSinkProvider2.Next = serverChannelSinkProvider;
                serverChannelSinkProvider       = serverChannelSinkProvider2;
            }
            for (int j = channel.ClientProviders.Count - 1; j >= 0; j--)
            {
                ProviderData prov2 = channel.ClientProviders[j] as ProviderData;
                IClientChannelSinkProvider clientChannelSinkProvider2 = (IClientChannelSinkProvider)ChannelServices.CreateProvider(prov2);
                clientChannelSinkProvider2.Next = clientChannelSinkProvider;
                clientChannelSinkProvider       = clientChannelSinkProvider2;
            }
            Type type = Type.GetType(channel.Type);

            if (type == null)
            {
                throw new RemotingException("Type '" + channel.Type + "' not found");
            }
            bool flag  = typeof(IChannelSender).IsAssignableFrom(type);
            bool flag2 = typeof(IChannelReceiver).IsAssignableFrom(type);

            Type[]   types;
            object[] parameters;
            if (flag && flag2)
            {
                types = new Type[]
                {
                    typeof(IDictionary),
                    typeof(IClientChannelSinkProvider),
                    typeof(IServerChannelSinkProvider)
                };
                parameters = new object[]
                {
                    channel.CustomProperties,
                    clientChannelSinkProvider,
                    serverChannelSinkProvider
                };
            }
            else if (flag)
            {
                types = new Type[]
                {
                    typeof(IDictionary),
                    typeof(IClientChannelSinkProvider)
                };
                parameters = new object[]
                {
                    channel.CustomProperties,
                    clientChannelSinkProvider
                };
            }
            else
            {
                if (!flag2)
                {
                    throw new RemotingException(type + " is not a valid channel type");
                }
                types = new Type[]
                {
                    typeof(IDictionary),
                    typeof(IServerChannelSinkProvider)
                };
                parameters = new object[]
                {
                    channel.CustomProperties,
                    serverChannelSinkProvider
                };
            }
            ConstructorInfo constructor = type.GetConstructor(types);

            if (constructor == null)
            {
                throw new RemotingException(type + " does not have a valid constructor");
            }
            IChannel channel2;

            try
            {
                channel2 = (IChannel)constructor.Invoke(parameters);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            object syncRoot = ChannelServices.registeredChannels.SyncRoot;

            lock (syncRoot)
            {
                if (channel.DelayLoadAsClientChannel == "true" && !(channel2 is IChannelReceiver))
                {
                    ChannelServices.delayedClientChannels.Add(channel2);
                }
                else
                {
                    ChannelServices.RegisterChannel(channel2);
                }
            }
        }
 public static void RegisterChannel(IChannel chnl)
 {
     ChannelServices.RegisterChannel(chnl, false);
 }