本文整理汇总了C#中Response类的典型用法代码示例。如果您正苦于以下问题:C# Response类的具体用法?C# Response怎么用?C# Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于命名空间,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ActivateMeta
public Response ActivateMeta(MetaSearchModel metaSearchModel)
{
var response = new Response { Success = true, Warning = false };
try
{
var deRowPost = new ET_DataExtensionRow
{
AuthStub = conexion.ETCliente,
DataExtensionName = "METASAPPBENEFICIOS",
};
deRowPost.ColumnValues.Add("ID", metaSearchModel.Id);
deRowPost.ColumnValues.Add("ACTIVED", "TRUE");
try
{
var postResponse = deRowPost.Patch();
response.Success = postResponse.Status;
response.Message = postResponse.Message;
response.Code = postResponse.Code;
}
catch (Exception exCreate)
{
response.Success = false;
response.Message = exCreate.Message;
}
}
catch (Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:MijailStell,项目名称:Falabella,代码行数:35,代码来源:DataExtensionHelper.cs
示例2: ResponseMayHaveContentLength
public void ResponseMayHaveContentLength()
{
AppDelegate app = call =>
{
var response = new Response();
response.Headers.SetHeader("Content-Length", "12");
response.Write("Hello world.");
return response.EndAsync();
};
using (ServerFactory.Create(app, 8090, null))
{
var request = (HttpWebRequest)WebRequest.Create("http://localhost:8090/");
string text;
using (var response = request.GetResponse())
{
using (var stream = response.GetResponseStream())
{
using (var reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
}
}
Assert.That(text, Is.EqualTo("Hello world."));
}
}
开发者ID:dragan,项目名称:gate,代码行数:27,代码来源:ServerTests.cs
示例3: ViewAllPtoRequests
public Response<List<PaidTimeOff>> ViewAllPtoRequests()
{
Response<List<PaidTimeOff>> response = new Response<List<PaidTimeOff>>();
List<PaidTimeOff> ptoList = _ptoRepo.ViewAllPtoRequests();
try
{
if (ptoList.Count > 0)
{
response.Data = ptoList;
response.Success = true;
}
else
{
response.Success = false;
response.Message = "There are no requests to display";
}
}
catch (Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:JakeSaliga,项目名称:SGHRPortal,代码行数:25,代码来源:PaidTimeOffOperations.cs
示例4: CreateOrder
public Response<Order> CreateOrder(OrderRequest orderToAddRequest)
{
var response = new Response<Order>();
try
{
var orders = _orderRepo.ListAll(orderToAddRequest.OrderDate);
if (orderToAddRequest.Order.OrderNumber == 0)
{
orderToAddRequest.Order.OrderNumber = GenerateOrderNumber(orders);
}
orderToAddRequest = GetTaxRate(orderToAddRequest);
orderToAddRequest = UpdateCosts(orderToAddRequest);
_orderRepo.Add(orderToAddRequest);
response.Success = true;
response.Data = orderToAddRequest.Order;
}
catch (Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:KileyDowling,项目名称:FlooringMasteryProject,代码行数:27,代码来源:OrderOperations.cs
示例5: PutResponse
public IHttpActionResult PutResponse(int id, Response response)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != response.Id)
{
return BadRequest();
}
CITDataContext.Entry(response).State = EntityState.Modified;
try
{
CITDataContext.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!ResponseExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
开发者ID:PavanBod,项目名称:MyAngProject,代码行数:32,代码来源:ResponsesController.cs
示例6: if
public Response<TradePlayer>TradePlayer(TradePlayer trader)
{
Response<TradePlayer> response = new Response<TradePlayer>();
try
{
if (trader.Player1ID == trader.Player2ID)
{
response.Success = false;
response.Message = "You cannot trade the same player!";
}
else if (trader.Team1ID == trader.Team2ID)
{
response.Success = false;
response.Message = "you cannot trade to the same team!";
}
else
{
_repo.TradePlayer(trader);
response.Success = true;
response.Message = "Successfully traded players.";
}
}
catch(Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:amdenne,项目名称:SWGuildProjects,代码行数:30,代码来源:BaseballLeagueManager.cs
示例7: Get
public IHttpActionResult Get(int CurrentPage)
{
//申明参数
int _pageSize = 10;
try
{
PageInfo pageInfo = new PageInfo()
{
PageIndex = CurrentPage,
PageSize = _pageSize,
OrderField = "POSTID",
Order = OrderEnum.asc
};
var list = bll.GetList(pageInfo);
Response<IEnumerable<V_tm_pm_post>> response = new Response<IEnumerable<V_tm_pm_post>>
{
Data = list,
PagesCount = pageInfo.Total / _pageSize
};
return Ok(response);
}
catch (Exception ex)
{
LogHelper.WriteInfo(ex.ToString());
return BadRequest("异常");
}
}
开发者ID:x55756016,项目名称:CodeMaticProjectTemplate,代码行数:28,代码来源:tm_pm_post.cs
示例8: Handle
/// <summary>
/// Tries to handle request.
/// </summary>
/// <param name="request">
/// The request.
/// </param>
/// <returns>
/// The WebServer.BusinessLogic.Response.
/// </returns>
public override Response Handle(Request request)
{
if (request.HttpPath.EndsWith("/"))
{
string path = Configurator.Instance.RelativeWwwPath + request.HttpPath.Replace("/", "\\");
if(!Directory.Exists(path))
{
return NextHandler.Handle(request);
}
DirectoryInfo directory = new DirectoryInfo(path);
List<FileSystemInfo> descendants = new List<FileSystemInfo>();
descendants.AddRange(directory.GetFileSystemInfos());
if (descendants.Select(desc => desc.Name).Contains("index.html"))
{
request.HttpPath += "index.html";
return NextHandler.Handle(request);
}
string webPage = this.CreateWebPage(descendants, request);
Response toReturn = new Response("text/html", request.HttpVersion, Encoding.UTF8.GetBytes(webPage));
if (Configurator.Instance.UseResponseCompression && request.AcceptEncoding == EnumAcceptEncoding.Gzip)
{
toReturn.Data = GzipCompress(toReturn.Data);
toReturn.ContentEncoding = "gzip";
}
return toReturn;
}
return NextHandler.Handle(request);
}
开发者ID:taraspikh,项目名称:cs-webserver,代码行数:42,代码来源:DirectoryHandler.cs
示例9: DisplayFiles
public Response<List<Resumes>> DisplayFiles(string filePath)
{
var repo = new FileRepository();
var response = new Response<List<Resumes>>();
try
{
response.Data = repo.GetFiles(filePath);
if (response.Data != null)
{
response.Success = true;
}
else
{
response.Success = false;
response.Message = "There are no files to display.";
}
}
catch (Exception ex)
{
response.Message = ex.Message;
response.Success = false;
}
return response;
}
开发者ID:cancastle,项目名称:CodingSampler,代码行数:32,代码来源:FileOperations.cs
示例10: HasDefaultMessage
public void HasDefaultMessage()
{
var response = new Response((HttpStatusCode)451, null, new Dictionary<string, string>(), "application/json");
var legalRestrictionException = new LegalRestrictionException(response);
Assert.Equal("Resource taken down due to a DMCA notice.", legalRestrictionException.Message);
}
开发者ID:RadicalLove,项目名称:octokit.net,代码行数:7,代码来源:LegalRestrictionExceptionTests.cs
示例11: IsNew
public Boolean IsNew(Response response)
{
Int32? obs = response.Observe;
if (!obs.HasValue)
{
// this is a final response, e.g., error or proactive cancellation
return true;
}
// Multiple responses with different notification numbers might
// arrive and be processed by different threads. We have to
// ensure that only the most fresh one is being delivered.
// We use the notation from the observe draft-08.
DateTime T1 = Timestamp;
DateTime T2 = DateTime.Now;
Int32 V1 = Current;
Int32 V2 = obs.Value;
Int64 notifMaxAge = (_config ?? CoapConfig.Default).NotificationMaxAge;
if (V1 < V2 && V2 - V1 < 1 << 23
|| V1 > V2 && V1 - V2 > 1 << 23
|| T2 > T1.AddMilliseconds(notifMaxAge))
{
Timestamp = T2;
_number = V2;
return true;
}
else
{
return false;
}
}
开发者ID:Kulak,项目名称:CoAP.NET,代码行数:31,代码来源:ObserveNotificationOrderer.cs
示例12: AddPost
public Response<Post> AddPost(Post newPost)
{
Regex pattern = new Regex(@"#\w+", RegexOptions.IgnoreCase);
var cats = new List<string>();
List<Category> catList = new List<Category>();
foreach (Match match in pattern.Matches(newPost.Content))
{
string cat = match.Value;
cats.Add(cat.Substring(1, cat.Length - 1) + " ");
foreach (var c in cats)
{
catList.Add(new Category() { category = c });
}
}
newPost.Categories = catList;
var response = new Response<Post>();
try
{
_repo.AddPost(newPost);
response.Success = true;
response.Message = "Successfully added post.";
}
catch(Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:amdenne,项目名称:SWGuildProjects,代码行数:34,代码来源:BlogManager.cs
示例13: JsonFormatterExtensionsFixtures
public JsonFormatterExtensionsFixtures()
{
this.formatter = A.Fake<IResponseFormatter>();
this.model = new Person { FirstName = "Andy", LastName = "Pike" };
DefaultSerializersStartup.JsonSerializer = new DefaultJsonSerializer();
this.response = this.formatter.AsJson(model);
}
开发者ID:rmueller,项目名称:Nancy,代码行数:7,代码来源:JsonFormatterExtensionsFixtures.cs
示例14: Should_not_parse_wrong_xml
public void Should_not_parse_wrong_xml()
{
var response = new Response(HttpStatusCode.OK, XmlContentType(), XmlWrongDtoResponseText);
var deserializer = new ResponseDeserializer();
Assert.Throws<UnexpectedXmlContentException>(() => deserializer.DeserializeResponse<Status>(response, false));
}
开发者ID:DrValani,项目名称:SevenDigital.Api.Wrapper,代码行数:7,代码来源:ResponseDeserializerTests.cs
示例15: Should_set_properties_when_creating_oauth_exception
public void Should_set_properties_when_creating_oauth_exception()
{
var dummyResponse = new Response(HttpStatusCode.BadRequest,"Test Body");
var result = new OAuthException(dummyResponse);
Assert.That(result.ResponseBody, Is.EqualTo(dummyResponse.Body));
Assert.That(result.StatusCode, Is.EqualTo(dummyResponse.StatusCode));
}
开发者ID:DrValani,项目名称:SevenDigital.Api.Wrapper,代码行数:7,代码来源:ExceptionFactoryTests.cs
示例16: Can_I_Generate_Conference_With_Dial
public void Can_I_Generate_Conference_With_Dial()
{
var response = new Response();
response.Dial(Dial.Create(PhoneNumberToDial).Conference("conference"));
Assert.True(IsValidInboundXML(response.CreateXml()));
}
开发者ID:TelAPI,项目名称:telapi-dotnet,代码行数:7,代码来源:ConferenceTest.cs
示例17: Execute
private static Response Execute(String args)
{
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo()
{
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
FileName = SvnAdminPath,
Arguments = args
};
process.Start();
var response = new Response()
{
StandardOutput = process.StandardOutput.ReadToEnd(),
StandardError = process.StandardError.ReadToEnd()
};
process.WaitForExit();
if (response.StandardError != "")
throw new Exception(response.StandardError);
return response;
}
}
开发者ID:CodeGarten,项目名称:CodeGarten,代码行数:30,代码来源:SVNAdmin.cs
示例18: 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
示例19: CreatePlayer
public Response<Player> CreatePlayer(Player player)
{
var response = new Response<Player>();
var players = _repo.GetAllPlayersByTeam(player.TeamID);
try
{
foreach (var p in players)
{
if (player.PlayerName == p.PlayerName)
{
response.Success = false;
response.Message = "That player already exists!";
return response;
}
}
_repo.CreatePlayer(player);
response.Success = true;
response.Message = "Successfully created player";
}
catch (Exception ex)
{
response.Success = false;
response.Message = ex.Message;
}
return response;
}
开发者ID:amdenne,项目名称:SWGuildProjects,代码行数:27,代码来源:BaseballLeagueManager.cs
示例20: 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
注:本文中的Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论