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


C# MemBlock.ToBase16String方法代码示例

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


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

示例1: ReceivedPacketEvent

 /**
  * This method is used by subclasses.
  * @param b the packet to send a ReceivedPacket event for
  */
 public void ReceivedPacketEvent(MemBlock b)
 {
   if( 1 == _is_closed ) {
     //We should not be receiving packets on closed edges:
     throw new EdgeClosedException(
                   String.Format("Trying to Receive on a Closed Edge: {0}",
                                 this) );
   }
   try {
     _sub.Handle(b, this);
     Interlocked.Exchange(ref _last_in_packet_datetime, DateTime.UtcNow.Ticks);
   }
   catch(System.NullReferenceException) {
     //this can happen if _sub is null
     //We don't record the time of this packet.  We don't
     //want unhandled packets to keep edges open.
     //
     //This packet is going into the trash:
     Console.Error.WriteLine("{0} lost packet {1}",this,b.ToBase16String());
   }
 }
开发者ID:xujyan,项目名称:brunet,代码行数:25,代码来源:Edge.cs

示例2: Parse

 /**
  * Parse the PType starting at mb, and return all of mb <b>after</b>
  * the PType.
  */
 public static PType Parse(MemBlock mb, out MemBlock rest) {
   PType result = null;
   byte fb = mb[0];
   bool is_v_n = IsValidNumeric( (int)fb );
   /**
    * Since ptypes must be valid UTF8 strings,
    * if the second byte is null, the first byte is an ascii character
    * and hence has a value less than ASCII_UPPER_BOUND 
    */
   bool store_in_tbl = ( is_v_n || (mb[1] == 0) );
   if( store_in_tbl ) {
     //This is stored in our table:
     result = _table[ fb ];
     if( result != null ) {
       if( is_v_n ) {
         //There is no null
         rest = mb.Slice(1);
       }
       else {
         //Skip the null
         rest = mb.Slice(2);
       }
       return result;
     }
   }
   //Otherwise we have to make it:
   MemBlock raw_data = null;
   result = new PType();
   if( is_v_n ) {
     /*
      * Don't set the raw_data since it is only one byte and we may not need
      * it
      */
     rest = mb.Slice(1);
     result._type_num = (int)fb;
   }
   else {
     int null_pos = mb.IndexOf(0);
     if( null_pos > 0 ) {
       //Include the "null", but make a copy so we don't keep some data in
       //scope for ever
       raw_data = MemBlock.Copy( (ICopyable)mb.Slice(0, null_pos + 1) );
       rest = mb.Slice(null_pos + 1); 
     }
     else {
       //There is no terminating Null, panic!!
       throw new ParseException(
         System.String.Format("PType not null terminated: {0}", mb.ToBase16String()));
     }
     result._type_num = -2;
     result._raw_data = raw_data;
   }
   if( store_in_tbl ) {
     //Make sure we don't have to create an object like this again
     _table[ fb ] = result;
   }
   return result;
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:62,代码来源:PType.cs


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