namespace MyOffice.Core.Helpers
{
	using System.Text.Json;
	using System.Text.Json.Serialization;

	public static class JsonHelper
	{
		public static string ToJson(this object entity, JsonSerializerOptions? options = null)
		{
			options ??= new JsonSerializerOptions
			{
				MaxDepth = 0,
				DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
				ReferenceHandler = ReferenceHandler.IgnoreCycles,
				WriteIndented = true,
			};
			return JsonSerializer.Serialize(entity, options);
		}
	}

	/*public class CustomIgnoreReferenceHandler : ReferenceHandler
	{
		//public CustomIgnoreReferenceHandler() => HandlingStrategy = ReferenceHandlingStrategy.IgnoreCycles;
		public CustomIgnoreReferenceHandler()
		{
			new HandlingStrategy { } = true;
		}

		public override ReferenceResolver CreateResolver() => new IgnoreReferenceResolver();
	}*/
}
