aktueller Stand
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -8,14 +9,14 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
{
|
||||
internal class F4SDProtocoll
|
||||
{
|
||||
private readonly ICollection<IProtocollEntry> _protocollEntries = new List<IProtocollEntry>();
|
||||
private readonly ICollection<ProtocollEntryBase> _protocollEntries = new List<ProtocollEntryBase>();
|
||||
|
||||
public static F4SDProtocoll Instance { get; private set; } = new F4SDProtocoll();
|
||||
|
||||
private F4SDProtocoll() { }
|
||||
|
||||
internal void Add(IProtocollEntry entry) => _protocollEntries.Add(entry);
|
||||
internal void Add(IEnumerable<IProtocollEntry> entries)
|
||||
internal void Add(ProtocollEntryBase entry) => _protocollEntries.Add(entry);
|
||||
internal void Add(IEnumerable<ProtocollEntryBase> entries)
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
@@ -25,34 +26,34 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
|
||||
internal void Clear() => _protocollEntries.Clear();
|
||||
|
||||
internal T GetLatestOfType<T>() where T : IProtocollEntry => _protocollEntries.OfType<T>().LastOrDefault();
|
||||
internal T GetLatestOfType<T>() where T : ProtocollEntryBase => _protocollEntries.OfType<T>().LastOrDefault();
|
||||
|
||||
internal IEnumerable<T> GetOfType<T>(int? count = null) where T : IProtocollEntry
|
||||
internal IEnumerable<T> GetOfType<T>(int? count = null) where T : ProtocollEntryBase
|
||||
{
|
||||
if(count.HasValue)
|
||||
return _protocollEntries.OfType<T>().Reverse().Take(count.Value).Reverse();
|
||||
return _protocollEntries.OfType<T>();
|
||||
}
|
||||
|
||||
internal IEnumerable<IProtocollEntry> GetAll() => _protocollEntries;
|
||||
internal IEnumerable<ProtocollEntryBase> GetAll() => _protocollEntries;
|
||||
|
||||
internal DataObject GetLatestOfTypeAsDataObject<T>(bool skipHtmlFrame) where T : IProtocollEntry
|
||||
internal DataObject GetLatestOfTypeAsDataObject<T>(bool skipHtmlFrame) where T : ProtocollEntryBase
|
||||
{
|
||||
IProtocollEntry entry = _protocollEntries.OfType<T>().LastOrDefault();
|
||||
ProtocollEntryBase entry = _protocollEntries.OfType<T>().LastOrDefault();
|
||||
|
||||
if (entry is null)
|
||||
return new DataObject();
|
||||
|
||||
return GetDataObjectOf(new IProtocollEntry[] { entry }, skipHtmlFrame);
|
||||
return GetDataObjectOf(new ProtocollEntryBase[] { entry }, skipHtmlFrame);
|
||||
}
|
||||
|
||||
internal DataObject GetOfTypeAsDataObject<T>(bool skipHtmlFrame, int? count = null) where T : IProtocollEntry
|
||||
=> GetDataObjectOf(GetOfType<T>(count).Cast<IProtocollEntry>(), skipHtmlFrame);
|
||||
internal DataObject GetOfTypeAsDataObject<T>(bool skipHtmlFrame, int? count = null) where T : ProtocollEntryBase
|
||||
=> GetDataObjectOf(GetOfType<T>(count).Cast<ProtocollEntryBase>(), skipHtmlFrame);
|
||||
|
||||
internal DataObject GetAllAsDataObject(bool skipHtmlFrame)
|
||||
=> GetDataObjectOf(_protocollEntries, skipHtmlFrame);
|
||||
|
||||
private DataObject GetDataObjectOf(IEnumerable<IProtocollEntry> entries, bool skipHtmlFrame, int? count = null)
|
||||
private DataObject GetDataObjectOf(IEnumerable<ProtocollEntryBase> entries, bool skipHtmlFrame, int? count = null)
|
||||
{
|
||||
DataObject dataObject = new DataObject();
|
||||
|
||||
@@ -67,16 +68,16 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
if (count.HasValue)
|
||||
entries = entries.Reverse().Take(count.Value).Reverse();
|
||||
|
||||
foreach (IProtocollEntry entry in entries)
|
||||
foreach (ProtocollEntryBase entry in entries)
|
||||
{
|
||||
string entryAscii = entry.GetAscii();
|
||||
string entryAscii = entry.AsciiContent;
|
||||
if (!string.IsNullOrEmpty(entryAscii))
|
||||
{
|
||||
ascii += entryAscii;
|
||||
ascii += asciiSeparator;
|
||||
}
|
||||
|
||||
string entryHtml = entry.GetHtml();
|
||||
string entryHtml = entry.HtmlContent;
|
||||
if (!string.IsNullOrEmpty(entryHtml))
|
||||
{
|
||||
html += entryHtml;
|
||||
|
||||
Reference in New Issue
Block a user