mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +00:00
refactor: Removing redundant code
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using ICD.Common.Properties;
|
||||||
using System.Collections.Generic;
|
using ICD.Common.Utils.Json;
|
||||||
using System.Text;
|
|
||||||
using ICD.Common.Properties;
|
|
||||||
|
|
||||||
namespace ICD.Common.Utils
|
namespace ICD.Common.Utils
|
||||||
{
|
{
|
||||||
@@ -13,72 +11,16 @@ namespace ICD.Common.Utils
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void PrintLine<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
|
public static void PrintLine([CanBeNull] object value)
|
||||||
{
|
{
|
||||||
if (dictionary == null)
|
string serial = ToString(value);
|
||||||
throw new ArgumentNullException("dictionary");
|
IcdConsole.PrintLine(serial);
|
||||||
|
|
||||||
IcdConsole.PrintLine(ToString(dictionary));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void PrintLine<T>(IEnumerable<T> sequence)
|
public static string ToString([CanBeNull] object value)
|
||||||
{
|
{
|
||||||
if (sequence == null)
|
return JsonUtils.Format(value);
|
||||||
throw new ArgumentNullException("sequence");
|
|
||||||
|
|
||||||
IcdConsole.PrintLine(ToString(sequence));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PublicAPI]
|
|
||||||
public static string ToString<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
|
|
||||||
{
|
|
||||||
if (dictionary == null)
|
|
||||||
throw new ArgumentNullException("dictionary");
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.AppendLine("{");
|
|
||||||
|
|
||||||
foreach (KeyValuePair<TKey, TValue> kvp in dictionary)
|
|
||||||
{
|
|
||||||
builder.Append('\t');
|
|
||||||
builder.Append(ToString(kvp.Key));
|
|
||||||
builder.Append(" : ");
|
|
||||||
builder.Append(ToString(kvp.Value));
|
|
||||||
builder.Append(',');
|
|
||||||
builder.AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Append("}");
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
[PublicAPI]
|
|
||||||
public static string ToString<T>(IEnumerable<T> sequence)
|
|
||||||
{
|
|
||||||
if (sequence == null)
|
|
||||||
throw new ArgumentNullException("sequence");
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.AppendLine("[");
|
|
||||||
|
|
||||||
foreach (T item in sequence)
|
|
||||||
{
|
|
||||||
builder.Append('\t');
|
|
||||||
builder.Append(ToString(item));
|
|
||||||
builder.Append(',');
|
|
||||||
builder.AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Append("]");
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
[PublicAPI]
|
|
||||||
public static string ToString<T>(T value)
|
|
||||||
{
|
|
||||||
// ReSharper disable once CompareNonConstrainedGenericWithNull
|
|
||||||
return StringUtils.ToRepresentation(value == null ? null : value.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user