public void Write(object instance, INodeWriter parentNode, Type referencedAsType)
        {
            var valueID  = valuesCache.Add(instance);
            var typeName = typeNamesCache.GetTypeName(instance.GetType());

            using (var arrayNode = ownerDocument.CreateArrayElement(
                       typeName, valueID, parentNode))
            {
                using (var itemsNode = ownerDocument.CreateItemsElement(arrayNode))
                {
                    foreach (var listItem in (IEnumerable)instance)
                    {
                        var itemType = listItem == null?instance.GetType().GetElementType() : listItem.GetType();

                        objectWriter.Write(listItem, itemsNode, itemType);
                    }
                }
            }
        }