• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Messages.ServerRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ThoughtWorks.CruiseControl.Remote.Messages.ServerRequest的典型用法代码示例。如果您正苦于以下问题:C# ServerRequest类的具体用法?C# ServerRequest怎么用?C# ServerRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerRequest类属于ThoughtWorks.CruiseControl.Remote.Messages命名空间,在下文中一共展示了ServerRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SendMessage

        /// <summary>
        /// Sends a message to a remote server.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="request">The request to send to the server.</param>
        /// <returns>The response from the server.</returns>
        public Response SendMessage(string action, ServerRequest request)
        {
            // Make sure there is a password
            if ((cryptoKey.Length == 0) || (cryptoIv.Length == 0)) InitialisePassword();

            // Generate the encrypted request
            var encryptedRequest = new EncryptedRequest();
            encryptedRequest.Action = action;
            var crypto = new RijndaelManaged();
            crypto.Key = cryptoKey;
            crypto.IV = cryptoIv;
            encryptedRequest.EncryptedData = EncryptMessage(crypto, request.ToString());

            // Send the request
            var response = innerConnection.SendMessage("ProcessSecureRequest", encryptedRequest);
            var encryptedResponse = response as EncryptedResponse;

            // Generate the actual response
            if ((response.Result == ResponseResult.Success) && (encryptedResponse != null))
            {
                var data = DecryptMessage(crypto, encryptedResponse.EncryptedData);
                response = XmlConversionUtil.ProcessResponse(data);
            }
            return response;
        }
开发者ID:ImaginaryDevelopment,项目名称:CruiseControl.NET,代码行数:31,代码来源:EncryptingConnection.cs


