当前位置: 首页>>代码示例>>C#>>正文


C# Page.TrimEnd方法代码示例

本文整理汇总了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();
        }
开发者ID:TariqStuff,项目名称:ProfilesRNS,代码行数:53,代码来源:OpenSocialManager.cs

示例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();
        }
开发者ID:CTSIatUCSF,项目名称:ProfilesRNS10x-OpenSocial,代码行数:49,代码来源:OpenSocialManager.cs


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