Skip to content

Commit

Permalink
UPDATED: LoggerProvider and Enumeration.scriban
Browse files Browse the repository at this point in the history
- Removed the code that writes logs to a file in the LoggerProvider class
- Uncommented the code for creating and writing logs to a text file in the Logger
- Modified the Parse method in the Enumeration.scriban file to return a non-nullable object of nullable object
- Updated the Parse method in the Enumeration.scriban file to use the provided matchPredicate
  • Loading branch information
dgmjr committed Nov 23, 2023
1 parent af875c6 commit 62c55b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Reflection.PortableExecutable;
/*
* Constants.cs
*
Expand Down
10 changes: 5 additions & 5 deletions src/LoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ protected virtual void Dispose(bool disposing)
_context.RegisterPostInitializationOutput(
ctx => ctx.AddSource("log.g.cs", GetLogs())
);
new FileInfo(
Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "log.g.txt")
)
.CreateText()
.Write(GetLogs());
// new FileInfo(
// Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "log.g.txt")
// )
// .CreateText()
// .Write(GetLogs());
}
disposedValue = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Enumeration.scriban
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public {{ if base_type == "" || base_type == null }} static {{ end }} partial {

/// <summary>Parses the <paramref name="value"/> to an object of type <see cref="I{{ dto_type_name }}"/>.</summary>
/// <exception cref="InvalidCastException">if no matching item was found</exception>
public static I{{ dto_type_name }}? Parse(string value)
=> Parse(value);
public static I{{ dto_type_name }} Parse(string value)
=> Parse(e => e.Name == value || e.DisplayName == value || e.GuidString == value || e.UriString == value || e.ShortName == value);

/// <summary>Uses the predicate the <paramref name="matchPredicate"/> to find an object of type <see cref="I{{ dto_type_name }}"/>.</summary>
/// <exception cref="InvalidCastException">if no matching item was found</exception>
public static I{{ dto_type_name }}? Parse(Func<I{{ dto_type_name }}, bool> matchPredicate)
public static I{{ dto_type_name }} Parse(Func<I{{ dto_type_name }}, bool> matchPredicate)
=> Parse(matchPredicate, true);

private static I{{ dto_type_name }} Parse(Func<I{{ dto_type_name }}, bool> matchPredicate, bool throwOnNotFound)
Expand Down

0 comments on commit 62c55b3

Please sign in to comment.