Skip to content

Commit 14da6c2

Browse files
authored
Allow for null hint proxies to be returned. (#2438)
1 parent 77b69e8 commit 14da6c2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

MaterialDesignThemes.Wpf/HintProxyFabric.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public HintProxyBuilder(Func<Control?, bool> canBuild, Func<Control, IHintProxy>
1919
}
2020

2121
public bool CanBuild(Control? control) => _canBuild(control);
22-
public IHintProxy Build(Control control) => _build(control);
22+
public IHintProxy? Build(Control control) => _build(control);
2323
}
2424

2525
private static readonly List<HintProxyBuilder> Builders = new List<HintProxyBuilder>();
@@ -35,13 +35,11 @@ static HintProxyFabric()
3535
public static void RegisterBuilder(Func<Control?, bool> canBuild, Func<Control, IHintProxy> build)
3636
=> Builders.Add(new HintProxyBuilder(canBuild, build));
3737

38-
public static IHintProxy Get(Control? control)
38+
public static IHintProxy? Get(Control? control)
3939
{
40+
if (control is null) return null;
4041
var builder = Builders.FirstOrDefault(v => v.CanBuild(control));
41-
42-
if (builder is null) throw new NotImplementedException();
43-
44-
return builder.Build(control!);
42+
return builder?.Build(control);
4543
}
4644
}
4745
}

0 commit comments

Comments
 (0)