コード例 #1
0
 protected internal string GetString(LexicalUnit unit, int maxLength)
 {
     if (IsFragmentEmpty(unit))
     {
         return(string.Empty);
     }
     if (IsContiguous(unit))
     {
         return(new string(buffer, unit.headOffset, GetLength(unit)));
     }
     if (stringBuildSink == null)
     {
         stringBuildSink = new StringBuildSink();
     }
     stringBuildSink.Reset(maxLength);
     this.WriteTo(unit, stringBuildSink);
     return(stringBuildSink.ToString());
 }
コード例 #2
0
 protected internal string GetString(ref Fragment fragment, int maxLength)
 {
     if (fragment.head == fragment.tail)
     {
         return(string.Empty);
     }
     if (IsContiguous(ref fragment))
     {
         return(new string(buffer, fragment.headOffset, GetLength(ref fragment)));
     }
     if (IsFragmentEmpty(ref fragment))
     {
         return(string.Empty);
     }
     if (stringBuildSink == null)
     {
         stringBuildSink = new StringBuildSink();
     }
     stringBuildSink.Reset(maxLength);
     this.WriteTo(ref fragment, stringBuildSink);
     return(stringBuildSink.ToString());
 }