public static IMessagePathId AddViaTimesLimitPath <TMessage>(this Window window, string description, LogEnum logType, Action <TMessage> action, int viaTimesLimit, Type location) 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.AddViaTimesLimitPath(description, logType, action, viaTimesLimit, location); messagePathIds.Add(messagePathId); return(messagePathId); }