本文整理汇总了C#中System.Web.UI.Page.TrimEnd方法的典型用法代码示例。如果您正苦于以下问题:C# Page.TrimEnd方法的具体用法?C# Page.TrimEnd怎么用?C# Page.TrimEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.Page
的用法示例。
在下文中一共展示了Page.TrimEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SocketSendReceive
private static string SocketSendReceive(string viewer, string owner, string gadget)
{
// These keys need to match what you see in edu.ucsf.profiles.shindig.service.SecureTokenGeneratorService in Shindig
string request = "c=default" + (viewer != null ? "&v=" + HttpUtility.UrlEncode(viewer) : "") +
(owner != null ? "&o=" + HttpUtility.UrlEncode(owner) : "") + (gadget != null ? "&u=" + HttpUtility.UrlEncode(gadget) : "") + "\r\n";
Byte[] bytesSent = System.Text.Encoding.ASCII.GetBytes(request);
Byte[] bytesReceived = new Byte[256];
// Create a socket connection with the specified server and port.
//Socket s = ConnectSocket(tokenService[0], Int32.Parse(tokenService[1]));
// during startup we might fail a few times, so be will to retry
string page = "";
for (int i = 0; i < 3 && page.Length == 0; i++)
{
CustomSocket s = null;
try
{
s = sockets.GetSocket();
if (s == null)
return ("Connection failed");
// Send request to the server.
DebugLogging.Log("Sending Bytes");
s.Send(bytesSent);
// Receive the server home page content.
int bytes = 0;
// The following will block until the page is transmitted.
// we recognize the end of the message when the Trim drops the length by removing the EOL
do
{
DebugLogging.Log("Receiving Bytes");
bytes = s.Receive(bytesReceived);
page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
DebugLogging.Log("Socket Page=" + page + "|");
}
while (page.Length == page.TrimEnd().Length && bytes > 0);
}
catch (Exception ex)
{
DebugLogging.Log("Socket Error :" + ex.Message);
page = "";
}
finally
{
if (sockets != null && s != null) sockets.PutSocket(s);
}
}
return page.TrimEnd();
}
示例2: SocketSendReceive
private static string SocketSendReceive(string viewer, string owner, string gadget)
{
// These keys need to match what you see in edu.ucsf.profiles.shindig.service.SecureTokenGeneratorService in Shindig
string[] tokenService = ConfigurationManager.AppSettings["OpenSocial.TokenService"].ToString().Trim().Split(':');
string request = "c=default" + (viewer != null ? "&v=" + HttpUtility.UrlEncode(viewer) : "") +
(owner != null ? "&o=" + HttpUtility.UrlEncode(owner) : "") + "&g=" + HttpUtility.UrlEncode(gadget) + "\r\n";
Byte[] bytesSent = Encoding.ASCII.GetBytes(request);
Byte[] bytesReceived = new Byte[256];
// Create a socket connection with the specified server and port.
//Socket s = ConnectSocket(tokenService[0], Int32.Parse(tokenService[1]));
CustomSocket s = null;
string page = "";
try
{
s = sockets.GetSocket();
if (s == null)
return ("Connection failed");
// Send request to the server.
DebugLogging.Log("Sending Bytes");
s.Send(bytesSent, bytesSent.Length, 0);
// Receive the server home page content.
int bytes = 0;
// The following will block until te page is transmitted.
do
{
DebugLogging.Log("Receiving Bytes");
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
DebugLogging.Log("Socket Page=" + page + "|");
}
while (page.Length == page.TrimEnd().Length && bytes > 0);
}
catch (Exception ex)
{
DebugLogging.Log("Socket Error :" + ex.Message);
}
finally
{
sockets.PutSocket(s);
}
return page.TrimEnd();
}