本文整理汇总了C#中Value.ToBool方法的典型用法代码示例。如果您正苦于以下问题:C# Value.ToBool方法的具体用法?C# Value.ToBool怎么用?C# Value.ToBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Value
的用法示例。
在下文中一共展示了Value.ToBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Nils
public void Nils()
{
var val = new Value();
Assert.IsTrue( val.IsNil );
Assert.IsFalse( val.ToBool() );
Assert.AreEqual( LValueType.Nil, val.ValueType );
val.Set( true );
Assert.IsFalse( val.IsNil );
val.Set( Value.Nil );
Assert.IsTrue( val.IsNil );
val = new Value();
Assert.IsTrue( val.IsNil );
val = Value.Nil;
Assert.IsTrue( val.IsNil );
val.Set( true );
Assert.IsFalse( val.IsNil );
val.SetNil();
Assert.IsTrue( val.IsNil );
}
示例2: SGsub
//.........这里部分代码省略.........
break;
case LValueType.String:
//need to handle escape sequences
{
var sb = (byte[])subst.RefVal;
for( int i = LString.BufferDataOffset; i < sb.Length; i++ )
{
var ch = sb[i];
if( ch != (byte)'%' )
{
strBuilder.Append( ch );
continue;
}
if( ++i == sb.Length )
throw new ArgumentException( "Invalid use of % in replacement string" );
ch = sb[i];
if( ch == (byte)'%' )
{
strBuilder.Append( ch );
continue;
}
switch( ch )
{
case (byte)'0':
strBuilder.Append( ms.Str, sPos, e - sPos );
break;
case (byte)'1':
case (byte)'2':
case (byte)'3':
case (byte)'4':
case (byte)'5':
case (byte)'6':
case (byte)'7':
case (byte)'8':
case (byte)'9':
{
int idx = ch - (byte)'1';
PushCapture( ref ms, idx, sPos, e );
substVal = l.PopValue();
l.ConvertToString( ref substVal );
strBuilder.Append( (LString)substVal );
}
break;
default:
throw new ArgumentException( "Invalid use o f% in replacement string" );
}
}
}
substVal = new Value(); //hush, little compiler
break;
default:
substVal = new Value();
break;
}
if( subTy != LValueType.String )
{
//strings already appended, need to handle this case now
if( !substVal.ToBool() )
{
strBuilder.Append( ms.Str, sPos, e - sPos );
}
else
{
l.ConvertToString( ref substVal );
strBuilder.Append( (LString)substVal );
}
}
}
if( e != -1 && e > sPos )
sPos = e;
else if( sPos < ms.Str.Length )
strBuilder.Append( ms.Str[sPos++] );
else
break;
if( anchor )
break;
}
strBuilder.Append( ms.Str, sPos, ms.Str.Length - sPos );
var ret = strBuilder.ToLString();
l.RetireStrBuilder( strBuilder );
RetireMatchState( ref ms );
return l.SetReturnValues( ret, n );
}