This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 183d51e8a5d81a955217d7a11af0047f7ba87ea2
Author: Shad Storhaug <[email protected]>
AuthorDate: Thu Dec 3 15:59:36 2020 +0700

    Lucene.Net.Documents.Document: Moved ToString(string, IFormatProvider) 
implementation to shared private method
---
 src/Lucene.Net/Document/Document.cs | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/Lucene.Net/Document/Document.cs 
b/src/Lucene.Net/Document/Document.cs
index 3c2d845..5324fb7 100644
--- a/src/Lucene.Net/Document/Document.cs
+++ b/src/Lucene.Net/Document/Document.cs
@@ -464,26 +464,19 @@ namespace Lucene.Net.Documents
         // LUCENENET specific - method added for better .NET compatibility
         private string ToString(string format, IFormatProvider provider)
         {
-            return (this as IFormattable).ToString(format, provider);
-        }
-
-        /// <summary>
-        /// Prints the fields of a document for human consumption. 
-        /// </summary>
-        /// <param name="format">A standard or custom numeric format string. 
This parameter has no effect if this field is non-numeric.</param>
-        /// <param name="provider">An object that supplies culture-specific 
formatting information. This parameter has no effect if this field is 
non-numeric.</param>
-        // LUCENENET specific - method added for better .NET compatibility
-        string IFormattable.ToString(string format, IFormatProvider provider)
-        {
             var buffer = new StringBuilder();
             buffer.Append("Document<");
             for (int i = 0; i < fields.Count; i++)
             {
                 IIndexableField field = fields[i];
                 if (field is IFormattable formattable)
+                {
                     buffer.Append(formattable.ToString(format, provider));
+                }
                 else
+                {
                     buffer.Append(field.ToString());
+                }
                 if (i != fields.Count - 1)
                 {
                     buffer.Append(" ");
@@ -492,5 +485,16 @@ namespace Lucene.Net.Documents
             buffer.Append(">");
             return buffer.ToString();
         }
+
+        /// <summary>
+        /// Prints the fields of a document for human consumption. 
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. 
This parameter has no effect if this field is non-numeric.</param>
+        /// <param name="provider">An object that supplies culture-specific 
formatting information. This parameter has no effect if this field is 
non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        string IFormattable.ToString(string format, IFormatProvider provider)
+        {
+            return ToString(format, provider);
+        }
     }
 }
\ No newline at end of file

Reply via email to