/// <summary> /// Try to get a suitable formatter. /// </summary> /// <param name="formattingInfo"></param> /// <exception cref="FormattingException"></exception> private void EvaluateFormatters(FormattingInfo formattingInfo) { var handled = InvokeFormatterExtensions(formattingInfo); if (!handled) { throw formattingInfo.FormattingException("No suitable Formatter could be found", formattingInfo.Format); } }
private void EvaluateSelectors(FormattingInfo formattingInfo) { if (formattingInfo.Placeholder is null) { return; } var firstSelector = true; foreach (var selector in formattingInfo.Placeholder.Selectors) { formattingInfo.Selector = selector; formattingInfo.Result = null; var handled = InvokeSourceExtensions(formattingInfo); if (handled) { formattingInfo.CurrentValue = formattingInfo.Result; } if (firstSelector) { firstSelector = false; // Handle "nested scopes" by traversing the stack: var parentFormattingInfo = formattingInfo; while (!handled && parentFormattingInfo.Parent != null) { parentFormattingInfo = parentFormattingInfo.Parent; parentFormattingInfo.Selector = selector; parentFormattingInfo.Result = null; handled = InvokeSourceExtensions(parentFormattingInfo); if (handled) { formattingInfo.CurrentValue = parentFormattingInfo.Result; } } } if (!handled) { throw formattingInfo.FormattingException($"Could not evaluate the selector \"{selector.RawText}\"", selector); } } }