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


C# MemBlock.GetString方法代码示例

本文整理汇总了C#中Brunet.MemBlock.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# MemBlock.GetString方法的具体用法?C# MemBlock.GetString怎么用?C# MemBlock.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Brunet.MemBlock的用法示例。


在下文中一共展示了MemBlock.GetString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextTranslate

 /// <summary>
 /// This method replaces IP addresses based on some identifier
 /// </summary>
 /// <param name="payload">Payload to be translated</param>
 /// <param name="old_ss_ip">Old source IP address</param>
 /// <param name="old_sd_ip">Old destination IP</param>
 /// <param name="new_ss_ip">New source IP address</param>
 /// <param name="new_sd_ip">New destination IP address</param>
 /// <param name="packet_id">A packet identifier</param>
 /// <returns>A MemBlock of the translated payload</returns>
 public static MemBlock TextTranslate(MemBlock payload, string old_ss_ip,
                                  string old_sd_ip, string new_ss_ip,
                                  string new_sd_ip, string packet_id)
 {
     string sdata = payload.GetString(System.Text.Encoding.UTF8);
       if(sdata.Contains(packet_id)) {
     sdata = sdata.Replace(old_ss_ip, new_ss_ip);
     sdata = sdata.Replace(old_sd_ip, new_sd_ip);
     payload = MemBlock.Reference(System.Text.Encoding.UTF8.GetBytes(sdata));
       }
       return payload;
 }
开发者ID:arjunprakash84,项目名称:ipop,代码行数:22,代码来源:ManagedNodeHelper.cs

示例2: ReadString

 public static string ReadString(MemBlock b, int offset, out int bytelength)
 {
   int null_idx = b.IndexOf(0, offset);
   int raw_length = null_idx - offset;
   bytelength = raw_length + 1; //One for the null
   Encoding e;
   /*
    * Benchmarks of mono show this to be about twice as fast as just
    * using UTF8.  That really means UTF8 could be optimized in mono
    */
   if( b.IsAscii(offset, raw_length) ) {
     e = Encoding.ASCII;
   } else {
     e = Encoding.UTF8;
   }
   return b.GetString(e, offset, raw_length);
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:17,代码来源:NumberSerializer.cs


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