mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 02:31:22 +00:00
Plugged Boolean.Parse(string) and Boolean.TryParse(string, out bool)
Added methodname displaying in build GUI again
This commit is contained in:
parent
48646d171e
commit
998e3dd16c
4 changed files with 91 additions and 11 deletions
|
|
@ -27,7 +27,7 @@ namespace FrodeTest
|
|||
{
|
||||
//while (true)
|
||||
//Console.Beep(2000, 2);
|
||||
Console.Beep();
|
||||
//Console.Beep();
|
||||
//Cosmos.Hardware.PIT.PlaySound(3000);
|
||||
//Console.Beep();
|
||||
//Shell.Session.Run();
|
||||
|
|
@ -54,7 +54,7 @@ namespace FrodeTest
|
|||
//Test.BasicTest.RunTest();
|
||||
//Test.SwitchTest.RunTest();
|
||||
//Console.ReadLine();
|
||||
//Test.BoolTest.RunTest();
|
||||
Test.BoolTest.RunTest();
|
||||
//Test.InterfaceTest.RunTest();
|
||||
//Test.ExtensionMethodsTest.RunTest();
|
||||
//Test.BinaryHelperTest.RunTest();
|
||||
|
|
|
|||
|
|
@ -14,8 +14,52 @@ namespace FrodeTest.Test
|
|||
Console.WriteLine("true.ToString() gives: " + yes.ToString());
|
||||
Console.WriteLine("false.ToString() gives: " + no.ToString());
|
||||
|
||||
|
||||
//Testing returntype
|
||||
CompareNullReturnFalse();
|
||||
|
||||
//Testing parsing
|
||||
Check.Text = "Bool Parse";
|
||||
if (Boolean.Parse("True"))
|
||||
Check.OK();
|
||||
else
|
||||
Check.Fail();
|
||||
|
||||
//if (Boolean.Parse("tRUE")) //Doesn't work because of .Equals(string, StringComparison)
|
||||
// Check.OK();
|
||||
//else
|
||||
// Check.Fail();
|
||||
|
||||
if (Boolean.Parse("False"))
|
||||
Check.Fail();
|
||||
else
|
||||
Check.OK();
|
||||
|
||||
try
|
||||
{
|
||||
Check.Text = "ArgumentNull check";
|
||||
Boolean.Parse(null);
|
||||
Check.Fail();
|
||||
}
|
||||
catch (ArgumentNullException)
|
||||
{
|
||||
Check.OK();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Check.Fail();
|
||||
}
|
||||
|
||||
Check.Text = "TryParse";
|
||||
bool result = false;
|
||||
Boolean.TryParse("True", out result);
|
||||
if (result)
|
||||
Check.OK();
|
||||
else
|
||||
Check.Fail();
|
||||
|
||||
Check.Text = "TryParseShouldGiveFalse";
|
||||
if (!Boolean.TryParse("blabla", out result))
|
||||
Check.OK();
|
||||
}
|
||||
|
||||
public static bool CompareNullReturnFalse()
|
||||
|
|
|
|||
|
|
@ -7,13 +7,49 @@ using Indy.IL2CPU.Plugs;
|
|||
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||
[Plug(Target=typeof(bool))]
|
||||
public static class BooleanImpl {
|
||||
public static string ToString(ref bool aThis) {
|
||||
if (aThis) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
//NOTE; Not used any more??
|
||||
//public static string ToString(ref Boolean aThis)
|
||||
//{
|
||||
// if (aThis)
|
||||
// {
|
||||
// return "true";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "false";
|
||||
// }
|
||||
//}
|
||||
|
||||
public static bool Parse(string aBoolText)
|
||||
{
|
||||
if (aBoolText == null)
|
||||
throw new ArgumentNullException("aBoolText");
|
||||
|
||||
Boolean xResult = false;
|
||||
if (!Boolean.TryParse(aBoolText, out xResult))
|
||||
{
|
||||
throw new FormatException("String was not recognized as a valid Boolean.");
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
|
||||
public static bool TryParse(string aBoolText, out Boolean aResult)
|
||||
{
|
||||
aResult = false;
|
||||
|
||||
//Currently .Equals(string, StringComparison) does not work, so only exactly "True" and "False" work. Not "true", "tRuE" etc.
|
||||
if ("True".Equals(aBoolText, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
aResult = true;
|
||||
return true;
|
||||
}
|
||||
else if ("False".Equals(aBoolText, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
aResult = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ namespace Indy.IL2CPU {
|
|||
return mProgressMessage;
|
||||
}
|
||||
set {
|
||||
//mProgressMessage = value;
|
||||
mProgressMessage = value;
|
||||
OnProgressChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue