using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace JsonRPC4.Router.Utilities { public class RpcUtil { public static bool TypesMatch(object value, Type type) { Type underlyingType = Nullable.GetUnderlyingType(type); if (underlyingType != null) { type = underlyingType; } return value?.GetType() == type; } public static bool NamesMatch(ReadOnlySpan actual, ReadOnlySpan requested) { if (actual.Length > requested.Length) { return false; } int num = 0; for (int i = 0; i < actual.Length; i++) { //char c = (char)(*(ushort*)requested.get_Item(num++)); char c = requested[num++];//(char)(*(ushort*)requested.get_Item(num++)); //if (char.ToLower((char)(*(ushort*)actual.get_Item(i))) != char.ToLower(c)) if(char.ToLower(actual[i])!=char.ToLower(c)) { if (c != '-' && c != '_') { return false; } i--; } } return num == actual.Length; } } }