Restore SEBPatch
This commit is contained in:
45
SafeExamBrowser.Logging/DefaultLogFormatter.cs
Normal file
45
SafeExamBrowser.Logging/DefaultLogFormatter.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation of <see cref="ILogContentFormatter"/>.
|
||||
/// </summary>
|
||||
public class DefaultLogFormatter : ILogContentFormatter
|
||||
{
|
||||
public string Format(ILogContent content)
|
||||
{
|
||||
if (content is ILogText text)
|
||||
{
|
||||
return text.Text;
|
||||
}
|
||||
|
||||
if (content is ILogMessage message)
|
||||
{
|
||||
return FormatLogMessage(message);
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"The default formatter is not yet implemented for log content of type {content.GetType()}!");
|
||||
}
|
||||
|
||||
private string FormatLogMessage(ILogMessage message)
|
||||
{
|
||||
var date = message.DateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
var severity = message.Severity.ToString().ToUpper();
|
||||
var threadId = message.ThreadInfo.Id < 10 ? $"0{message.ThreadInfo.Id}" : message.ThreadInfo.Id.ToString();
|
||||
var threadName = message.ThreadInfo.HasName ? ": " + message.ThreadInfo.Name : string.Empty;
|
||||
var threadInfo = $"[{threadId}{threadName}]";
|
||||
|
||||
return $"{date} {threadInfo} - {severity}: {message.Message}";
|
||||
}
|
||||
}
|
||||
}
|
53
SafeExamBrowser.Logging/LogFileWriter.cs
Normal file
53
SafeExamBrowser.Logging/LogFileWriter.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ILogObserver"/> which immediately saves new log content to disk.
|
||||
/// </summary>
|
||||
public class LogFileWriter : ILogObserver
|
||||
{
|
||||
private readonly object @lock = new object();
|
||||
private readonly string filePath;
|
||||
private readonly ILogContentFormatter formatter;
|
||||
|
||||
public LogFileWriter(ILogContentFormatter formatter, string filePath)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
var directory = Path.GetDirectoryName(filePath);
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
}
|
||||
|
||||
public void Notify(ILogContent content)
|
||||
{
|
||||
lock (@lock)
|
||||
{
|
||||
var raw = formatter.Format(content);
|
||||
|
||||
using (var stream = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||
{
|
||||
stream.WriteLine(raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
SafeExamBrowser.Logging/LogMessage.cs
Normal file
38
SafeExamBrowser.Logging/LogMessage.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation of <see cref="ILogMessage"/>.
|
||||
/// </summary>
|
||||
public class LogMessage : ILogMessage
|
||||
{
|
||||
public DateTime DateTime { get; private set; }
|
||||
public LogLevel Severity { get; private set; }
|
||||
public string Message { get; private set; }
|
||||
public IThreadInfo ThreadInfo { get; private set; }
|
||||
|
||||
public LogMessage(DateTime dateTime, LogLevel severity, string message, IThreadInfo threadInfo)
|
||||
{
|
||||
DateTime = dateTime;
|
||||
Severity = severity;
|
||||
Message = message;
|
||||
ThreadInfo = threadInfo ?? throw new ArgumentNullException(nameof(threadInfo));
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new LogMessage(DateTime, Severity, Message, ThreadInfo.Clone() as IThreadInfo);
|
||||
}
|
||||
}
|
||||
}
|
30
SafeExamBrowser.Logging/LogText.cs
Normal file
30
SafeExamBrowser.Logging/LogText.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation of <see cref="ILogText"/>.
|
||||
/// </summary>
|
||||
public class LogText : ILogText
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
|
||||
public LogText(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new LogText(Text);
|
||||
}
|
||||
}
|
||||
}
|
190
SafeExamBrowser.Logging/Logger.cs
Normal file
190
SafeExamBrowser.Logging/Logger.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Default, thread-safe implementation of <see cref="ILogger"/>.
|
||||
/// </summary>
|
||||
public class Logger : ILogger
|
||||
{
|
||||
private readonly object @lock = new object();
|
||||
private readonly IList<ILogContent> log = new List<ILogContent>();
|
||||
private readonly IList<ILogObserver> observers = new List<ILogObserver>();
|
||||
|
||||
public LogLevel LogLevel { get; set; }
|
||||
|
||||
public void Debug(string message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (LogLevel <= LogLevel.Debug)
|
||||
{
|
||||
Add(LogLevel.Debug, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Info(string message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (LogLevel <= LogLevel.Info)
|
||||
{
|
||||
Add(LogLevel.Info, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Warn(string message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (LogLevel <= LogLevel.Warning)
|
||||
{
|
||||
Add(LogLevel.Warning, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (LogLevel <= LogLevel.Error)
|
||||
{
|
||||
Add(LogLevel.Error, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Error(string message, Exception exception)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (exception == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(exception));
|
||||
}
|
||||
|
||||
var details = new StringBuilder();
|
||||
|
||||
details.AppendLine();
|
||||
details.AppendLine($" Exception Message: {exception.Message}");
|
||||
details.AppendLine($" Exception Type: {exception.GetType()}");
|
||||
|
||||
if (exception.StackTrace != null)
|
||||
{
|
||||
details.AppendLine();
|
||||
details.AppendLine(exception.StackTrace);
|
||||
}
|
||||
|
||||
for (var inner = exception.InnerException; inner != null; inner = inner.InnerException)
|
||||
{
|
||||
details.AppendLine();
|
||||
details.AppendLine($" Inner Exception Message: {inner.Message}");
|
||||
details.AppendLine($" Inner Exception Type: {inner.GetType()}");
|
||||
|
||||
if (inner.StackTrace != null)
|
||||
{
|
||||
details.AppendLine();
|
||||
details.AppendLine(inner.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
if (LogLevel <= LogLevel.Error)
|
||||
{
|
||||
Add(LogLevel.Error, message);
|
||||
Add(new LogText(details.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void Log(string text)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
Add(new LogText(text));
|
||||
}
|
||||
|
||||
public IList<ILogContent> GetLog()
|
||||
{
|
||||
lock (@lock)
|
||||
{
|
||||
return log.Select(m => m.Clone() as ILogContent).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void Subscribe(ILogObserver observer)
|
||||
{
|
||||
if (observer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(observer));
|
||||
}
|
||||
|
||||
lock (@lock)
|
||||
{
|
||||
if (!observers.Contains(observer))
|
||||
{
|
||||
observers.Add(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Unsubscribe(ILogObserver observer)
|
||||
{
|
||||
lock (@lock)
|
||||
{
|
||||
observers.Remove(observer);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add(LogLevel severity, string message)
|
||||
{
|
||||
var threadId = Thread.CurrentThread.ManagedThreadId;
|
||||
var threadName = Thread.CurrentThread.Name;
|
||||
var threadInfo = new ThreadInfo(threadId, threadName);
|
||||
|
||||
Add(new LogMessage(DateTime.Now, severity, message, threadInfo));
|
||||
}
|
||||
|
||||
private void Add(ILogContent content)
|
||||
{
|
||||
lock (@lock)
|
||||
{
|
||||
log.Add(content);
|
||||
|
||||
foreach (var observer in observers)
|
||||
{
|
||||
observer.Notify(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
88
SafeExamBrowser.Logging/ModuleLogger.cs
Normal file
88
SafeExamBrowser.Logging/ModuleLogger.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
public class ModuleLogger : IModuleLogger
|
||||
{
|
||||
private ILogger logger;
|
||||
private string moduleInfo;
|
||||
|
||||
public LogLevel LogLevel
|
||||
{
|
||||
get { return logger.LogLevel; }
|
||||
set { logger.LogLevel = value; }
|
||||
}
|
||||
|
||||
public ModuleLogger(ILogger logger, string moduleInfo)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.moduleInfo = moduleInfo;
|
||||
}
|
||||
|
||||
public IModuleLogger CloneFor(string moduleInfo)
|
||||
{
|
||||
return new ModuleLogger(logger, moduleInfo);
|
||||
}
|
||||
|
||||
public void Debug(string message)
|
||||
{
|
||||
logger.Debug(AppendModuleInfo(message));
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
logger.Error(AppendModuleInfo(message));
|
||||
}
|
||||
|
||||
public void Error(string message, Exception exception)
|
||||
{
|
||||
logger.Error(AppendModuleInfo(message), exception);
|
||||
}
|
||||
|
||||
public IList<ILogContent> GetLog()
|
||||
{
|
||||
return logger.GetLog();
|
||||
}
|
||||
|
||||
public void Info(string message)
|
||||
{
|
||||
logger.Info(AppendModuleInfo(message));
|
||||
}
|
||||
|
||||
public void Log(string message)
|
||||
{
|
||||
logger.Log(message);
|
||||
}
|
||||
|
||||
public void Subscribe(ILogObserver observer)
|
||||
{
|
||||
logger.Subscribe(observer);
|
||||
}
|
||||
|
||||
public void Unsubscribe(ILogObserver observer)
|
||||
{
|
||||
logger.Unsubscribe(observer);
|
||||
}
|
||||
|
||||
public void Warn(string message)
|
||||
{
|
||||
logger.Warn(AppendModuleInfo(message));
|
||||
}
|
||||
|
||||
private string AppendModuleInfo(string message)
|
||||
{
|
||||
return $"[{moduleInfo}] {message}";
|
||||
}
|
||||
}
|
||||
}
|
33
SafeExamBrowser.Logging/Properties/AssemblyInfo.cs
Normal file
33
SafeExamBrowser.Logging/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SafeExamBrowser.Logging")]
|
||||
[assembly: AssemblyDescription("Safe Exam Browser")]
|
||||
[assembly: AssemblyCompany("ETH Zürich")]
|
||||
[assembly: AssemblyProduct("SafeExamBrowser.Logging")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024 ETH Zürich, IT Services")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e107026c-2011-4552-a7d8-3a0d37881df6")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0.0")]
|
78
SafeExamBrowser.Logging/SafeExamBrowser.Logging.csproj
Normal file
78
SafeExamBrowser.Logging/SafeExamBrowser.Logging.csproj
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E107026C-2011-4552-A7D8-3A0D37881DF6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SafeExamBrowser.Logging</RootNamespace>
|
||||
<AssemblyName>SafeExamBrowser.Logging</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DefaultLogFormatter.cs" />
|
||||
<Compile Include="LogFileWriter.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="LogMessage.cs" />
|
||||
<Compile Include="LogText.cs" />
|
||||
<Compile Include="ModuleLogger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ThreadInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SafeExamBrowser.Logging.Contracts\SafeExamBrowser.Logging.Contracts.csproj">
|
||||
<Project>{64ea30fb-11d4-436a-9c2b-88566285363e}</Project>
|
||||
<Name>SafeExamBrowser.Logging.Contracts</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SafeExamBrowser.Settings\SafeExamBrowser.Settings.csproj">
|
||||
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
|
||||
<Name>SafeExamBrowser.Settings</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
38
SafeExamBrowser.Logging/ThreadInfo.cs
Normal file
38
SafeExamBrowser.Logging/ThreadInfo.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation of <see cref="IThreadInfo"/>.
|
||||
/// </summary>
|
||||
public class ThreadInfo : IThreadInfo
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public bool HasName
|
||||
{
|
||||
get { return !String.IsNullOrWhiteSpace(Name); }
|
||||
}
|
||||
|
||||
public ThreadInfo(int id, string name = null)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new ThreadInfo(Id, Name);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user