mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 14:02:19 +00:00
Merge branch 'Cyber4-master'
t push origin master
This commit is contained in:
commit
24c73995d6
1 changed files with 161 additions and 29 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
using Cosmos.Common;
|
using Cosmos.Common;
|
||||||
using Cosmos.Debug.Kernel;
|
using Cosmos.Debug.Kernel;
|
||||||
using Cosmos.IL2CPU.Plugs;
|
using Cosmos.IL2CPU.Plugs;
|
||||||
|
|
||||||
namespace Cosmos.Core.Plugs.System
|
namespace Cosmos.Core.Plugs.System
|
||||||
{
|
{
|
||||||
|
|
@ -212,9 +212,9 @@ namespace Cosmos.Core.Plugs.System
|
||||||
else if (xCharArray[i] == '{')
|
else if (xCharArray[i] == '{')
|
||||||
{
|
{
|
||||||
mDebugger.SendInternal("Found opening placeholder");
|
mDebugger.SendInternal("Found opening placeholder");
|
||||||
xFoundPlaceholder = true;
|
xFoundPlaceholder = true;
|
||||||
xParamNumberDone = false;
|
xParamNumberDone = false;
|
||||||
xParamNumber = string.Empty;
|
xParamNumber = string.Empty;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -227,7 +227,82 @@ namespace Cosmos.Core.Plugs.System
|
||||||
|
|
||||||
public static bool StartsWith(string aThis, string aSubstring, StringComparison aComparison)
|
public static bool StartsWith(string aThis, string aSubstring, StringComparison aComparison)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
Char[] di = aThis.ToCharArray();
|
||||||
|
Char[] ci = aSubstring.ToCharArray();
|
||||||
|
if (aSubstring.Length > aThis.Length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < ci.Length; i++)
|
||||||
|
{
|
||||||
|
if (di[i] != ci[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//String concatenation plugs
|
||||||
|
public static string Concat(string str0)
|
||||||
|
{
|
||||||
|
return str0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(string str0, string str1)
|
||||||
|
{
|
||||||
|
return Concat(new[] { str0, str1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(string str0, string str1, string str2)
|
||||||
|
{
|
||||||
|
return Concat(new[] { str0, str1, str2 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(string str0, string str1, string str2, string str3)
|
||||||
|
{
|
||||||
|
return Concat(new[] { str0, str1, str2, str3 });
|
||||||
|
}
|
||||||
|
|
||||||
|
//Object concatenation plugs
|
||||||
|
public static string Concat(object obj0)
|
||||||
|
{
|
||||||
|
return obj0?.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(object obj0, object obj1)
|
||||||
|
{
|
||||||
|
return Concat(obj0?.ToString(), obj1?.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(object obj0, object obj1, object obj2)
|
||||||
|
{
|
||||||
|
return Concat(obj0?.ToString(), obj1?.ToString(), obj2?.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Concat(object obj0, object obj1, object obj2, object obj3)
|
||||||
|
{
|
||||||
|
return Concat(new[] { obj0?.ToString(), obj1?.ToString(), obj2?.ToString(), obj3?.ToString() });
|
||||||
|
}
|
||||||
|
|
||||||
|
//Array concatenation plugs
|
||||||
|
public static string Concat(params string[] values)
|
||||||
|
{
|
||||||
|
if (values != null)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
for (int i = 0; i < values.Length; i++)
|
||||||
|
{
|
||||||
|
string xValue = values[i];
|
||||||
|
if (xValue != null)
|
||||||
|
{
|
||||||
|
len += values[i].Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ConcatArray(values, len);
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string PadHelper(string aThis, int totalWidth, char paddingChar, bool isRightPadded)
|
public static string PadHelper(string aThis, int totalWidth, char paddingChar, bool isRightPadded)
|
||||||
|
|
@ -463,11 +538,36 @@ namespace Cosmos.Core.Plugs.System
|
||||||
|
|
||||||
public static bool Contains(string aThis, string value)
|
public static bool Contains(string aThis, string value)
|
||||||
{
|
{
|
||||||
if (aThis.IndexOf(value) != -1)
|
Char[] di = aThis.ToCharArray();
|
||||||
|
Char[] ci = value.ToCharArray();
|
||||||
|
if (value.Length == aThis.Length)
|
||||||
{
|
{
|
||||||
|
if (value == aThis)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(value.Length > aThis.Length) && (value.Length != aThis.Length))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < aThis.Length; i++)
|
||||||
|
{
|
||||||
|
if (di[i] == ci[0])
|
||||||
|
{
|
||||||
|
for (int j = 1; j < value.Length; j++)
|
||||||
|
{
|
||||||
|
if (di[i + j] != ci[j])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -478,31 +578,32 @@ namespace Cosmos.Core.Plugs.System
|
||||||
|
|
||||||
public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison)
|
public static bool EndsWith(string aThis, string aSubStr, StringComparison aComparison)
|
||||||
{
|
{
|
||||||
if (aSubStr == null)
|
Char[] di = aThis.ToCharArray();
|
||||||
|
Char[] ci = aSubStr.ToCharArray();
|
||||||
|
if (aThis.Length == aSubStr.Length)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("aSubStr");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aThis == aSubStr)
|
if (aThis == aSubStr)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
if (aSubStr.Length == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if (aThis.Length > aSubStr.Length)
|
||||||
int xLastIdx = aThis.Length - aSubStr.Length;
|
|
||||||
for (int i = 0; i < aSubStr.Length; i++)
|
|
||||||
{
|
{
|
||||||
if (aThis[xLastIdx + i] != aSubStr[i])
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = aThis.Length - aSubStr.Length; i < aThis.Length; i++)
|
||||||
|
{
|
||||||
|
if (di[aThis.Length - aSubStr.Length + i] != ci[i])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison)
|
// System.Int32 System.String.IndexOf(System.String, System.Int32, System.Int32, System.StringComparison)
|
||||||
|
|
||||||
|
|
@ -603,15 +704,15 @@ namespace Cosmos.Core.Plugs.System
|
||||||
{
|
{
|
||||||
mDebugger.SendInternal("nativeCompareOrdinalEx : aStrA is null");
|
mDebugger.SendInternal("nativeCompareOrdinalEx : aStrA is null");
|
||||||
if (aStrB == null)
|
if (aStrB == null)
|
||||||
{
|
{
|
||||||
mDebugger.SendInternal($"nativeCompareOrdinalEx : aStrB is null");
|
mDebugger.SendInternal($"nativeCompareOrdinalEx : aStrB is null");
|
||||||
mDebugger.SendInternal($"nativeCompareOrdinalEx : returning 0");
|
mDebugger.SendInternal($"nativeCompareOrdinalEx : returning 0");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mDebugger.SendInternal($"nativeCompareOrdinalEx : aStrB is not null");
|
mDebugger.SendInternal($"nativeCompareOrdinalEx : aStrB is not null");
|
||||||
mDebugger.SendInternal($"nativeCompareOrdinalEx : returning -1");
|
mDebugger.SendInternal($"nativeCompareOrdinalEx : returning -1");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (aStrB == null)
|
if (aStrB == null)
|
||||||
{
|
{
|
||||||
mDebugger.SendInternal("nativeCompareOrdinalEx : aStrA is not null");
|
mDebugger.SendInternal("nativeCompareOrdinalEx : aStrA is not null");
|
||||||
|
|
@ -651,11 +752,18 @@ namespace Cosmos.Core.Plugs.System
|
||||||
|
|
||||||
public static bool StartsWith(string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture)
|
public static bool StartsWith(string aThis, string aSubStr, bool aIgnoreCase, CultureInfo aCulture)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < aSubStr.Length; i++)
|
Char[] di = aThis.ToCharArray();
|
||||||
|
Char[] ci = aSubStr.ToCharArray();
|
||||||
|
if (aSubStr.Length > aThis.Length)
|
||||||
{
|
{
|
||||||
if (aThis[i] != aSubStr[i])
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < ci.Length; i++)
|
||||||
|
{
|
||||||
|
if (di[i] != ci[i])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -721,5 +829,29 @@ namespace Cosmos.Core.Plugs.System
|
||||||
{
|
{
|
||||||
return new string(new char[length]);
|
return new string(new char[length]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string TrimStart(string aThis, string aSubStr)
|
||||||
|
{
|
||||||
|
char[] ci = aThis.ToCharArray();
|
||||||
|
char[] di = aSubStr.ToCharArray();
|
||||||
|
|
||||||
|
if(aThis.StartsWith(aSubStr))
|
||||||
|
{
|
||||||
|
if(aThis != aSubStr)
|
||||||
|
{
|
||||||
|
char[] oi = new char[ci.Length - di.Length];
|
||||||
|
for(int i=0; i < ci.Length - di.Length; i++)
|
||||||
|
{
|
||||||
|
oi[i] = ci[i + di.Length];
|
||||||
|
}
|
||||||
|
return oi.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue