Exemple #1
0
 public static void Register <T>(UnmanagedFormatterDelegate <T> formatter)
     where T : unmanaged
 {
     lock (_unmanagedStructs)
     {
         _unmanagedStructs[typeof(T).TypeHandle.Value]  = (b, vp, view) => FormatterGeneric(b, vp, view, formatter);
         _unmanagedStructs[typeof(T?).TypeHandle.Value] = (b, vp, view) => FormatterGenericNullable(b, vp, view, formatter);
     }
 }
Exemple #2
0
        public static void Register <T>()
            where T : unmanaged, IStringFormattable
        {
            UnmanagedFormatterDelegate <T> formatter = (ref T input, StringBuffer buffer, StringView view) => input.Format(buffer, view);

            lock (_unmanagedStructs)
            {
                _unmanagedStructs[typeof(T).TypeHandle.Value]  = (b, vp, view) => FormatterGeneric(b, vp, view, formatter);
                _unmanagedStructs[typeof(T?).TypeHandle.Value] = (b, vp, view) => FormatterGenericNullable(b, vp, view, formatter);
            }
        }
Exemple #3
0
 public static void RegisterUnmanaged <T>(UnmanagedFormatterDelegate <T> formatter)
     where T : unmanaged
 => UnmanagedCache.Register(formatter);
Exemple #4
0
 private static void FormatterGenericNullable <T>(StringBuffer stringBuffer, byte *valuePtr, StringView view, UnmanagedFormatterDelegate <T> typedFormatter)
     where T : unmanaged
 {
     ref var typedValueRef = ref UnsafeTools.AsRef <T?>(valuePtr);
Exemple #5
0
 private static void FormatterGeneric <T>(StringBuffer stringBuffer, byte *valuePtr, StringView view, UnmanagedFormatterDelegate <T> typedFormatter)
     where T : unmanaged
 {
     typedFormatter?.Invoke(ref UnsafeTools.AsRef <T>(valuePtr), stringBuffer, view);
 }