Modified Logger
This commit is contained in:
@@ -1,16 +1,64 @@
|
||||
using Firebird2D.Logger;
|
||||
|
||||
using Firebird2D.Logger;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Firebird2D.Requirement
|
||||
{
|
||||
public class Require
|
||||
{
|
||||
public static void NotNull(object input, string name, [CallerMemberName] string callerName = "", [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLineNumber = 0)
|
||||
public static void NotNull(object input, string name, int loggerInstanceNumber,
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerFilePath] string callerPath = "",
|
||||
[CallerLineNumber] int callerLineNumber = 0)
|
||||
{
|
||||
if (input == null) {
|
||||
GameLogger.Log(callerName, LogType.Error, string.Format("{0}, was Null at Line {1} in {2} from {3}.", name, callerLineNumber, callerName, callerPath));
|
||||
throw new ArgumentNullException(string.Format("{0}, was Null at Line {1} in {2} from {3}.", name, callerLineNumber, callerName, callerPath));
|
||||
if (input == null)
|
||||
{
|
||||
LogAndThrow(loggerInstanceNumber, callerName, callerPath, callerLineNumber,
|
||||
$"{name} was null.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void NotEmpty(string input, string name, int loggerInstanceNumber,
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerFilePath] string callerPath = "",
|
||||
[CallerLineNumber] int callerLineNumber = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
LogAndThrow(loggerInstanceNumber, callerName, callerPath, callerLineNumber,
|
||||
$"{name} must not be null or empty.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Range(int value, int min, int max, string name, int loggerInstanceNumber,
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerFilePath] string callerPath = "",
|
||||
[CallerLineNumber] int callerLineNumber = 0)
|
||||
{
|
||||
if (value < min || value > max)
|
||||
{
|
||||
LogAndThrow(loggerInstanceNumber, callerName, callerPath, callerLineNumber,
|
||||
$"{name} must be in range [{min}, {max}], but was {value}.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void IsTrue(bool condition, string message, int loggerInstanceNumber,
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerFilePath] string callerPath = "",
|
||||
[CallerLineNumber] int callerLineNumber = 0)
|
||||
{
|
||||
if (!condition)
|
||||
{
|
||||
LogAndThrow(loggerInstanceNumber, callerName, callerPath, callerLineNumber, message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogAndThrow(int loggerInstanceNumber, string callerName, string callerPath, int lineNumber, string message)
|
||||
{
|
||||
string fullMessage = $"{message} (at {callerName} in {callerPath}, line {lineNumber})";
|
||||
|
||||
GameLogger.GetInstance(loggerInstanceNumber).Log(callerName, LogType.Error, fullMessage);
|
||||
throw new ArgumentException(fullMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Firebird2D.Requirement")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4d5afc4ba4c2fb1fde6fb769da0e6c84003d734")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+51493135dfc8aa77e4285d80e32310c1f02be5b0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Firebird2D.Requirement")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Firebird2D.Requirement")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
e39a5a8fa70529a2443df64310c68b2a15058d3b8161dad3c45da459c8bf1c38
|
||||
40d7aae7c923ca3d4454d246c52e8a64820bf9653fadbe515530b8637584741e
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,73 @@
|
||||
"G:\\Coding\\Firebird2D\\Firebird2D.Requirement\\Firebird2D.Requirement.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\Firebird2D.Interfaces.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\Firebird2D.Interfaces.csproj",
|
||||
"projectName": "Firebird2D.Interfaces",
|
||||
"projectPath": "G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\Firebird2D.Interfaces.csproj",
|
||||
"packagesPath": "C:\\Users\\wayan\\.nuget\\packages\\",
|
||||
"outputPath": "G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\wayan\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net8.0"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"C:\\TwinCAT\\Functions\\TE2000-HMI-Engineering\\Infrastructure\\Packages": {},
|
||||
"C:\\TwinCAT\\Functions\\TE2000-HMI-Engineering\\References": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net8.0": {
|
||||
"targetAlias": "net8.0",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net8.0": {
|
||||
"targetAlias": "net8.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.303/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"G:\\Coding\\Firebird2D\\Firebird2D.Logger\\Firebird2D.Logger.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
@@ -34,7 +101,11 @@
|
||||
"frameworks": {
|
||||
"net8.0": {
|
||||
"targetAlias": "net8.0",
|
||||
"projectReferences": {}
|
||||
"projectReferences": {
|
||||
"G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\Firebird2D.Interfaces.csproj": {
|
||||
"projectPath": "G:\\Coding\\Firebird2D\\FireBird2D.Interfaces\\Firebird2D.Interfaces.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
|
||||
@@ -2,9 +2,22 @@
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net8.0": {
|
||||
"Firebird2D.Interfaces/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v8.0",
|
||||
"compile": {
|
||||
"bin/placeholder/Firebird2D.Interfaces.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/Firebird2D.Interfaces.dll": {}
|
||||
}
|
||||
},
|
||||
"Firebird2D.Logger/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v8.0",
|
||||
"dependencies": {
|
||||
"Firebird2D.Interfaces": "1.0.0"
|
||||
},
|
||||
"compile": {
|
||||
"bin/placeholder/Firebird2D.Logger.dll": {}
|
||||
},
|
||||
@@ -15,6 +28,11 @@
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Firebird2D.Interfaces/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../FireBird2D.Interfaces/Firebird2D.Interfaces.csproj",
|
||||
"msbuildProject": "../FireBird2D.Interfaces/Firebird2D.Interfaces.csproj"
|
||||
},
|
||||
"Firebird2D.Logger/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../Firebird2D.Logger/Firebird2D.Logger.csproj",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "Cnwm1cp4iIM=",
|
||||
"dgSpecHash": "UvsIOKD4Be8=",
|
||||
"success": true,
|
||||
"projectFilePath": "G:\\Coding\\Firebird2D\\Firebird2D.Requirement\\Firebird2D.Requirement.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
|
||||
Reference in New Issue
Block a user