コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProtocolChannel"/> class.
        /// </summary>
        /// <param name="id">The ID number of the current endpoint.</param>
        /// <param name="channelTemplate">The type of channel, e.g. TCP.</param>
        /// <param name="hostBuilder">
        /// The function that returns an object which handles the <see cref="ServiceHost"/> for the channel used to communicate with.
        /// </param>
        /// <param name="messageReceiverBuilder">The function that builds message receiving endpoints.</param>
        /// <param name="dataReceiverBuilder">The function that builds data receiving endpoints.</param>
        /// <param name="senderBuilder">The function that builds sending endpoints.</param>
        /// <param name="versionedMessageSenderBuilder">
        /// The function that creates a specific version of the message sender used to connect to a given URL.
        /// </param>
        /// <param name="versionedDataSenderBuilder">
        /// The function that creates a specific version of the data sender used to connect to a given URL.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="id"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="channelTemplate"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="hostBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="messageReceiverBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="dataReceiverBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="senderBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="versionedMessageSenderBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="versionedDataSenderBuilder"/> is <see langword="null" />.
        /// </exception>
        public ProtocolChannel(
            EndpointId id,
            IProtocolChannelTemplate channelTemplate,
            Func <IHoldServiceConnections> hostBuilder,
            Func <Version, Tuple <Type, IMessagePipe> > messageReceiverBuilder,
            Func <Version, Tuple <Type, IDataPipe> > dataReceiverBuilder,
            BuildSendingEndpoint senderBuilder,
            Func <Version, Uri, IMessageSendingEndpoint> versionedMessageSenderBuilder,
            Func <Version, Uri, IDataTransferingEndpoint> versionedDataSenderBuilder)
        {
            {
                Lokad.Enforce.Argument(() => id);
                Lokad.Enforce.Argument(() => channelTemplate);
                Lokad.Enforce.Argument(() => hostBuilder);
                Lokad.Enforce.Argument(() => messageReceiverBuilder);
                Lokad.Enforce.Argument(() => dataReceiverBuilder);
                Lokad.Enforce.Argument(() => senderBuilder);
                Lokad.Enforce.Argument(() => versionedMessageSenderBuilder);
                Lokad.Enforce.Argument(() => versionedDataSenderBuilder);
            }

            m_Id          = id;
            m_Template    = channelTemplate;
            m_HostBuilder = hostBuilder;

            m_MessageMessageReceiverBuilder = messageReceiverBuilder;
            m_DataReceiverBuilder           = dataReceiverBuilder;

            m_SenderBuilder = senderBuilder;
            m_VersionedMessageSenderBuilder = versionedMessageSenderBuilder;
            m_VersionedDataSenderBuilder    = versionedDataSenderBuilder;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RestoringDataTransferingEndpoint"/> class.
        /// </summary>
        /// <param name="address">The address of the remote endpoint.</param>
        /// <param name="template">The template that is used to create the binding used to connect to the remote endpoint.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostic methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="address"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="template"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RestoringDataTransferingEndpoint(
            Uri address,
            IProtocolChannelTemplate template,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => address);
                Lokad.Enforce.Argument(() => template);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            var endpoint = new EndpointAddress(address);
            var binding  = template.GenerateDataBinding();

            // No need to put a DataContractResolver on this factory because the message type
            // for this endpoint is completely known.
            m_Factory = new ChannelFactory <IDataReceivingEndpointProxy>(binding, endpoint);

            m_Diagnostics = systemDiagnostics;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RestoringMessageSendingEndpoint"/> class.
        /// </summary>
        /// <param name="address">The address of the remote endpoint.</param>
        /// <param name="template">The template that is used to create the binding used to connect to the remote endpoint.</param>
        /// <param name="dataContractResolver">The <see cref="DataContractResolver"/> that is used for the endpoint.</param>
        /// <param name="messageConverters">The collection that contains all the message converters.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostic methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="address"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="template"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="dataContractResolver"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="messageConverters"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RestoringMessageSendingEndpoint(
            Uri address,
            IProtocolChannelTemplate template,
            ProtocolDataContractResolver dataContractResolver,
            IEnumerable <IConvertCommunicationMessages> messageConverters,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => address);
                Lokad.Enforce.Argument(() => template);
                Lokad.Enforce.Argument(() => dataContractResolver);
                Lokad.Enforce.Argument(() => messageConverters);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            var endpoint = new EndpointAddress(address);
            var binding  = template.GenerateMessageBinding();

            m_Factory = new ChannelFactory <IMessageReceivingEndpointProxy>(binding, endpoint);
            foreach (var operation in m_Factory.Endpoint.Contract.Operations)
            {
                var behavior = operation.Behaviors.Find <DataContractSerializerOperationBehavior>();
                if (behavior == null)
                {
                    behavior = new DataContractSerializerOperationBehavior(operation);
                    operation.Behaviors.Add(behavior);
                }

                behavior.DataContractResolver = dataContractResolver;
            }

            m_Diagnostics = systemDiagnostics;

            foreach (var converter in messageConverters)
            {
                m_Converters.Add(converter.MessageTypeToTranslate, converter);
            }
        }