示例2: SendMessageSendsAndReceivesAMessage

 public void SendMessageSendsAndReceivesAMessage()
 {
     var action = "DoSomething";
     var request = new ServerRequest
     {
         ServerName = "TestServer"
     };
     var url = "http://somewhere/";
     var factory = new TestClientFactory((u, a, d) =>
     {
         Assert.AreEqual(url + "server/TestServer/RawXmlMessage.aspx", u.AbsoluteUri);
         Assert.AreEqual("POST", a);
         Assert.AreEqual(action, d["action"]);
         Assert.AreEqual(request.ToString(), d["message"]);
         var theResponse = new Response
         {
             RequestIdentifier = request.Identifier
         };
         return Encoding.UTF8.GetBytes(theResponse.ToString());
     });
     var connection = new HttpConnection(new Uri(url), factory);
     var response = connection.SendMessage(action, request);
     Assert.IsInstanceOf<Response>(response);
     Assert.AreEqual(request.Identifier, response.RequestIdentifier);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:25,代码来源:HttpConnectionTests.cs


示例3: EqualsMatchesRequestWithTheSameIdentifier

 public void EqualsMatchesRequestWithTheSameIdentifier()
 {
     ServerRequest request1 = new ServerRequest();
     ServerRequest request2 = new ServerRequest();
     request1.Identifier = request2.Identifier;
     Assert.IsTrue(request1.Equals(request2));
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:ServerRequestTests.cs


示例4: SendMessageAsyncSendsMessage

 public void SendMessageAsyncSendsMessage()
 {
     var action = "DoSomething";
     var request = new ServerRequest
     {
         ServerName = "TestServer"
     };
     var url = "http://somewhere/";
     var factory = new TestClientFactory((u, a, d) =>
     {
         Assert.AreEqual(url + "server/TestServer/RawXmlMessage.aspx", u.AbsoluteUri);
         Assert.AreEqual("POST", a);
         Assert.AreEqual(action, d["action"]);
         Assert.AreEqual(request.ToString(), d["message"]);
         var theResponse = new Response
         {
             RequestIdentifier = request.Identifier
         };
         return Encoding.UTF8.GetBytes(theResponse.ToString());
     });
     var connection = new HttpConnection(new Uri(url), factory);
     var completed = false;
     connection.SendMessageCompleted += (o, e) =>
     {
         completed = true;
         Assert.IsFalse(e.Cancelled);
         Assert.IsNull(e.Error);
     };
     connection.SendMessageAsync(action, request);
     Assert.IsTrue(completed);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:31,代码来源:HttpConnectionTests.cs


示例5: ChannelCanBeSetAndRetrieved

 public void ChannelCanBeSetAndRetrieved()
 {
     var channelInfo = new object();
     var message = new ServerRequest();
     message.ChannelInformation = channelInfo;
     Assert.AreSame(channelInfo, message.ChannelInformation);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:CommunicationsMessageTests.cs


示例6: FireRequestSending

 /// <summary>
 /// Fires the <see cref="RequestSending"/> event.
 /// </summary>
 /// <param name="action">The action that is being sent.</param>
 /// <param name="request">The request that is being sent.</param>
 protected virtual void FireRequestSending(string action, ServerRequest request)
 {
     if (RequestSending != null)
     {
         RequestSending(this, new CommunicationsEventArgs(action, request));
     }
 }
开发者ID:ImaginaryDevelopment,项目名称:CruiseControl.NET,代码行数:12,代码来源:ServerConnectionBase.cs


示例7: InitialiseNewRequestSetsTheDefaultValues

 public void InitialiseNewRequestSetsTheDefaultValues()
 {
     DateTime now = DateTime.Now;
     ServerRequest request = new ServerRequest();
     Assert.IsFalse(string.IsNullOrEmpty(request.Identifier), "Identifier was not set");
     Assert.AreEqual(Environment.MachineName, request.SourceName, "Source name doesn't match the machine name");
     Assert.IsTrue((now <= request.Timestamp), "Timestamp was not set");
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:8,代码来源:ServerRequestTests.cs


示例8: ConvertXmlToRequestConvertsRequest

 public void ConvertXmlToRequestConvertsRequest()
 {
     var request = new ServerRequest("123456-789");
     request.ServerName = "theServer";
     var xmlString = request.ToString();
     var convertedRequest = XmlConversionUtil.ConvertXmlToRequest(xmlString);
     Assert.AreEqual("123456-789", convertedRequest.SessionToken);
     Assert.AreEqual("theServer", convertedRequest.ServerName);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:9,代码来源:XmlConversionUtilTests.cs


示例9: InitialiseResponseFromRequestSetsTheDefaultValues

 public void InitialiseResponseFromRequestSetsTheDefaultValues()
 {
     DateTime now = DateTime.Now;
     ServerRequest request = new ServerRequest();
     ListUsersResponse response = new ListUsersResponse(request);
     Assert.AreEqual(ResponseResult.Unknown, response.Result, "Result wasn't set to failure");
     Assert.AreEqual(request.Identifier, response.RequestIdentifier, "RequestIdentifier wasn't set to the identifier of the request");
     Assert.IsTrue((now <= response.Timestamp), "Timestamp was not set");
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:9,代码来源:ListUsersResponseTests.cs


示例10: InitialiseRequestWithSessionSetsTheCorrectValues

 public void InitialiseRequestWithSessionSetsTheCorrectValues()
 {
     string sessionToken = "the session";
     DateTime now = DateTime.Now;
     ServerRequest request = new ServerRequest(sessionToken);
     Assert.IsFalse(string.IsNullOrEmpty(request.Identifier), "Identifier was not set");
     Assert.AreEqual(Environment.MachineName, request.SourceName, "Source name doesn't match the machine name");
     Assert.AreEqual(sessionToken, request.SessionToken, "SessionToken doesn't match the input token");
     Assert.IsTrue((now <= request.Timestamp), "Timestamp was not set");
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:10,代码来源:ServerRequestTests.cs


示例11: ToStringSerialisesDefaultValues

 public void ToStringSerialisesDefaultValues()
 {
     ServerRequest request = new ServerRequest();
     string actual = request.ToString();
     string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<serverMessage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
         "timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" source=\"{1}\" />",
         request.Identifier,
         request.SourceName,
         request.Timestamp);
     Assert.AreEqual(expected, actual);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:11,代码来源:ServerRequestTests.cs


示例12: buildProject

        private void buildProject()
        {
            this._manager = new RemoteCruiseManagerFactory()
                .GetCruiseServerClient("tcp://localhost:21234/CruiseManager.rem");
            this._project = new ProjectRequest("Edd", this.Name);
            this._manager.ForceBuild(this._project);
            this._request = new ServerRequest(this._project.SessionToken);

            // Write current status
            this.progress(String.Empty);
            IsRunning = false;
            Console.Write("\n\n");
        }
开发者ID:redheat,项目名称:vx-deployment,代码行数:13,代码来源:VxBuild.cs


示例13: SendMessageEncryptsMessage

        public void SendMessageEncryptsMessage()
        {
            var innerConnection = new TestConnection();
            var outerConnection = new EncryptingConnection(innerConnection);
            var request = new ServerRequest();
            var expectedResponse = new Response(request);
            var actionName = "DoSomething";
            string iv = null;
            string key = null;

            innerConnection.SendMessageAction = (a, r) =>
            {
                Response sendResponse = null;
                if (a == "RetrievePublicKey")
                {
                    sendResponse = this.GenerateKeyResponse(r);
                }
                else if (a == "InitialiseSecureConnection")
                {
                    Assert.IsInstanceOf<LoginRequest>(r);
                    sendResponse = this.GenerateConnectioResponse(r as LoginRequest, out iv, out key);
                }
                else if (a == "ProcessSecureRequest")
                {
                    Assert.IsInstanceOf<EncryptedRequest>(r);
                    var actualRequest = r as EncryptedRequest;
                    Assert.AreEqual(actionName, actualRequest.Action);

                    var crypto = new RijndaelManaged();
                    crypto.Key = Convert.FromBase64String(key);
                    crypto.IV = Convert.FromBase64String(iv);
                    var requestData = DecryptMessage(crypto, actualRequest.EncryptedData);
                    Assert.AreEqual(request.ToString(), requestData);

                    var encryptedResponse = new EncryptedResponse();
                    encryptedResponse.Result = ResponseResult.Success;
                    encryptedResponse.EncryptedData = EncryptMessage(crypto, expectedResponse.ToString());
                    sendResponse = encryptedResponse;
                }
                else
                {
                    Assert.Fail("Unknown action: " + a);
                }

                return sendResponse;
            };
            var response = outerConnection.SendMessage(actionName, request);
            Assert.IsNotNull(response);
            Assert.AreEqual(expectedResponse.RequestIdentifier, response.RequestIdentifier);
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:50,代码来源:EncryptingConnectionTests.cs


示例14: GetSetAllPropertiesWorks

 public void GetSetAllPropertiesWorks()
 {
     ServerRequest request = new ServerRequest();
     request.Identifier = "new id";
     Assert.AreEqual("new id", request.Identifier, "Identifier fails the get/set test");
     request.ServerName = "new server";
     Assert.AreEqual("new server", request.ServerName, "ServerName fails the get/set test");
     request.SessionToken = "new session";
     Assert.AreEqual("new session", request.SessionToken, "SessionToken fails the get/set test");
     request.SourceName = "new source";
     Assert.AreEqual("new source", request.SourceName, "SourceName fails the get/set test");
     DateTime now = DateTime.Now;
     request.Timestamp = now;
     Assert.AreEqual(now, request.Timestamp, "Timestamp fails the get/set test");
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:15,代码来源:ServerRequestTests.cs


示例15: SendMessage

 public Response SendMessage(string action, ServerRequest request)
 {
     Assert.AreEqual(this.action, action);
     Assert.AreEqual(this.message, request.GetType());
     if (!string.IsNullOrEmpty(projectName) && (request is ProjectRequest))
     {
         Assert.AreEqual(this.projectName, (request as ProjectRequest).ProjectName);
     }
     if (response == null)
     {
         Response result = new Response(request);
         result.Result = ResponseResult.Success;
         return result;
     }
     else
     {
         return response;
     }
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:19,代码来源:CruiseServerClientTests.cs


示例16: Response

 /// <summary>
 /// Initialise a new instance of <see cref="Response"/> from a request.
 /// </summary>
 /// <param name="request">The request to use.</param>
 public Response(ServerRequest request)
     : this()
 {
     requestIdentifier = request.Identifier;
 }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:9,代码来源:Response.cs


示例17: ListServers

 /// <summary>
 /// Lists the available servers that can be monitored.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns>
 /// A list containing one server - local.
 /// </returns>
 /// <remarks>
 /// This message is not secured at all.
 /// </remarks>
 public DataListResponse ListServers(ServerRequest request)
 {
     return new DataListResponse
     {
         Data = new List<string>{
             "local"
         }
     };
 }
开发者ID:bkr765,项目名称:CruiseControl.NET,代码行数:19,代码来源:CruiseServerClient.cs


示例18: TerminateSecureConnection

        /// <summary>
        /// Terminate a secure communications connection.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public Response TerminateSecureConnection(ServerRequest request)
        {
            // Remove the connection details
            if (connections.ContainsKey(request.SourceName))
            {
                connections.Remove(request.SourceName);
            }

            // Generate a response
            var response = new Response(request);
            response.Result = ResponseResult.Success;
            return response;
        }
开发者ID:bkr765,项目名称:CruiseControl.NET,代码行数:18,代码来源:CruiseServerClient.cs


示例19: RetrievePublicKey

        /// <summary>
        /// Retrieve the public key for the server.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public DataResponse RetrievePublicKey(ServerRequest request)
        {
            var response = new DataResponse(request);

            // Either generate or retrieve the key for CruiseControl.NET Server
            var cp = new CspParameters();
            cp.KeyContainerName = "CruiseControl.NET Server";
            var provider = new RSACryptoServiceProvider(cp);

            // Return the public key
            response.Data = provider.ToXmlString(false);
            response.Result = ResponseResult.Success;

            return response;
        }
开发者ID:bkr765,项目名称:CruiseControl.NET,代码行数:20,代码来源:CruiseServerClient.cs


示例20: ProcessSecureRequest

        /// <summary>
        /// Processes an encrypted request.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public Response ProcessSecureRequest(ServerRequest request)
        {
            // Validate the request
            var encryptedRequest = request as EncryptedRequest;
            if (encryptedRequest == null) throw new CruiseControlException("Incoming request is not an encrypted request");
            if (!connections.ContainsKey(request.SourceName)) throw new CruiseControlException("No secure connection for the source");
            var connection = connections[request.SourceName];

            // Decrypt the data
            var crypto = new RijndaelManaged();
            crypto.Key = connection.Key;
            crypto.IV = connection.IV;
            string data = DecryptMessage(crypto, encryptedRequest.EncryptedData);

            // Find the action and message type, extract the message and invoke the method
            var response = ExtractAndInvokeMessage(data, encryptedRequest.Action,
                new RemotingChannelSecurityInformation { IsEncrypted = true });

            // Encrypt the response
            var encryptedResponse = new EncryptedResponse(request);
            encryptedResponse.EncryptedData = response.ToString();
            encryptedResponse.EncryptedData = EncryptMessage(crypto, encryptedResponse.EncryptedData);
            encryptedResponse.Result = ResponseResult.Success;

            return encryptedResponse;
        }
开发者ID:bkr765,项目名称:CruiseControl.NET,代码行数:31,代码来源:CruiseServerClient.cs



注:本文中的ThoughtWorks.CruiseControl.Remote.Messages.ServerRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Protocol.TBinaryProtocol类代码示例发布时间:2022-05-26
下一篇:
C# Messages.ProjectRequest类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap