private string FormatInternal(Type type, Func <TypeSpec, TypeSpec> rewriter = null) { string runtimeType = null; foreach (var converter in _converters) { if (converter.TryFormat(type, out var value)) { runtimeType = value; break; } } if (string.IsNullOrWhiteSpace(runtimeType)) { runtimeType = RuntimeTypeNameFormatter.Format(type); } var runtimeTypeSpec = RuntimeTypeNameParser.Parse(runtimeType); var displayTypeSpec = RuntimeTypeNameRewriter.Rewrite(runtimeTypeSpec, _convertToDisplayName); if (rewriter is object) { displayTypeSpec = rewriter(displayTypeSpec); } var formatted = displayTypeSpec.Format(); return(formatted); }
private bool ParseInternal(string formatted, out Type type) { var parsed = RuntimeTypeNameParser.Parse(formatted); var runtimeTypeSpec = RuntimeTypeNameRewriter.Rewrite(parsed, _convertFromDisplayName); var runtimeType = runtimeTypeSpec.Format(); foreach (var converter in _converters) { if (converter.TryParse(runtimeType, out type)) { return(true); } } return(_resolver.TryResolveType(runtimeType, out type)); }