using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using SmartFormat.Core.Extensions;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SmartFormat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2011-2024 SmartFormat Project")]
[assembly: AssemblyDescription("This package is a SmartFormat extension for formatting Newtonsoft.Json types.\r\n\r\nSmartFormat is a lightweight text templating library written in C#.\r\nIt can format various data sources into a string with a minimal, intuitive syntax similar to string.Format.\r\nIt uses extensions to provide named placeholders, localization, pluralization, gender conjugation, and list and time formatting.\r\n ")]
[assembly: AssemblyFileVersion("3.5.0.886")]
[assembly: AssemblyInformationalVersion("3.5.0+c097ea6fc668033580909317ed90679dacbb0e8a")]
[assembly: AssemblyProduct("SmartFormat")]
[assembly: AssemblyTitle("SmartFormat.Extensions.Newtonsoft.Json")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/axuno/SmartFormat.git")]
[assembly: AssemblyVersion("3.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SmartFormat.Extensions
{
public class NewtonsoftJsonSource : Source
{
public override bool TryEvaluateSelector(ISelectorInfo selectorInfo)
{
object currentValue = selectorInfo.CurrentValue;
JObject val = (JObject)((currentValue is JObject) ? currentValue : null);
object obj;
if (val == null)
{
JValue val2 = (JValue)((currentValue is JValue) ? currentValue : null);
obj = ((val2 == null) ? selectorInfo.CurrentValue : val2.Value);
}
else
{
obj = (((JToken)val).HasValues ? val : null);
}
object obj2 = obj;
if (((Source)this).TrySetResultForNullableOperator(selectorInfo))
{
return true;
}
if (obj2 == null)
{
return false;
}
currentValue = selectorInfo.CurrentValue;
JObject val3 = (JObject)((currentValue is JObject) ? currentValue : null);
if (val3 == null)
{
JToken val4 = (JToken)((currentValue is JToken) ? currentValue : null);
if (val4 != null)
{
return TryEvaluateJToken(val4, selectorInfo);
}
return false;
}
return TryEvaluateJObject(val3, selectorInfo);
}
private static bool TryEvaluateJObject(JObject jsonObject, ISelectorInfo selectorInfo)
{
JToken value = jsonObject.GetValue(selectorInfo.SelectorText, selectorInfo.FormatDetails.Settings.GetCaseSensitivityComparison());
if (value != null)
{
return TryEvaluateJToken(value, selectorInfo);
}
return false;
}
private static bool TryEvaluateJToken(JToken jsonToken, ISelectorInfo selectorInfo)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected I4, but got Unknown
JTokenType type = jsonToken.Type;
selectorInfo.Result = (type - 1) switch
{
9 => null,
8 => Extensions.Value<bool>((IEnumerable<JToken>)jsonToken),
5 => Extensions.Value<int>((IEnumerable<JToken>)jsonToken),
6 => Extensions.Value<float>((IEnumerable<JToken>)jsonToken),
7 => Extensions.Value<string>((IEnumerable<JToken>)jsonToken),
0 => Extensions.Value<object>((IEnumerable<JToken>)jsonToken),
1 => jsonToken.ToObject<List<object>>(),
11 => Extensions.Value<DateTime>((IEnumerable<JToken>)jsonToken),
16 => Extensions.Value<TimeSpan>((IEnumerable<JToken>)jsonToken),
_ => jsonToken,
};
return true;
}
}
}