public static IMessagePathId BuildViaTimesLimitPath <TMessage>(this Window window, string description, LogEnum logType, int viaTimesLimit, Type location, PathPriority priority, Action <TMessage> path) where TMessage : IMessage { if (WpfUtil.IsInDesignMode) { return(null); } if (window.Resources == null) { window.Resources = new ResourceDictionary(); } List <IMessagePathId> messagePathIds = (List <IMessagePathId>)window.Resources[messagePathIdsResourceKey]; if (messagePathIds == null) { messagePathIds = new List <IMessagePathId>(); window.Resources.Add(messagePathIdsResourceKey, messagePathIds); window.Closed += UiElement_Closed;; } var messagePathId = VirtualRoot.BuildViaTimesLimitPath(description, logType, viaTimesLimit, location, priority, path); messagePathIds.Add(messagePathId); return(messagePathId); }