Skip to content

Commit

Permalink
Adding CustomValuesGenerators for Dumpify
Browse files Browse the repository at this point in the history
  • Loading branch information
MoaidHathot committed May 17, 2023
1 parent a8ac3f1 commit eff799b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Dumpify/Descriptors/Generators/CustomValuesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public CustomValuesGenerator(ConcurrentDictionary<RuntimeTypeHandle, Func<object
_customTypeHandlers.TryAdd(typeof(StringBuilder).TypeHandle, (obj, type, valueProvider, memberProvider) => ((StringBuilder)obj).ToString());
_customTypeHandlers.TryAdd(typeof(DateTime).TypeHandle, (obj, type, valueProvider, memberProvider) => ((DateTime)obj).ToString(CultureInfo.CurrentCulture));
_customTypeHandlers.TryAdd(typeof(DateTimeOffset).TypeHandle, (obj, type, valueProvider, memberProvider) => ((DateTimeOffset)obj).ToString());
_customTypeHandlers.TryAdd(typeof(Guid).TypeHandle, (obj, type, valueProvider, memberProvider) => ((Guid)obj).ToString());

#if NET6_0_OR_GREATER
_customTypeHandlers.TryAdd(typeof(DateOnly).TypeHandle, (obj, type, valueProvider, memberProvider) => ((DateOnly)obj).ToString());
Expand All @@ -70,11 +71,11 @@ public CustomValuesGenerator(ConcurrentDictionary<RuntimeTypeHandle, Func<object
return new CustomDescriptor(type, valueProvider);
}

if(_customTypeHandlers.ContainsKey(type.TypeHandle))
if (_customTypeHandlers.ContainsKey(type.TypeHandle))
{
return new CustomDescriptor(type, valueProvider);
}

return null;
}
}
}

0 comments on commit eff799b

Please sign in to comment.