Skip to content

Commit 55b4f05

Browse files
committed
MET-4188 add extension method with serviceProvider function
this function allows access to serviceProvider to build/get options from there
1 parent 0ef1cfd commit 55b4f05

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/Samhammer.AspNetCore.HealthChecks.FilesystemDirectory/DirectoryHealthCheckBuilderExtensions.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public static IHealthChecksBuilder AddDirectory(
1111
this IHealthChecksBuilder builder,
1212
Action<DirectoryHealthCheckOptions> configure,
1313
string name = "directoryHealthCheck",
14-
HealthStatus? failureStatus = default,
15-
IEnumerable<string> tags = default,
16-
TimeSpan? timeout = default)
14+
HealthStatus? failureStatus = null,
15+
IEnumerable<string> tags = null,
16+
TimeSpan? timeout = null)
1717
{
1818
var options = new DirectoryHealthCheckOptions();
1919
configure(options);
@@ -25,5 +25,26 @@ public static IHealthChecksBuilder AddDirectory(
2525
tags,
2626
timeout));
2727
}
28+
29+
public static IHealthChecksBuilder AddDirectory(
30+
this IHealthChecksBuilder builder,
31+
Func<IServiceProvider, DirectoryHealthCheckOptions> optionsProvider,
32+
string name = "directoryHealthCheck",
33+
HealthStatus? failureStatus = null,
34+
IEnumerable<string> tags = null,
35+
TimeSpan? timeout = null)
36+
{
37+
return builder.Add(
38+
new HealthCheckRegistration(
39+
name,
40+
sp =>
41+
{
42+
var options = optionsProvider(sp);
43+
return new DirectoryHealthCheck(options);
44+
},
45+
failureStatus,
46+
tags,
47+
timeout));
48+
}
2849
}
2950
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
4+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
35
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prtg/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)