Enhance export demo
This commit is contained in:
@ -29,10 +29,10 @@
|
|||||||
<RadzenTabs RenderMode="TabRenderMode.Client" Style="height: 100%;">
|
<RadzenTabs RenderMode="TabRenderMode.Client" Style="height: 100%;">
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<RadzenTabsItem Text="Запрос">
|
<RadzenTabsItem Text="Запрос">
|
||||||
<RadzenTextArea @bind-Value=@messageBody Disabled="true" />
|
<RadzenTextArea @ref=@messageTextArea Value=@messageBody Disabled="true" ReadOnly="true" Style="resize: none; white-space: pre; overflow-wrap: normal; overflow-x: auto;" class="rz-w-stretch" />
|
||||||
</RadzenTabsItem>
|
</RadzenTabsItem>
|
||||||
<RadzenTabsItem Text="Результат">
|
<RadzenTabsItem Text="Результат">
|
||||||
<RadzenTextArea @bind-Value=@responseBody Disabled="true" />
|
<RadzenTextArea @ref=@responseTextArea Value=@responseBody Disabled="true" ReadOnly="true" Style="resize: none; white-space: pre; overflow-wrap: normal; overflow-x: auto;" class="rz-w-stretch" />
|
||||||
</RadzenTabsItem>
|
</RadzenTabsItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</RadzenTabs>
|
</RadzenTabs>
|
||||||
@ -45,6 +45,8 @@
|
|||||||
@code {
|
@code {
|
||||||
EventConsole console = default!;
|
EventConsole console = default!;
|
||||||
bool inputDisabled = false;
|
bool inputDisabled = false;
|
||||||
|
RadzenTextArea messageTextArea;
|
||||||
|
RadzenTextArea responseTextArea;
|
||||||
string messageBody;
|
string messageBody;
|
||||||
string responseBody;
|
string responseBody;
|
||||||
|
|
||||||
@ -85,7 +87,8 @@
|
|||||||
{
|
{
|
||||||
catchMessageBody = false;
|
catchMessageBody = false;
|
||||||
|
|
||||||
messageBody = File.ReadAllText(fileName);
|
messageBody = XmlBeautifier.Beautify(File.ReadAllText(fileName));
|
||||||
|
messageTextArea.Rows = messageBody.Count(c => c.Equals('\n')) + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +121,7 @@
|
|||||||
void EndExport()
|
void EndExport()
|
||||||
{
|
{
|
||||||
inputDisabled = false;
|
inputDisabled = false;
|
||||||
responseBody = File.ReadAllText(messageCapturer.LastFileName);
|
responseBody = XmlBeautifier.Beautify(File.ReadAllText(messageCapturer.LastFileName));
|
||||||
|
responseTextArea.Rows = responseBody.Count(c => c.Equals('\n')) + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
Hcs.WebApp/XmlBeautifier.cs
Normal file
29
Hcs.WebApp/XmlBeautifier.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace Hcs.WebApp
|
||||||
|
{
|
||||||
|
internal static class XmlBeautifier
|
||||||
|
{
|
||||||
|
internal static string Beautify(string xml)
|
||||||
|
{
|
||||||
|
var stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
var settings = new XmlWriterSettings
|
||||||
|
{
|
||||||
|
OmitXmlDeclaration = true,
|
||||||
|
Indent = true,
|
||||||
|
NewLineOnAttributes = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
|
||||||
|
{
|
||||||
|
var element = XElement.Parse(xml);
|
||||||
|
element.Save(xmlWriter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user