public void RenderObject()

in src/log4net/ObjectRenderer/DefaultRenderer.cs [129:185]


  public void RenderObject(RendererMap rendererMap, object? obj, TextWriter writer)
  {
    rendererMap.EnsureNotNull();
    writer.EnsureNotNull();

    if (obj is null)
    {
      writer.Write(SystemInfo.NullText);
      return;
    }

    if (obj is Array objArray)
    {
      RenderArray(rendererMap, objArray, writer);
      return;
    }

    // Test if we are dealing with some form of collection object
    if (obj is IEnumerable objEnumerable)
    {
      // Get a collection interface if we can as its .Count property may be more
      // performant than getting the IEnumerator object and trying to advance it.
      if (obj is ICollection objCollection && objCollection.Count == 0)
      {
        writer.Write("{}");
        return;
      }

      // This is a special check to allow us to get the enumerator from the IDictionary
      // interface as this guarantees us DictionaryEntry objects. Note that in .NET 2.0
      // the generic IDictionary<> interface enumerates KeyValuePair objects rather than
      // DictionaryEntry ones. However the implementation of the plain IDictionary 
      // interface on the generic Dictionary<> still returns DictionaryEntry objects.
      if (obj is IDictionary objDictionary)
      {
        RenderEnumerator(rendererMap, objDictionary.GetEnumerator(), writer);
        return;
      }

      RenderEnumerator(rendererMap, objEnumerable.GetEnumerator(), writer);
      return;
    }

    if (obj is IEnumerator objEnumerator)
    {
      RenderEnumerator(rendererMap, objEnumerator, writer);
      return;
    }

    if (obj is DictionaryEntry entry)
    {
      RenderDictionaryEntry(rendererMap, entry, writer);
      return;
    }

    writer.Write(obj.ToString() ?? SystemInfo.NullText);
  }