static string?RenderAsFormattable( IProperty property, IPropertyContainer container, PropertyRendererOptions options, string format, IFormatProvider?formatProvider) { SearchOptions searchOptions = options.SearchOptions ?? container.SearchOptions.UseDefaultValue(false).ReturnNull(); object? valueUntyped = container.GetValueUntyped(property, searchOptions); if (valueUntyped == null) { return(options.NullValue); } if (valueUntyped is IFormattable formattable) { return(formattable.ToString(format, formatProvider ?? CultureInfo.InvariantCulture)); } return(valueUntyped.DefaultFormatValue()); }
/// <inheritdoc /> public void Configure(Action <PropertyRendererOptions> configure) { if (configure != null) { var rendererOptions = new PropertyRendererOptions(PropertyUntyped) { TargetName = TargetName, SearchOptions = SearchOptions, NullValue = NullValue, CustomRender = CustomRender, }; configure(rendererOptions); TargetName = rendererOptions.TargetName ?? TargetName; SearchOptions = rendererOptions.SearchOptions ?? SearchOptions; NullValue = rendererOptions.NullValue ?? NullValue; CustomRender = rendererOptions.CustomRender ?? CustomRender; rendererOptions.AfterConfigure?.Invoke(this); } }
/// <inheritdoc /> public IPropertyRenderer ConfigureRenderer(Action <PropertyRendererOptions> configure) { configure = configure ?? throw new ArgumentNullException(nameof(configure)); PropertyRendererOptions?rendererOptions = new PropertyRendererOptions(PropertyUntyped) { TargetName = TargetName, SearchOptions = SearchOptions, NullValue = NullValue, CustomRender = CustomRender, }; configure(rendererOptions); TargetName = rendererOptions.TargetName ?? TargetName; SearchOptions = rendererOptions.SearchOptions ?? SearchOptions; NullValue = rendererOptions.NullValue ?? NullValue; CustomRender = rendererOptions.CustomRender ?? CustomRender; rendererOptions.AfterConfigure?.Invoke(this); return(this); }