Как отформатировать текст в blazorC#

Место общения программистов C#
Anonymous
Как отформатировать текст в blazor

Сообщение Anonymous »

Привет, ребята, я создаю новый проект в blazor и пытаюсь отформатировать текст перед использованием в своем html. Я пытаюсь это сделать с помощью замены, моя основная проблема в том, что я могу добавить линию разрыва
это функция, которую я использую

Код: Выделить всё

public string gLInjectionStatusFormattedText (string? rawText) {
var text = rawText?.Replace("- Valve:", "\n Valve:")
.Replace("{CompletionAnalysisResults.troubleshooting_data.cont_gaslift_cmpl_inject_status.ref_data.current_op_valve_description}", "Weatherford RO-1 5/32 (THC)")
.Replace("- Mandrel number:", "\n Mandrel number:")
.Replace("{CompletionAnalysisResults.troubleshooting_data.cont_gaslift_cmpl_inject_status.ref_data.current_op_valve_mand_num}", "8")
.Replace("- Meas Depth:", "\n Meas Depth:")
.Replace("{CompletionAnalysisResults.troubleshooting_data.cont_gaslift_cmpl_inject_status.ref_data.current_op_valve_depth}", "4833.0 feet")
.Replace("{CompletionAnalysisResults.troubleshooting_data.cont_gaslift_cmpl_inject_status.ref_data.valve_status_summary}", "The deepest possible injection depth for this well is 4833.0 feet (MD) at current operating conditions.")
.Replace("Valve Status Summary:", "Valve Status Summary:");

return text ?? "";
}
и я использую его в html (blazor) вот так

Код: Выделить всё


@getSummaryStatusColor(summaryStatus.GLInjectionStatus)
GL Injection Status:

@gLInjectionStatusFormattedText(summaryStatus.GLInjectionText)

где summaryStatus.GLInjectionText — это строка, которую я получаю из базы данных
Я бы хотел, чтобы мой текст выглядел так

Код: Выделить всё

This well is injecting at its designed operating point:

Valve: Weatherford RO-1 5/32 (THC)
Mandrel number: 6
Meas Depth: 4833.0 feet
Valve Status Summary: The deepest possible injection depth for this well is 4833.0 feet (MD) at current operating conditions.

Lift gas injection is from an ORIF valve in mandrel number 6 at 4833.0 feet and has an estimated flow rate of 453.292 MCF/day.
Но вместо этого в моем html это выглядит так:

Код: Выделить всё

This well is injecting at its designed operating point: Valve: Weatherford RO-1 5/32 (THC) Mandrel number: 8 Meas Depth: 4833.0 feet   Valve Status Summary: The deepest possible injection depth for this well is 4833.0 feet (MD) at current operating conditions.
Можно ли как-нибудь этого добиться?

Подробнее здесь: https://stackoverflow.com/questions/786 ... -in-blazor

Вернуться в «C#»