@@ -11,7 +11,9 @@ public static class IMuninServiceBuilderExtensions {
1111 /// <summary>
1212 /// Adds a <c>Munin-Node</c> to the <see cref="IMuninServiceBuilder"/> with default configurations.
1313 /// </summary>
14- /// <param name="builder">An <see cref="IMuninNodeBuilder"/> to build the <c>Munin-Node</c> to be added.</param>
14+ /// <param name="builder">
15+ /// An <see cref="IMuninServiceBuilder"/> that the built <c>Munin-Node</c> will be added to.
16+ /// </param>
1517 /// <returns>The current <see cref="IMuninNodeBuilder"/> so that additional calls can be chained.</returns>
1618 public static IMuninNodeBuilder AddNode (
1719 this IMuninServiceBuilder builder
@@ -25,7 +27,7 @@ this IMuninServiceBuilder builder
2527 /// Adds a <c>Munin-Node</c> to the <see cref="IMuninServiceBuilder"/> with specified configurations.
2628 /// </summary>
2729 /// <param name="builder">
28- /// An <see cref="IMuninNodeBuilder "/> to build the <c>Munin-Node</c> to be added.
30+ /// An <see cref="IMuninServiceBuilder "/> that the built <c>Munin-Node</c> will be added to .
2931 /// </param>
3032 /// <param name="configure">
3133 /// An <see cref="Action{MuninNodeOptions}"/> to setup <see cref="MuninNodeOptions"/> to
@@ -36,29 +38,48 @@ public static IMuninNodeBuilder AddNode(
3638 this IMuninServiceBuilder builder ,
3739 Action < MuninNodeOptions > configure
3840 )
41+ => AddNode < MuninNodeOptions > (
42+ builder : builder ?? throw new ArgumentNullException ( nameof ( builder ) ) ,
43+ configure : configure ?? throw new ArgumentNullException ( nameof ( configure ) )
44+ ) ;
45+
46+ /// <summary>
47+ /// Adds a <c>Munin-Node</c> to the <see cref="IMuninServiceBuilder"/> with specified configurations.
48+ /// </summary>
49+ /// <typeparam name="TMuninNodeOptions">
50+ /// The extended type of <see cref="MuninNodeOptions"/> to configure the <c>Munin-Node</c>.
51+ /// </typeparam>
52+ /// <param name="builder">
53+ /// An <see cref="IMuninServiceBuilder"/> that the built <c>Munin-Node</c> will be added to.
54+ /// </param>
55+ /// <param name="configure">
56+ /// An <see cref="Action{TMuninNodeOptions}"/> to setup <typeparamref name="TMuninNodeOptions"/> to
57+ /// configure the <c>Munin-Node</c> to be built.
58+ /// </param>
59+ /// <returns>The current <see cref="IMuninNodeBuilder"/> so that additional calls can be chained.</returns>
60+ public static IMuninNodeBuilder AddNode < TMuninNodeOptions > (
61+ this IMuninServiceBuilder builder ,
62+ Action < TMuninNodeOptions > configure
63+ )
64+ where TMuninNodeOptions : MuninNodeOptions , new ( )
3965 {
4066 if ( builder is null )
4167 throw new ArgumentNullException ( nameof ( builder ) ) ;
4268 if ( configure is null )
4369 throw new ArgumentNullException ( nameof ( configure ) ) ;
4470
45- var options = new MuninNodeOptions ( ) ;
71+ var configuredOptions = new TMuninNodeOptions ( ) ;
4672
47- configure ( options ) ;
73+ configure ( configuredOptions ) ;
4874
4975 var nodeBuilder = new MuninNodeBuilder (
5076 serviceBuilder : builder ,
51- serviceKey : options . HostName // use configured hostname as a service key and option name
77+ serviceKey : configuredOptions . HostName // use configured hostname as a service key and option name
5278 ) ;
5379
54- _ = builder . Services . Configure < MuninNodeOptions > (
80+ _ = builder . Services . Configure < TMuninNodeOptions > (
5581 name : nodeBuilder . ServiceKey , // configure MuninNodeOptions for this builder
56- opts => {
57- opts . Address = options . Address ;
58- opts . Port = options . Port ;
59- opts . HostName = options . HostName ;
60- opts . AccessRule = options . AccessRule ;
61- }
82+ options => options . Configure ( configuredOptions )
6283 ) ;
6384
6485 builder . Services . Add (
0 commit comments