Example #1
0
        public static LogEntry For(AddNodesRequest request)
        {
            LogEntry entry = new LogEntry("AddNodesRequest");

            entry.Add("RequestHeader", For(request.RequestHeader));
            entry.Add("NodesToAdd", For(request.NodesToAdd));
            return(entry);
        }
Example #2
0
        public async Task AddNodesAsync()
        {
            var response = new AddNodesResponse();
            var request  = new AddNodesRequest();
            var channel  = new TestRequestChannel(response);

            var ret = await channel.AddNodesAsync(request);

            ret
            .Should().BeSameAs(response);

            channel.Request
            .Should().BeSameAs(request);
        }
Example #3
0
        /// <summary>
        /// Adds one or more Nodes into the AddressSpace hierarchy.
        /// </summary>
        /// <param name="channel">A instance of <see cref="IRequestChannel"/>.</param>
        /// <param name="request">A <see cref="AddNodesRequest"/>.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation that returns a <see cref="AddNodesResponse"/>.</returns>
        public static async Task <AddNodesResponse> AddNodesAsync(this IRequestChannel channel, AddNodesRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return((AddNodesResponse)await channel.RequestAsync(request).ConfigureAwait(false));
        }
Example #4
0
        /// <summary>
        /// Begins an asynchronous invocation of the AddNodes service.
        /// </summary>
        public IAsyncResult BeginAddNodes(
            RequestHeader          requestHeader,
            AddNodesItemCollection nodesToAdd,
            AsyncCallback          callback,
            object                 asyncState)
        {
            AddNodesRequest request = new AddNodesRequest();

            request.RequestHeader = requestHeader;
            request.NodesToAdd    = nodesToAdd;

            UpdateRequestHeader(request, requestHeader == null, "AddNodes");

            if (UseTransportChannel)
            {
                return TransportChannel.BeginSendRequest(request, callback, asyncState);
            }

            return InnerChannel.BeginAddNodes(new AddNodesMessage(request), callback, asyncState);
        }
Example #5
0
        /// <summary>
        /// Invokes the AddNodes service.
        /// </summary>
        public virtual ResponseHeader AddNodes(
            RequestHeader                requestHeader,
            AddNodesItemCollection       nodesToAdd,
            out AddNodesResultCollection results,
            out DiagnosticInfoCollection diagnosticInfos)
        {
            AddNodesRequest request = new AddNodesRequest();
            AddNodesResponse response = null;

            request.RequestHeader = requestHeader;
            request.NodesToAdd    = nodesToAdd;

            UpdateRequestHeader(request, requestHeader == null, "AddNodes");

            try
            {
                if (UseTransportChannel)
                {
                    IServiceResponse genericResponse = TransportChannel.SendRequest(request);

                    if (genericResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    ValidateResponse(genericResponse.ResponseHeader);
                    response = (AddNodesResponse)genericResponse;
                }
                else
                {
                    AddNodesResponseMessage responseMessage = InnerChannel.AddNodes(new AddNodesMessage(request));

                    if (responseMessage == null || responseMessage.AddNodesResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    response = responseMessage.AddNodesResponse;
                    ValidateResponse(response.ResponseHeader);
                }

                results         = response.Results;
                diagnosticInfos = response.DiagnosticInfos;
            }
            finally
            {
                RequestCompleted(request, response, "AddNodes");
            }

            return response.ResponseHeader;
        }
Example #6
0
 /// <summary>
 /// Initializes the message with the body.
 /// </summary>
 public AddNodesMessage(AddNodesRequest AddNodesRequest)
 {
     this.AddNodesRequest = AddNodesRequest;
 }