1using Microsoft.Extensions.Localization;
2using System.Diagnostics;
3using System.Globalization;
4using System.Reflection;
11 LocalizedString
this[
string Name,
bool ShouldReport] {
get; }
13 LocalizedString
this[
string Name,
bool ShouldReport, params
object[] Arguments] {
get; }
22 private readonly IStringLocalizer localizer = Localizer;
24 public LocalizedString
this[
string Name]
27 public LocalizedString
this[
string Name, params
object[] Arguments]
34 LocalizedString Result = this.localizer[Name];
35 if (Result is not
null && !Result.ResourceNotFound)
38 StackTrace Trace =
new();
40 int i, c = Trace.FrameCount;
41 Assembly ThisAssembly = typeof(
App).Assembly;
43 for (i = 1; i < c; i++)
45 Type? T = Trace.GetFrame(i)?.GetMethod()?.DeclaringType;
49 if (T.Assembly.FullName == ThisAssembly.FullName)
51 if (T == typeof(ReportingStringLocalizer))
54 if (T.IsConstructedGenericType)
55 T = T.GetGenericTypeDefinition();
63 LocalizeExtension.ReportMissingString(Name, Caller);
65 return new LocalizedString(Name, Name,
true);
69 LocalizedString IReportingStringLocalizer.this[
string Name,
bool ShouldReport, params
object[] Arguments]
73 LocalizedString Result =
this[Name];
74 if (Result.ResourceNotFound)
77 return new LocalizedString(Name,
string.Format(CultureInfo.CurrentCulture, Result.Value, Arguments));
81 public IEnumerable<LocalizedString> GetAllStrings(
bool includeParentCultures)
83 return this.localizer.GetAllStrings(includeParentCultures);
Represents an instance of the Neuro-Access app.
Base class that references services in the app.