Exemple #1
0
        public static bool TryFormat(object?value,
                                     Span <char> destination,
                                     out int charsWritten,
                                     ReadOnlySpan <char> format = default,
                                     IFormatProvider?provider   = null)
        {
            if (value is null)
            {
                charsWritten = 0;
                return(true);
            }

            var tryFormat = _tryFormatCache.GetOrAdd(value.GetType(), CreateTryFormatDelegate);

            return(tryFormat(value, destination, out charsWritten, format, provider));
        }
Exemple #2
0
 public static IEqualityComparer DefaultEqualityComparer(Type?type)
 {
     return(_equalityCache.GetOrAdd(type ?? typeof(object), GetEqualityComparerForType));
 }
Exemple #3
0
 internal static MethodInfo GetCloneMethod(Type type)
 {
     Debug.Assert(type != null);
     return(_cloneMethods.GetOrAdd(type, FindCloneMethod));
 }