Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCraver committed Jul 24, 2016
1 parent dfdef4b commit e5a4992
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Opserver.Core/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static string TrimEnd(this string s, string toTrim) =>
/// </summary>
public static string ReadableTypeDescription(this Type t) =>
t.IsGenericType
? $"{t.Name.Split('`')[0]}<{string.Join(",", t.GetGenericArguments().Select(a => a.Name))}>"
? $"{t.Name.Split(StringSplits.Tilde)[0]}<{string.Join(",", t.GetGenericArguments().Select(a => a.Name))}>"
: t.Name;

/// <summary>
Expand Down Expand Up @@ -127,14 +127,10 @@ public static string Pluralize(this string noun, int number, string pluralForm =
/// force string to be maxlen or smaller
/// </summary>
public static string Truncate(this string s, int maxLength) =>
s.IsNullOrEmpty()
? s
: (s.Length > maxLength ? s.Remove(maxLength) : s);
s.IsNullOrEmpty() ? s : (s.Length > maxLength ? s.Remove(maxLength) : s);

public static string TruncateWithEllipsis(this string s, int maxLength) =>
s.IsNullOrEmpty() || s.Length <= maxLength
? s
: Truncate(s, Math.Max(maxLength, 3) - 3) + "...";
s.IsNullOrEmpty() || s.Length <= maxLength ? s : Truncate(s, Math.Max(maxLength, 3) - 3) + "…";

public static string CleanCRLF(this string s) =>
string.IsNullOrWhiteSpace(s)
Expand All @@ -157,7 +153,7 @@ public static string NormalizeHostOrFQDN(this string s, bool defaultToHttps = fa

public static IEnumerable<T> WithIssues<T>(this IEnumerable<T> items) where T : IMonitorStatus =>
items.Where(i => i.MonitorStatus != MonitorStatus.Good);

public static string GetReasonSummary(this IEnumerable<IMonitorStatus> items) =>
string.Join(", ", items.WithIssues().Select(i => i.MonitorStatusReason));

Expand Down
1 change: 1 addition & 0 deletions Opserver.Core/StringSplits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static readonly char[]
ForwardSlash = {'/'},
BackSlash = {'\\'},
DoubleQuote = {'"'},
Tilde = {'`'},
Period_Plus = {'.', '+'},
NewLine_CarriageReturn = {'\n', '\r'},
Comma_SemiColon = {',', ';'},
Expand Down
1 change: 1 addition & 0 deletions Opserver.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FOBJECT_005FPROPERTY_005FOF_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsParsFormattingSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>

0 comments on commit e5a4992

Please sign in to comment.