Pointless change
This commit is contained in:
parent
8839cfe262
commit
e2f8f88186
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project>
|
||||||
|
<!-- Standard properties. -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version Condition="'$(BUILD_BUILDNUMBER)' != ''">$(BUILD_BUILDNUMBER)</Version>
|
||||||
|
|
||||||
|
<OutputType Condition="'$(OutputType)' == ''">Library</OutputType>
|
||||||
|
<RootNamespace Condition="'$(RootNamespace)' == ''">$(AssemblyName)</RootNamespace>
|
||||||
|
|
||||||
|
<Configurations>Debug;Release;DebugLegacy;ReleaseLegacy</Configurations>
|
||||||
|
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
|
||||||
|
<Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
|
||||||
|
<OutputPath>bin\$(Configuration)</OutputPath>
|
||||||
|
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Externalconsole>true</Externalconsole>
|
||||||
|
|
||||||
|
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
|
||||||
|
<Cecil Condition="'$(Cecil)' == ''">true</Cecil>
|
||||||
|
<CecilLegacy>false</CecilLegacy>
|
||||||
|
|
||||||
|
<ILGen Condition="'$(ILGen)' == ''">false</ILGen>
|
||||||
|
|
||||||
|
<NETFramework>false</NETFramework>
|
||||||
|
<NETStandard>false</NETStandard>
|
||||||
|
<NETStandard1X>false</NETStandard1X>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- dotnet pack -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<Authors>0x0ade</Authors> <!-- Note: This previously said "Maik Macho and collaborators", but with dotnet pack, <Authors> is also the list of owners. -->
|
||||||
|
<Copyright>Copyright 2018 Maik Macho</Copyright>
|
||||||
|
<PackageTags>MonoMod;assembly;assemblies;module;modules;il;cil;msil;bytecode;reflection;injection;cecil;mono;$(PackageTags)</PackageTags>
|
||||||
|
<PackageLicenseUrl>https://github.com/0x0ade/MonoMod/blob/master/LICENSE</PackageLicenseUrl>
|
||||||
|
<PackageProjectUrl>https://github.com/0x0ade/MonoMod</PackageProjectUrl>
|
||||||
|
<PackageIconUrl>https://user-images.githubusercontent.com/1200380/47308180-28242880-d631-11e8-89d2-14d86f3db113.png</PackageIconUrl>
|
||||||
|
<!-- Fix dotnet pack not being able to find .NET Framework 3.5 -->
|
||||||
|
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35' And '$(OS)' == 'Windows_NT'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Debug -->
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug' Or '$(Configuration)' == 'DebugLegacy'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<DefineConstants>DEBUG;TRACE;$(DefineConstants)</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Release -->
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'ReleaseLegacy'">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DefineConstants>TRACE;$(DefineConstants)</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Legacy -->
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'DebugLegacy' Or '$(Configuration)' == 'ReleaseLegacy'">
|
||||||
|
<CecilLegacy>true</CecilLegacy>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Common references. -->
|
||||||
|
<Choose>
|
||||||
|
<When Condition="$(TargetFramework.StartsWith('netstandard')) Or $(TargetFramework.StartsWith('netcoreapp'))">
|
||||||
|
<!-- .NET Standard -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<NETStandard>true</NETStandard>
|
||||||
|
<NETStandard1X Condition="$(TargetFramework.StartsWith('netstandard1')) Or $(TargetFramework.StartsWith('netcoreapp1'))">true</NETStandard1X>
|
||||||
|
<DefineConstants>NETSTANDARD;$(DefineConstants)</DefineConstants>
|
||||||
|
<DefineConstants Condition="$(NETStandard1X)">NETSTANDARD1_X;$(DefineConstants)</DefineConstants>
|
||||||
|
<DefineConstants Condition="$(CecilLegacy)">CECIL0_10;$(DefineConstants)</DefineConstants>
|
||||||
|
<CecilVersion Condition="$(CecilLegacy) And '$(CecilVersion)' == ''">0.10.3</CecilVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- These are also required when targeting .NET Standard 2.0 to resolve a version conflict with Mono.Cecil, which targets .NET Standard 1.0 -->
|
||||||
|
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
</When>
|
||||||
|
<Otherwise>
|
||||||
|
<!-- .NET Framework -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<NETFramework>true</NETFramework>
|
||||||
|
<DefineConstants>NETFRAMEWORK;$(DefineConstants)</DefineConstants>
|
||||||
|
<DefineConstants Condition="$(CecilLegacy)">CECIL0_9;$(DefineConstants)</DefineConstants>
|
||||||
|
<CecilVersion Condition="$(CecilLegacy) And '$(CecilVersion)' == ''">0.9.6</CecilVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- <Reference Include="mscorlib" /> -->
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Otherwise>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
|
<!-- Mono.Cecil reference. -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<CecilVersion Condition="'$(CecilVersion)' == ''">0.10.3</CecilVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition="$(Cecil)">
|
||||||
|
<PackageReference Include="Mono.Cecil">
|
||||||
|
<Version>$(CecilVersion)</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Shared source files. -->
|
||||||
|
<ItemGroup >
|
||||||
|
<Compile Condition="'$(AssemblyName)' != 'MonoMod'" Include="..\MonoMod\Properties\AssemblyInfo.Common.cs">
|
||||||
|
<Link>AssemblyInfo.Common.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Condition="'$(AssemblyName)' != 'MonoMod.Utils'" Include="..\MonoMod.Utils\NETStandardShims.cs">
|
||||||
|
<Link>NETStandardShims.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -58,7 +58,7 @@ namespace Newtonsoft.Json
|
||||||
/// To serialize without using any default settings create a <see cref="JsonSerializer"/> with
|
/// To serialize without using any default settings create a <see cref="JsonSerializer"/> with
|
||||||
/// <see cref="JsonSerializer.Create()"/>.
|
/// <see cref="JsonSerializer.Create()"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Serialization.Func<JsonSerializerSettings> DefaultSettings { get; set; }
|
public static Func<JsonSerializerSettings> DefaultSettings { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents JavaScript's boolean value <c>true</c> as a string. This field is read-only.
|
/// Represents JavaScript's boolean value <c>true</c> as a string. This field is read-only.
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace Newtonsoft.Json
|
||||||
{
|
{
|
||||||
ReferenceResolverProvider = (value != null)
|
ReferenceResolverProvider = (value != null)
|
||||||
? () => value
|
? () => value
|
||||||
: (Serialization.Func<IReferenceResolver>)null;
|
: (Func<IReferenceResolver>)null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ namespace Newtonsoft.Json
|
||||||
/// Gets or sets a function that creates the <see cref="IReferenceResolver"/> used by the serializer when resolving references.
|
/// Gets or sets a function that creates the <see cref="IReferenceResolver"/> used by the serializer when resolving references.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>A function that creates the <see cref="IReferenceResolver"/> used by the serializer when resolving references.</value>
|
/// <value>A function that creates the <see cref="IReferenceResolver"/> used by the serializer when resolving references.</value>
|
||||||
public Serialization.Func<IReferenceResolver> ReferenceResolverProvider { get; set; }
|
public Func<IReferenceResolver> ReferenceResolverProvider { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the <see cref="ITraceWriter"/> used by the serializer when writing trace messages.
|
/// Gets or sets the <see cref="ITraceWriter"/> used by the serializer when writing trace messages.
|
||||||
|
|
|
@ -349,7 +349,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
contract.MemberSerialization = JsonTypeReflector.GetObjectMemberSerialization(contract.NonNullableUnderlyingType, ignoreSerializableAttribute);
|
contract.MemberSerialization = JsonTypeReflector.GetObjectMemberSerialization(contract.NonNullableUnderlyingType, ignoreSerializableAttribute);
|
||||||
contract.Properties.AddRange(CreateProperties(contract.NonNullableUnderlyingType, contract.MemberSerialization));
|
contract.Properties.AddRange(CreateProperties(contract.NonNullableUnderlyingType, contract.MemberSerialization));
|
||||||
|
|
||||||
Serialization.Func<string, string> extensionDataNameResolver = null;
|
Func<string, string> extensionDataNameResolver = null;
|
||||||
|
|
||||||
JsonObjectAttribute attribute = JsonTypeReflector.GetCachedAttribute<JsonObjectAttribute>(contract.NonNullableUnderlyingType);
|
JsonObjectAttribute attribute = JsonTypeReflector.GetCachedAttribute<JsonObjectAttribute>(contract.NonNullableUnderlyingType);
|
||||||
if (attribute != null)
|
if (attribute != null)
|
||||||
|
@ -511,14 +511,14 @@ namespace Newtonsoft.Json.Serialization
|
||||||
createdType = t;
|
createdType = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serialization.Func<object, object> getExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(member);
|
Func<object, object> getExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(member);
|
||||||
|
|
||||||
if (extensionDataAttribute.ReadData)
|
if (extensionDataAttribute.ReadData)
|
||||||
{
|
{
|
||||||
Serialization.Action<object, object> setExtensionDataDictionary = (ReflectionUtils.CanSetMemberValue(member, true, false))
|
Action<object, object> setExtensionDataDictionary = (ReflectionUtils.CanSetMemberValue(member, true, false))
|
||||||
? JsonTypeReflector.ReflectionDelegateFactory.CreateSet<object>(member)
|
? JsonTypeReflector.ReflectionDelegateFactory.CreateSet<object>(member)
|
||||||
: null;
|
: null;
|
||||||
Serialization.Func<object> createExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
|
Func<object> createExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
|
||||||
MethodInfo setMethod = t.GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, valueType, new[] { keyType }, null)?.GetSetMethod();
|
MethodInfo setMethod = t.GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, valueType, new[] { keyType }, null)?.GetSetMethod();
|
||||||
if (setMethod == null)
|
if (setMethod == null)
|
||||||
{
|
{
|
||||||
|
@ -775,7 +775,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
return JsonTypeReflector.GetJsonConverter(objectType);
|
return JsonTypeReflector.GetJsonConverter(objectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Serialization.Func<object> GetDefaultCreator(Type createdType)
|
private Func<object> GetDefaultCreator(Type createdType)
|
||||||
{
|
{
|
||||||
return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
|
return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
|
||||||
}
|
}
|
||||||
|
@ -1397,14 +1397,14 @@ namespace Newtonsoft.Json.Serialization
|
||||||
IValueProvider valueProvider;
|
IValueProvider valueProvider;
|
||||||
|
|
||||||
#if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0)
|
#if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0)
|
||||||
//if (DynamicCodeGeneration)
|
if (DynamicCodeGeneration)
|
||||||
//{
|
{
|
||||||
// valueProvider = new DynamicValueProvider(member);
|
valueProvider = new DynamicValueProvider(member);
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
valueProvider = new ReflectionValueProvider(member);
|
valueProvider = new ReflectionValueProvider(member);
|
||||||
//}
|
}
|
||||||
#elif !(PORTABLE40)
|
#elif !(PORTABLE40)
|
||||||
valueProvider = new ExpressionValueProvider(member);
|
valueProvider = new ExpressionValueProvider(member);
|
||||||
#else
|
#else
|
||||||
|
@ -1652,7 +1652,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serialization.Func<object, object> specifiedPropertyGet = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(specifiedMember);
|
Func<object, object> specifiedPropertyGet = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(specifiedMember);
|
||||||
|
|
||||||
property.GetIsSpecified = o => (bool)specifiedPropertyGet(o);
|
property.GetIsSpecified = o => (bool)specifiedPropertyGet(o);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace Newtonsoft.Json.Serialization
|
||||||
public class DynamicValueProvider : IValueProvider
|
public class DynamicValueProvider : IValueProvider
|
||||||
{
|
{
|
||||||
private readonly MemberInfo _memberInfo;
|
private readonly MemberInfo _memberInfo;
|
||||||
private Serialization.Func<object, object> _getter;
|
private Func<object, object> _getter;
|
||||||
private Serialization.Action<object, object> _setter;
|
private Action<object, object> _setter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DynamicValueProvider"/> class.
|
/// Initializes a new instance of the <see cref="DynamicValueProvider"/> class.
|
||||||
|
|
|
@ -43,8 +43,8 @@ namespace Newtonsoft.Json.Serialization
|
||||||
public class ExpressionValueProvider : IValueProvider
|
public class ExpressionValueProvider : IValueProvider
|
||||||
{
|
{
|
||||||
private readonly MemberInfo _memberInfo;
|
private readonly MemberInfo _memberInfo;
|
||||||
private Serialization.Func<object, object> _getter;
|
private Func<object, object> _getter;
|
||||||
private Serialization.Action<object, object> _setter;
|
private Action<object, object> _setter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ExpressionValueProvider"/> class.
|
/// Initializes a new instance of the <see cref="ExpressionValueProvider"/> class.
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
|
|
||||||
private Type _genericWrapperType;
|
private Type _genericWrapperType;
|
||||||
private ObjectConstructor<object> _genericWrapperCreator;
|
private ObjectConstructor<object> _genericWrapperCreator;
|
||||||
private Serialization.Func<object> _genericTemporaryCollectionCreator;
|
private Func<object> _genericTemporaryCollectionCreator;
|
||||||
|
|
||||||
internal bool IsArray { get; }
|
internal bool IsArray { get; }
|
||||||
internal bool ShouldCreateWrapper { get; }
|
internal bool ShouldCreateWrapper { get; }
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// Gets or sets the default creator method used to create the object.
|
/// Gets or sets the default creator method used to create the object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The default creator method used to create the object.</value>
|
/// <value>The default creator method used to create the object.</value>
|
||||||
public Serialization.Func<object> DefaultCreator { get; set; }
|
public Func<object> DefaultCreator { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the default creator is non-public.
|
/// Gets or sets a value indicating whether the default creator is non-public.
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// Gets or sets the dictionary key resolver.
|
/// Gets or sets the dictionary key resolver.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The dictionary key resolver.</value>
|
/// <value>The dictionary key resolver.</value>
|
||||||
public Serialization.Func<string, string> DictionaryKeyResolver { get; set; }
|
public Func<string, string> DictionaryKeyResolver { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="System.Type"/> of the dictionary keys.
|
/// Gets the <see cref="System.Type"/> of the dictionary keys.
|
||||||
|
@ -66,7 +66,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
private Type _genericWrapperType;
|
private Type _genericWrapperType;
|
||||||
private ObjectConstructor<object> _genericWrapperCreator;
|
private ObjectConstructor<object> _genericWrapperCreator;
|
||||||
|
|
||||||
private Serialization.Func<object> _genericTemporaryDictionaryCreator;
|
private Func<object> _genericTemporaryDictionaryCreator;
|
||||||
|
|
||||||
internal bool ShouldCreateWrapper { get; }
|
internal bool ShouldCreateWrapper { get; }
|
||||||
|
|
||||||
|
|
|
@ -46,26 +46,26 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// Gets or sets the property name resolver.
|
/// Gets or sets the property name resolver.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The property name resolver.</value>
|
/// <value>The property name resolver.</value>
|
||||||
public Serialization.Func<string, string> PropertyNameResolver { get; set; }
|
public Func<string, string> PropertyNameResolver { get; set; }
|
||||||
|
|
||||||
private readonly ThreadSafeStore<string, CallSite<Serialization.Func<CallSite, object, object>>> _callSiteGetters =
|
private readonly ThreadSafeStore<string, CallSite<Func<CallSite, object, object>>> _callSiteGetters =
|
||||||
new ThreadSafeStore<string, CallSite<Serialization.Func<CallSite, object, object>>>(CreateCallSiteGetter);
|
new ThreadSafeStore<string, CallSite<Func<CallSite, object, object>>>(CreateCallSiteGetter);
|
||||||
|
|
||||||
private readonly ThreadSafeStore<string, CallSite<Serialization.Func<CallSite, object, object, object>>> _callSiteSetters =
|
private readonly ThreadSafeStore<string, CallSite<Func<CallSite, object, object, object>>> _callSiteSetters =
|
||||||
new ThreadSafeStore<string, CallSite<Serialization.Func<CallSite, object, object, object>>>(CreateCallSiteSetter);
|
new ThreadSafeStore<string, CallSite<Func<CallSite, object, object, object>>>(CreateCallSiteSetter);
|
||||||
|
|
||||||
private static CallSite<Serialization.Func<CallSite, object, object>> CreateCallSiteGetter(string name)
|
private static CallSite<Func<CallSite, object, object>> CreateCallSiteGetter(string name)
|
||||||
{
|
{
|
||||||
GetMemberBinder getMemberBinder = (GetMemberBinder)DynamicUtils.BinderWrapper.GetMember(name, typeof(DynamicUtils));
|
GetMemberBinder getMemberBinder = (GetMemberBinder)DynamicUtils.BinderWrapper.GetMember(name, typeof(DynamicUtils));
|
||||||
|
|
||||||
return CallSite<Serialization.Func<CallSite, object, object>>.Create(new NoThrowGetBinderMember(getMemberBinder));
|
return CallSite<Func<CallSite, object, object>>.Create(new NoThrowGetBinderMember(getMemberBinder));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CallSite<Serialization.Func<CallSite, object, object, object>> CreateCallSiteSetter(string name)
|
private static CallSite<Func<CallSite, object, object, object>> CreateCallSiteSetter(string name)
|
||||||
{
|
{
|
||||||
SetMemberBinder binder = (SetMemberBinder)DynamicUtils.BinderWrapper.SetMember(name, typeof(DynamicUtils));
|
SetMemberBinder binder = (SetMemberBinder)DynamicUtils.BinderWrapper.SetMember(name, typeof(DynamicUtils));
|
||||||
|
|
||||||
return CallSite<Serialization.Func<CallSite, object, object, object>>.Create(new NoThrowSetBinderMember(binder));
|
return CallSite<Func<CallSite, object, object, object>>.Create(new NoThrowSetBinderMember(binder));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -84,7 +84,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider));
|
ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider));
|
||||||
|
|
||||||
CallSite<Serialization.Func<CallSite, object, object>> callSite = _callSiteGetters.Get(name);
|
CallSite<Func<CallSite, object, object>> callSite = _callSiteGetters.Get(name);
|
||||||
|
|
||||||
object result = callSite.Target(callSite, dynamicProvider);
|
object result = callSite.Target(callSite, dynamicProvider);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider));
|
ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider));
|
||||||
|
|
||||||
CallSite<Serialization.Func<CallSite, object, object, object>> callSite = _callSiteSetters.Get(name);
|
CallSite<Func<CallSite, object, object, object>> callSite = _callSiteSetters.Get(name);
|
||||||
|
|
||||||
object result = callSite.Target(callSite, dynamicProvider, value);
|
object result = callSite.Target(callSite, dynamicProvider, value);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// Gets or sets the extension data name resolver.
|
/// Gets or sets the extension data name resolver.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The extension data name resolver.</value>
|
/// <value>The extension data name resolver.</value>
|
||||||
public Serialization.Func<string, string> ExtensionDataNameResolver { get; set; }
|
public Func<string, string> ExtensionDataNameResolver { get; set; }
|
||||||
|
|
||||||
internal bool ExtensionDataIsJToken;
|
internal bool ExtensionDataIsJToken;
|
||||||
private bool? _hasRequiredOrDefaultValueProperties;
|
private bool? _hasRequiredOrDefaultValueProperties;
|
||||||
|
|
|
@ -266,7 +266,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// Gets or sets an action used to set whether the property has been deserialized.
|
/// Gets or sets an action used to set whether the property has been deserialized.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>An action used to set whether the property has been deserialized.</value>
|
/// <value>An action used to set whether the property has been deserialized.</value>
|
||||||
public Serialization.Action<object, object> SetIsSpecified { get; set; }
|
public Action<object, object> SetIsSpecified { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="String"/> that represents this instance.
|
/// Returns a <see cref="String"/> that represents this instance.
|
||||||
|
|
|
@ -58,8 +58,8 @@ namespace Newtonsoft.Json.Serialization
|
||||||
|
|
||||||
public const string ConcurrentDictionaryTypeName = "System.Collections.Concurrent.ConcurrentDictionary`2";
|
public const string ConcurrentDictionaryTypeName = "System.Collections.Concurrent.ConcurrentDictionary`2";
|
||||||
|
|
||||||
private static readonly ThreadSafeStore<Type, Serialization.Func<object[], object>> CreatorCache =
|
private static readonly ThreadSafeStore<Type, Func<object[], object>> CreatorCache =
|
||||||
new ThreadSafeStore<Type, Serialization.Func<object[], object>>(GetCreator);
|
new ThreadSafeStore<Type, Func<object[], object>>(GetCreator);
|
||||||
|
|
||||||
#if !(NET20 || DOTNET)
|
#if !(NET20 || DOTNET)
|
||||||
private static readonly ThreadSafeStore<Type, Type> AssociatedMetadataTypesCache = new ThreadSafeStore<Type, Type>(GetAssociateMetadataTypeFromAttribute);
|
private static readonly ThreadSafeStore<Type, Type> AssociatedMetadataTypesCache = new ThreadSafeStore<Type, Type>(GetAssociateMetadataTypeFromAttribute);
|
||||||
|
@ -184,7 +184,7 @@ namespace Newtonsoft.Json.Serialization
|
||||||
|
|
||||||
if (converterAttribute != null)
|
if (converterAttribute != null)
|
||||||
{
|
{
|
||||||
Serialization.Func<object[], object> creator = CreatorCache.Get(converterAttribute.ConverterType);
|
Func<object[], object> creator = CreatorCache.Get(converterAttribute.ConverterType);
|
||||||
if (creator != null)
|
if (creator != null)
|
||||||
{
|
{
|
||||||
return (JsonConverter)creator(converterAttribute.ConverterParameters);
|
return (JsonConverter)creator(converterAttribute.ConverterParameters);
|
||||||
|
@ -202,13 +202,13 @@ namespace Newtonsoft.Json.Serialization
|
||||||
/// If <c>null</c>, the default constructor is used.</param>
|
/// If <c>null</c>, the default constructor is used.</param>
|
||||||
public static JsonConverter CreateJsonConverterInstance(Type converterType, object[] args)
|
public static JsonConverter CreateJsonConverterInstance(Type converterType, object[] args)
|
||||||
{
|
{
|
||||||
Serialization.Func<object[], object> converterCreator = CreatorCache.Get(converterType);
|
Func<object[], object> converterCreator = CreatorCache.Get(converterType);
|
||||||
return (JsonConverter)converterCreator(args);
|
return (JsonConverter)converterCreator(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NamingStrategy CreateNamingStrategyInstance(Type namingStrategyType, object[] args)
|
public static NamingStrategy CreateNamingStrategyInstance(Type namingStrategyType, object[] args)
|
||||||
{
|
{
|
||||||
Serialization.Func<object[], object> converterCreator = CreatorCache.Get(namingStrategyType);
|
Func<object[], object> converterCreator = CreatorCache.Get(namingStrategyType);
|
||||||
return (NamingStrategy)converterCreator(args);
|
return (NamingStrategy)converterCreator(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,9 +227,9 @@ namespace Newtonsoft.Json.Serialization
|
||||||
return containerAttribute.NamingStrategyInstance;
|
return containerAttribute.NamingStrategyInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Serialization.Func<object[], object> GetCreator(Type type)
|
private static Func<object[], object> GetCreator(Type type)
|
||||||
{
|
{
|
||||||
Serialization.Func<object> defaultConstructor = (ReflectionUtils.HasDefaultConstructor(type, false))
|
Func<object> defaultConstructor = (ReflectionUtils.HasDefaultConstructor(type, false))
|
||||||
? ReflectionDelegateFactory.CreateDefaultConstructor<object>(type)
|
? ReflectionDelegateFactory.CreateDefaultConstructor<object>(type)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
@ -516,10 +516,10 @@ namespace Newtonsoft.Json.Serialization
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0)
|
#if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0)
|
||||||
//if (DynamicCodeGeneration)
|
if (DynamicCodeGeneration)
|
||||||
//{
|
{
|
||||||
// return DynamicReflectionDelegateFactory.Instance;
|
return DynamicReflectionDelegateFactory.Instance;
|
||||||
//}
|
}
|
||||||
|
|
||||||
return LateBoundReflectionDelegateFactory.Instance;
|
return LateBoundReflectionDelegateFactory.Instance;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
return allAdded;
|
return allAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int IndexOf<T>(this IEnumerable<T> collection, Serialization.Func<T, bool> predicate)
|
public static int IndexOf<T>(this IEnumerable<T> collection, Func<T, bool> predicate)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (T value in collection)
|
foreach (T value in collection)
|
||||||
|
|
|
@ -248,10 +248,10 @@ namespace Newtonsoft.Json.Utilities
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly ThreadSafeStore<StructMultiKey<Type, Type>, Serialization.Func<object, object>> CastConverters =
|
private static readonly ThreadSafeStore<StructMultiKey<Type, Type>, Func<object, object>> CastConverters =
|
||||||
new ThreadSafeStore<StructMultiKey<Type, Type>, Serialization.Func<object, object>>(CreateCastConverter);
|
new ThreadSafeStore<StructMultiKey<Type, Type>, Func<object, object>>(CreateCastConverter);
|
||||||
|
|
||||||
private static Serialization.Func<object, object> CreateCastConverter(StructMultiKey<Type, Type> t)
|
private static Func<object, object> CreateCastConverter(StructMultiKey<Type, Type> t)
|
||||||
{
|
{
|
||||||
Type initialType = t.Value1;
|
Type initialType = t.Value1;
|
||||||
Type targetType = t.Value2;
|
Type targetType = t.Value2;
|
||||||
|
@ -599,7 +599,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serialization.Func<object, object> castConverter = CastConverters.Get(new StructMultiKey<Type, Type>(valueType, targetType));
|
Func<object, object> castConverter = CastConverters.Get(new StructMultiKey<Type, Type>(valueType, targetType));
|
||||||
if (castConverter != null)
|
if (castConverter != null)
|
||||||
{
|
{
|
||||||
return castConverter(value);
|
return castConverter(value);
|
||||||
|
|
|
@ -239,7 +239,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
generator.Return();
|
generator.Return();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T> CreateDefaultConstructor<T>(Type type)
|
public override Func<T> CreateDefaultConstructor<T>(Type type)
|
||||||
{
|
{
|
||||||
DynamicMethod dynamicMethod = CreateDynamicMethod("Create" + type.FullName, typeof(T), ReflectionUtils.EmptyTypes, type);
|
DynamicMethod dynamicMethod = CreateDynamicMethod("Create" + type.FullName, typeof(T), ReflectionUtils.EmptyTypes, type);
|
||||||
dynamicMethod.InitLocals = true;
|
dynamicMethod.InitLocals = true;
|
||||||
|
@ -247,7 +247,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
GenerateCreateDefaultConstructorIL(type, generator, typeof(T));
|
GenerateCreateDefaultConstructorIL(type, generator, typeof(T));
|
||||||
|
|
||||||
return (Serialization.Func<T>)dynamicMethod.CreateDelegate(typeof(Serialization.Func<T>));
|
return (Func<T>)dynamicMethod.CreateDelegate(typeof(Func<T>));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateCreateDefaultConstructorIL(Type type, ILGenerator generator, Type delegateType)
|
private void GenerateCreateDefaultConstructorIL(Type type, ILGenerator generator, Type delegateType)
|
||||||
|
@ -279,14 +279,14 @@ namespace Newtonsoft.Json.Utilities
|
||||||
generator.Return();
|
generator.Return();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
DynamicMethod dynamicMethod = CreateDynamicMethod("Get" + propertyInfo.Name, typeof(object), new[] { typeof(T) }, propertyInfo.DeclaringType);
|
DynamicMethod dynamicMethod = CreateDynamicMethod("Get" + propertyInfo.Name, typeof(object), new[] { typeof(T) }, propertyInfo.DeclaringType);
|
||||||
ILGenerator generator = dynamicMethod.GetILGenerator();
|
ILGenerator generator = dynamicMethod.GetILGenerator();
|
||||||
|
|
||||||
GenerateCreateGetPropertyIL(propertyInfo, generator);
|
GenerateCreateGetPropertyIL(propertyInfo, generator);
|
||||||
|
|
||||||
return (Serialization.Func<T, object>)dynamicMethod.CreateDelegate(typeof(Serialization.Func<T, object>));
|
return (Func<T, object>)dynamicMethod.CreateDelegate(typeof(Func<T, object>));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateCreateGetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator)
|
private void GenerateCreateGetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator)
|
||||||
|
@ -307,12 +307,12 @@ namespace Newtonsoft.Json.Utilities
|
||||||
generator.Return();
|
generator.Return();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
public override Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
if (fieldInfo.IsLiteral)
|
if (fieldInfo.IsLiteral)
|
||||||
{
|
{
|
||||||
object constantValue = fieldInfo.GetValue(null);
|
object constantValue = fieldInfo.GetValue(null);
|
||||||
Serialization.Func<T, object> getter = o => constantValue;
|
Func<T, object> getter = o => constantValue;
|
||||||
return getter;
|
return getter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
GenerateCreateGetFieldIL(fieldInfo, generator);
|
GenerateCreateGetFieldIL(fieldInfo, generator);
|
||||||
|
|
||||||
return (Serialization.Func<T, object>)dynamicMethod.CreateDelegate(typeof(Serialization.Func<T, object>));
|
return (Func<T, object>)dynamicMethod.CreateDelegate(typeof(Func<T, object>));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateCreateGetFieldIL(FieldInfo fieldInfo, ILGenerator generator)
|
private void GenerateCreateGetFieldIL(FieldInfo fieldInfo, ILGenerator generator)
|
||||||
|
@ -340,14 +340,14 @@ namespace Newtonsoft.Json.Utilities
|
||||||
generator.Return();
|
generator.Return();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
public override Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + fieldInfo.Name, null, new[] { typeof(T), typeof(object) }, fieldInfo.DeclaringType);
|
DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + fieldInfo.Name, null, new[] { typeof(T), typeof(object) }, fieldInfo.DeclaringType);
|
||||||
ILGenerator generator = dynamicMethod.GetILGenerator();
|
ILGenerator generator = dynamicMethod.GetILGenerator();
|
||||||
|
|
||||||
GenerateCreateSetFieldIL(fieldInfo, generator);
|
GenerateCreateSetFieldIL(fieldInfo, generator);
|
||||||
|
|
||||||
return (Serialization.Action<T, object>)dynamicMethod.CreateDelegate(typeof(Serialization.Action<T, object>));
|
return (Action<T, object>)dynamicMethod.CreateDelegate(typeof(Action<T, object>));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GenerateCreateSetFieldIL(FieldInfo fieldInfo, ILGenerator generator)
|
internal static void GenerateCreateSetFieldIL(FieldInfo fieldInfo, ILGenerator generator)
|
||||||
|
@ -372,14 +372,14 @@ namespace Newtonsoft.Json.Utilities
|
||||||
generator.Return();
|
generator.Return();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
public override Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + propertyInfo.Name, null, new[] { typeof(T), typeof(object) }, propertyInfo.DeclaringType);
|
DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + propertyInfo.Name, null, new[] { typeof(T), typeof(object) }, propertyInfo.DeclaringType);
|
||||||
ILGenerator generator = dynamicMethod.GetILGenerator();
|
ILGenerator generator = dynamicMethod.GetILGenerator();
|
||||||
|
|
||||||
GenerateCreateSetPropertyIL(propertyInfo, generator);
|
GenerateCreateSetPropertyIL(propertyInfo, generator);
|
||||||
|
|
||||||
return (Serialization.Action<T, object>)dynamicMethod.CreateDelegate(typeof(Serialization.Action<T, object>));
|
return (Action<T, object>)dynamicMethod.CreateDelegate(typeof(Action<T, object>));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GenerateCreateSetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator)
|
internal static void GenerateCreateSetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator)
|
||||||
|
|
|
@ -180,7 +180,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
return callExpression;
|
return callExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T> CreateDefaultConstructor<T>(Type type)
|
public override Func<T> CreateDefaultConstructor<T>(Type type)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(type, "type");
|
ValidationUtils.ArgumentNotNull(type, "type");
|
||||||
|
|
||||||
|
@ -198,9 +198,9 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
expression = EnsureCastExpression(expression, resultType);
|
expression = EnsureCastExpression(expression, resultType);
|
||||||
|
|
||||||
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Func<T>), expression);
|
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T>), expression);
|
||||||
|
|
||||||
Serialization.Func<T> compiled = (Serialization.Func<T>)lambdaExpression.Compile();
|
Func<T> compiled = (Func<T>)lambdaExpression.Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -211,7 +211,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
||||||
|
|
||||||
|
@ -236,13 +236,13 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
resultExpression = EnsureCastExpression(resultExpression, resultType);
|
resultExpression = EnsureCastExpression(resultExpression, resultType);
|
||||||
|
|
||||||
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Func<T, object>), resultExpression, parameterExpression);
|
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T, object>), resultExpression, parameterExpression);
|
||||||
|
|
||||||
Serialization.Func<T, object> compiled = (Serialization.Func<T, object>)lambdaExpression.Compile();
|
Func<T, object> compiled = (Func<T, object>)lambdaExpression.Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
public override Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
||||||
|
|
||||||
|
@ -262,11 +262,11 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
fieldExpression = EnsureCastExpression(fieldExpression, typeof(object));
|
fieldExpression = EnsureCastExpression(fieldExpression, typeof(object));
|
||||||
|
|
||||||
Serialization.Func<T, object> compiled = Expression.Lambda<Serialization.Func<T, object>>(fieldExpression, sourceParameter).Compile();
|
Func<T, object> compiled = Expression.Lambda<Func<T, object>>(fieldExpression, sourceParameter).Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
public override Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
||||||
|
|
||||||
|
@ -296,13 +296,13 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
BinaryExpression assignExpression = Expression.Assign(fieldExpression, valueExpression);
|
BinaryExpression assignExpression = Expression.Assign(fieldExpression, valueExpression);
|
||||||
|
|
||||||
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Action<T, object>), assignExpression, sourceParameterExpression, valueParameterExpression);
|
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action<T, object>), assignExpression, sourceParameterExpression, valueParameterExpression);
|
||||||
|
|
||||||
Serialization.Action<T, object> compiled = (Serialization.Action<T, object>)lambdaExpression.Compile();
|
Action<T, object> compiled = (Action<T, object>)lambdaExpression.Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
public override Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
||||||
|
|
||||||
|
@ -335,9 +335,9 @@ namespace Newtonsoft.Json.Utilities
|
||||||
setExpression = Expression.Call(readInstanceParameter, setMethod, readValueParameter);
|
setExpression = Expression.Call(readInstanceParameter, setMethod, readValueParameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Action<T, object>), setExpression, instanceParameter, valueParameter);
|
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action<T, object>), setExpression, instanceParameter, valueParameter);
|
||||||
|
|
||||||
Serialization.Action<T, object> compiled = (Serialization.Action<T, object>)lambdaExpression.Compile();
|
Action<T, object> compiled = (Action<T, object>)lambdaExpression.Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,9 @@ namespace Newtonsoft.Json.Utilities
|
||||||
public static MethodCall<object, object> PreComputeUnionTagReader { get; private set; }
|
public static MethodCall<object, object> PreComputeUnionTagReader { get; private set; }
|
||||||
public static MethodCall<object, object> PreComputeUnionReader { get; private set; }
|
public static MethodCall<object, object> PreComputeUnionReader { get; private set; }
|
||||||
public static MethodCall<object, object> PreComputeUnionConstructor { get; private set; }
|
public static MethodCall<object, object> PreComputeUnionConstructor { get; private set; }
|
||||||
public static Serialization.Func<object, object> GetUnionCaseInfoDeclaringType { get; private set; }
|
public static Func<object, object> GetUnionCaseInfoDeclaringType { get; private set; }
|
||||||
public static Serialization.Func<object, object> GetUnionCaseInfoName { get; private set; }
|
public static Func<object, object> GetUnionCaseInfoName { get; private set; }
|
||||||
public static Serialization.Func<object, object> GetUnionCaseInfoTag { get; private set; }
|
public static Func<object, object> GetUnionCaseInfoTag { get; private set; }
|
||||||
public static MethodCall<object, object> GetUnionCaseInfoFields { get; private set; }
|
public static MethodCall<object, object> GetUnionCaseInfoFields { get; private set; }
|
||||||
|
|
||||||
public const string FSharpSetTypeName = "FSharpSet`1";
|
public const string FSharpSetTypeName = "FSharpSet`1";
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
return (o, a) => method.Invoke(o, a);
|
return (o, a) => method.Invoke(o, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T> CreateDefaultConstructor<T>(Type type)
|
public override Func<T> CreateDefaultConstructor<T>(Type type)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(type, nameof(type));
|
ValidationUtils.ArgumentNotNull(type, nameof(type));
|
||||||
|
|
||||||
|
@ -79,28 +79,28 @@ namespace Newtonsoft.Json.Utilities
|
||||||
return () => (T)constructorInfo.Invoke(null);
|
return () => (T)constructorInfo.Invoke(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
||||||
|
|
||||||
return o => propertyInfo.GetValue(o, null);
|
return o => propertyInfo.GetValue(o, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
public override Func<T, object> CreateGet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
||||||
|
|
||||||
return o => fieldInfo.GetValue(o);
|
return o => fieldInfo.GetValue(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
public override Action<T, object> CreateSet<T>(FieldInfo fieldInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo));
|
||||||
|
|
||||||
return (o, v) => fieldInfo.SetValue(o, v);
|
return (o, v) => fieldInfo.SetValue(o, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Serialization.Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
public override Action<T, object> CreateSet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo));
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> Where<TSource>(
|
public static IEnumerable<TSource> Where<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TSource> WhereYield<TSource>(
|
private static IEnumerable<TSource> WhereYield<TSource>(
|
||||||
IEnumerable<TSource> source,
|
IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
if (predicate(item))
|
if (predicate(item))
|
||||||
|
@ -179,7 +179,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> Where<TSource>(
|
public static IEnumerable<TSource> Where<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
@ -189,7 +189,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TSource> WhereYield<TSource>(
|
private static IEnumerable<TSource> WhereYield<TSource>(
|
||||||
IEnumerable<TSource> source,
|
IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
|
@ -203,7 +203,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> Select<TSource, TResult>(
|
public static IEnumerable<TResult> Select<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TResult> selector)
|
Func<TSource, TResult> selector)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(selector, "selector");
|
CheckNotNull(selector, "selector");
|
||||||
|
@ -213,7 +213,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TResult> SelectYield<TSource, TResult>(
|
private static IEnumerable<TResult> SelectYield<TSource, TResult>(
|
||||||
IEnumerable<TSource> source,
|
IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TResult> selector)
|
Func<TSource, TResult> selector)
|
||||||
{
|
{
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
yield return selector(item);
|
yield return selector(item);
|
||||||
|
@ -226,7 +226,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> Select<TSource, TResult>(
|
public static IEnumerable<TResult> Select<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, TResult> selector)
|
Func<TSource, int, TResult> selector)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(selector, "selector");
|
CheckNotNull(selector, "selector");
|
||||||
|
@ -236,7 +236,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TResult> SelectYield<TSource, TResult>(
|
private static IEnumerable<TResult> SelectYield<TSource, TResult>(
|
||||||
IEnumerable<TSource> source,
|
IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, TResult> selector)
|
Func<TSource, int, TResult> selector)
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
|
@ -250,7 +250,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> SelectMany<TSource, TResult>(
|
public static IEnumerable<TResult> SelectMany<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, IEnumerable<TResult>> selector)
|
Func<TSource, IEnumerable<TResult>> selector)
|
||||||
{
|
{
|
||||||
CheckNotNull(selector, "selector");
|
CheckNotNull(selector, "selector");
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> SelectMany<TSource, TResult>(
|
public static IEnumerable<TResult> SelectMany<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, IEnumerable<TResult>> selector)
|
Func<TSource, int, IEnumerable<TResult>> selector)
|
||||||
{
|
{
|
||||||
CheckNotNull(selector, "selector");
|
CheckNotNull(selector, "selector");
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(
|
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, IEnumerable<TCollection>> collectionSelector,
|
Func<TSource, IEnumerable<TCollection>> collectionSelector,
|
||||||
Serialization.Func<TSource, TCollection, TResult> resultSelector)
|
Func<TSource, TCollection, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
CheckNotNull(collectionSelector, "collectionSelector");
|
CheckNotNull(collectionSelector, "collectionSelector");
|
||||||
|
|
||||||
|
@ -299,8 +299,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(
|
public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
|
Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
|
||||||
Serialization.Func<TSource, TCollection, TResult> resultSelector)
|
Func<TSource, TCollection, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(collectionSelector, "collectionSelector");
|
CheckNotNull(collectionSelector, "collectionSelector");
|
||||||
|
@ -311,8 +311,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TResult> SelectManyYield<TSource, TCollection, TResult>(
|
private static IEnumerable<TResult> SelectManyYield<TSource, TCollection, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
|
Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
|
||||||
Serialization.Func<TSource, TCollection, TResult> resultSelector)
|
Func<TSource, TCollection, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
|
@ -326,7 +326,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> TakeWhile<TSource>(
|
public static IEnumerable<TSource> TakeWhile<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> TakeWhile<TSource>(
|
public static IEnumerable<TSource> TakeWhile<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
@ -350,7 +350,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TSource> TakeWhileYield<TSource>(
|
private static IEnumerable<TSource> TakeWhileYield<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var item in source)
|
foreach (var item in source)
|
||||||
|
@ -362,8 +362,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static class Futures<T>
|
private static class Futures<T>
|
||||||
{
|
{
|
||||||
public static readonly Serialization.Func<T> Default = () => default(T);
|
public static readonly Func<T> Default = () => default(T);
|
||||||
public static readonly Serialization.Func<T> Undefined = () => { throw new InvalidOperationException(); };
|
public static readonly Func<T> Undefined = () => { throw new InvalidOperationException(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -372,7 +372,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static TSource FirstImpl<TSource>(
|
private static TSource FirstImpl<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource> empty)
|
Func<TSource> empty)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
Debug.Assert(empty != null);
|
Debug.Assert(empty != null);
|
||||||
|
@ -401,7 +401,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource First<TSource>(
|
public static TSource First<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return First(source.Where(predicate));
|
return First(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource FirstOrDefault<TSource>(
|
public static TSource FirstOrDefault<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return FirstOrDefault(source.Where(predicate));
|
return FirstOrDefault(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static TSource LastImpl<TSource>(
|
private static TSource LastImpl<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource> empty)
|
Func<TSource> empty)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource Last<TSource>(
|
public static TSource Last<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return Last(source.Where(predicate));
|
return Last(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource LastOrDefault<TSource>(
|
public static TSource LastOrDefault<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return LastOrDefault(source.Where(predicate));
|
return LastOrDefault(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static TSource SingleImpl<TSource>(
|
private static TSource SingleImpl<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource> empty)
|
Func<TSource> empty)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource Single<TSource>(
|
public static TSource Single<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return Single(source.Where(predicate));
|
return Single(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource SingleOrDefault<TSource>(
|
public static TSource SingleOrDefault<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return SingleOrDefault(source.Where(predicate));
|
return SingleOrDefault(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> SkipWhile<TSource>(
|
public static IEnumerable<TSource> SkipWhile<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TSource> SkipWhile<TSource>(
|
public static IEnumerable<TSource> SkipWhile<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
@ -699,7 +699,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static IEnumerable<TSource> SkipWhileYield<TSource>(
|
private static IEnumerable<TSource> SkipWhileYield<TSource>(
|
||||||
IEnumerable<TSource> source,
|
IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int, bool> predicate)
|
Func<TSource, int, bool> predicate)
|
||||||
{
|
{
|
||||||
using (var e = source.GetEnumerator())
|
using (var e = source.GetEnumerator())
|
||||||
{
|
{
|
||||||
|
@ -753,7 +753,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static int Count<TSource>(
|
public static int Count<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return Count(source.Where(predicate));
|
return Count(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static long LongCount<TSource>(
|
public static long LongCount<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
return LongCount(source.Where(predicate));
|
return LongCount(source.Where(predicate));
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
|
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return ToLookup(source, keySelector, e => e, /* comparer */ null);
|
return ToLookup(source, keySelector, e => e, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
|
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
return ToLookup(source, keySelector, e => e, comparer);
|
return ToLookup(source, keySelector, e => e, comparer);
|
||||||
|
@ -927,8 +927,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
|
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector)
|
Func<TSource, TElement> elementSelector)
|
||||||
{
|
{
|
||||||
return ToLookup(source, keySelector, elementSelector, /* comparer */ null);
|
return ToLookup(source, keySelector, elementSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -941,8 +941,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
|
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector,
|
Func<TSource, TElement> elementSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -975,7 +975,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
|
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return GroupBy(source, keySelector, /* comparer */ null);
|
return GroupBy(source, keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -988,7 +988,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
|
public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
return GroupBy(source, keySelector, e => e, comparer);
|
return GroupBy(source, keySelector, e => e, comparer);
|
||||||
|
@ -1002,8 +1002,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
|
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector)
|
Func<TSource, TElement> elementSelector)
|
||||||
{
|
{
|
||||||
return GroupBy(source, keySelector, elementSelector, /* comparer */ null);
|
return GroupBy(source, keySelector, elementSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1016,8 +1016,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
|
public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector,
|
Func<TSource, TElement> elementSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1035,8 +1035,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(
|
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
|
Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
return GroupBy(source, keySelector, resultSelector, /* comparer */ null);
|
return GroupBy(source, keySelector, resultSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1050,8 +1050,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(
|
public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
|
Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1069,9 +1069,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(
|
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector,
|
Func<TSource, TElement> elementSelector,
|
||||||
Serialization.Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
|
Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
return GroupBy(source, keySelector, elementSelector, resultSelector, /* comparer */ null);
|
return GroupBy(source, keySelector, elementSelector, resultSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1086,9 +1086,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(
|
public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector,
|
Func<TSource, TElement> elementSelector,
|
||||||
Serialization.Func<TKey, IEnumerable<TElement>, TResult> resultSelector,
|
Func<TKey, IEnumerable<TElement>, TResult> resultSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1106,7 +1106,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TSource Aggregate<TSource>(
|
public static TSource Aggregate<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TSource, TSource> func)
|
Func<TSource, TSource, TSource> func)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(func, "func");
|
CheckNotNull(func, "func");
|
||||||
|
@ -1128,7 +1128,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static TAccumulate Aggregate<TSource, TAccumulate>(
|
public static TAccumulate Aggregate<TSource, TAccumulate>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
TAccumulate seed,
|
TAccumulate seed,
|
||||||
Serialization.Func<TAccumulate, TSource, TAccumulate> func)
|
Func<TAccumulate, TSource, TAccumulate> func)
|
||||||
{
|
{
|
||||||
return Aggregate(source, seed, func, r => r);
|
return Aggregate(source, seed, func, r => r);
|
||||||
}
|
}
|
||||||
|
@ -1142,8 +1142,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static TResult Aggregate<TSource, TAccumulate, TResult>(
|
public static TResult Aggregate<TSource, TAccumulate, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
TAccumulate seed,
|
TAccumulate seed,
|
||||||
Serialization.Func<TAccumulate, TSource, TAccumulate> func,
|
Func<TAccumulate, TSource, TAccumulate> func,
|
||||||
Serialization.Func<TAccumulate, TResult> resultSelector)
|
Func<TAccumulate, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(func, "func");
|
CheckNotNull(func, "func");
|
||||||
|
@ -1230,7 +1230,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static bool All<TSource>(
|
public static bool All<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(predicate, "predicate");
|
CheckNotNull(predicate, "predicate");
|
||||||
|
@ -1262,7 +1262,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static bool Any<TSource>(
|
public static bool Any<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, bool> predicate)
|
Func<TSource, bool> predicate)
|
||||||
{
|
{
|
||||||
foreach (TSource item in source)
|
foreach (TSource item in source)
|
||||||
{
|
{
|
||||||
|
@ -1359,7 +1359,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static TSource MinMaxImpl<TSource>(
|
private static TSource MinMaxImpl<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TSource, bool> lesser)
|
Func<TSource, TSource, bool> lesser)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
Debug.Assert(lesser != null);
|
Debug.Assert(lesser != null);
|
||||||
|
@ -1373,7 +1373,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
private static TSource? MinMaxImpl<TSource>(
|
private static TSource? MinMaxImpl<TSource>(
|
||||||
this IEnumerable<TSource?> source,
|
this IEnumerable<TSource?> source,
|
||||||
TSource? seed, Serialization.Func<TSource?, TSource?, bool> lesser) where TSource : struct
|
TSource? seed, Func<TSource?, TSource?, bool> lesser) where TSource : struct
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
Debug.Assert(lesser != null);
|
Debug.Assert(lesser != null);
|
||||||
|
@ -1400,7 +1400,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TResult Min<TSource, TResult>(
|
public static TResult Min<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TResult> selector)
|
Func<TSource, TResult> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -1423,7 +1423,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static TResult Max<TSource, TResult>(
|
public static TResult Max<TSource, TResult>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TResult> selector)
|
Func<TSource, TResult> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -1454,7 +1454,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return source.OrderBy(keySelector, /* comparer */ null);
|
return source.OrderBy(keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1466,7 +1466,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IComparer<TKey> comparer)
|
IComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1481,7 +1481,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return source.OrderByDescending(keySelector, /* comparer */ null);
|
return source.OrderByDescending(keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1493,7 +1493,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IComparer<TKey> comparer)
|
IComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1509,7 +1509,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(
|
||||||
this IOrderedEnumerable<TSource> source,
|
this IOrderedEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return source.ThenBy(keySelector, /* comparer */ null);
|
return source.ThenBy(keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1521,7 +1521,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(
|
||||||
this IOrderedEnumerable<TSource> source,
|
this IOrderedEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IComparer<TKey> comparer)
|
IComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1536,7 +1536,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(
|
||||||
this IOrderedEnumerable<TSource> source,
|
this IOrderedEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return source.ThenByDescending(keySelector, /* comparer */ null);
|
return source.ThenByDescending(keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1548,7 +1548,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(
|
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(
|
||||||
this IOrderedEnumerable<TSource> source,
|
this IOrderedEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IComparer<TKey> comparer)
|
IComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1647,7 +1647,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
|
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector)
|
Func<TSource, TKey> keySelector)
|
||||||
{
|
{
|
||||||
return source.ToDictionary(keySelector, /* comparer */ null);
|
return source.ToDictionary(keySelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1660,7 +1660,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
|
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
return source.ToDictionary(keySelector, e => e);
|
return source.ToDictionary(keySelector, e => e);
|
||||||
|
@ -1674,8 +1674,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
|
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector)
|
Func<TSource, TElement> elementSelector)
|
||||||
{
|
{
|
||||||
return source.ToDictionary(keySelector, elementSelector, /* comparer */ null);
|
return source.ToDictionary(keySelector, elementSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1688,8 +1688,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
|
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, TKey> keySelector,
|
Func<TSource, TKey> keySelector,
|
||||||
Serialization.Func<TSource, TElement> elementSelector,
|
Func<TSource, TElement> elementSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
|
@ -1726,9 +1726,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(
|
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(
|
||||||
this IEnumerable<TOuter> outer,
|
this IEnumerable<TOuter> outer,
|
||||||
IEnumerable<TInner> inner,
|
IEnumerable<TInner> inner,
|
||||||
Serialization.Func<TOuter, TKey> outerKeySelector,
|
Func<TOuter, TKey> outerKeySelector,
|
||||||
Serialization.Func<TInner, TKey> innerKeySelector,
|
Func<TInner, TKey> innerKeySelector,
|
||||||
Serialization.Func<TOuter, TInner, TResult> resultSelector)
|
Func<TOuter, TInner, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
return outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null);
|
return outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1742,9 +1742,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(
|
public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(
|
||||||
this IEnumerable<TOuter> outer,
|
this IEnumerable<TOuter> outer,
|
||||||
IEnumerable<TInner> inner,
|
IEnumerable<TInner> inner,
|
||||||
Serialization.Func<TOuter, TKey> outerKeySelector,
|
Func<TOuter, TKey> outerKeySelector,
|
||||||
Serialization.Func<TInner, TKey> innerKeySelector,
|
Func<TInner, TKey> innerKeySelector,
|
||||||
Serialization.Func<TOuter, TInner, TResult> resultSelector,
|
Func<TOuter, TInner, TResult> resultSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(outer, "outer");
|
CheckNotNull(outer, "outer");
|
||||||
|
@ -1770,9 +1770,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
|
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
|
||||||
this IEnumerable<TOuter> outer,
|
this IEnumerable<TOuter> outer,
|
||||||
IEnumerable<TInner> inner,
|
IEnumerable<TInner> inner,
|
||||||
Serialization.Func<TOuter, TKey> outerKeySelector,
|
Func<TOuter, TKey> outerKeySelector,
|
||||||
Serialization.Func<TInner, TKey> innerKeySelector,
|
Func<TInner, TKey> innerKeySelector,
|
||||||
Serialization.Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
|
Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null);
|
return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null);
|
||||||
}
|
}
|
||||||
|
@ -1787,9 +1787,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
|
public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
|
||||||
this IEnumerable<TOuter> outer,
|
this IEnumerable<TOuter> outer,
|
||||||
IEnumerable<TInner> inner,
|
IEnumerable<TInner> inner,
|
||||||
Serialization.Func<TOuter, TKey> outerKeySelector,
|
Func<TOuter, TKey> outerKeySelector,
|
||||||
Serialization.Func<TInner, TKey> innerKeySelector,
|
Func<TInner, TKey> innerKeySelector,
|
||||||
Serialization.Func<TOuter, IEnumerable<TInner>, TResult> resultSelector,
|
Func<TOuter, IEnumerable<TInner>, TResult> resultSelector,
|
||||||
IEqualityComparer<TKey> comparer)
|
IEqualityComparer<TKey> comparer)
|
||||||
{
|
{
|
||||||
CheckNotNull(outer, "outer");
|
CheckNotNull(outer, "outer");
|
||||||
|
@ -1851,7 +1851,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static int Sum<TSource>(
|
public static int Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int> selector)
|
Func<TSource, int> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -1889,7 +1889,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double Average<TSource>(
|
public static double Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int> selector)
|
Func<TSource, int> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1919,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static int? Sum<TSource>(
|
public static int? Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int?> selector)
|
Func<TSource, int?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -1957,7 +1957,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Average<TSource>(
|
public static double? Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int?> selector)
|
Func<TSource, int?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -1982,7 +1982,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static int? Min<TSource>(
|
public static int? Min<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int?> selector)
|
Func<TSource, int?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -2008,7 +2008,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static int? Max<TSource>(
|
public static int? Max<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, int?> selector)
|
Func<TSource, int?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -2037,7 +2037,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static long Sum<TSource>(
|
public static long Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long> selector)
|
Func<TSource, long> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2075,7 +2075,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double Average<TSource>(
|
public static double Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long> selector)
|
Func<TSource, long> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2105,7 +2105,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static long? Sum<TSource>(
|
public static long? Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long?> selector)
|
Func<TSource, long?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2143,7 +2143,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Average<TSource>(
|
public static double? Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long?> selector)
|
Func<TSource, long?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2168,7 +2168,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static long? Min<TSource>(
|
public static long? Min<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long?> selector)
|
Func<TSource, long?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -2194,7 +2194,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static long? Max<TSource>(
|
public static long? Max<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, long?> selector)
|
Func<TSource, long?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -2223,7 +2223,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float Sum<TSource>(
|
public static float Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float> selector)
|
Func<TSource, float> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2261,7 +2261,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float Average<TSource>(
|
public static float Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float> selector)
|
Func<TSource, float> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2291,7 +2291,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float? Sum<TSource>(
|
public static float? Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float?> selector)
|
Func<TSource, float?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2329,7 +2329,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float? Average<TSource>(
|
public static float? Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float?> selector)
|
Func<TSource, float?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2354,7 +2354,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float? Min<TSource>(
|
public static float? Min<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float?> selector)
|
Func<TSource, float?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -2380,7 +2380,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static float? Max<TSource>(
|
public static float? Max<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, float?> selector)
|
Func<TSource, float?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -2409,7 +2409,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double Sum<TSource>(
|
public static double Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double> selector)
|
Func<TSource, double> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2447,7 +2447,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double Average<TSource>(
|
public static double Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double> selector)
|
Func<TSource, double> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2477,7 +2477,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Sum<TSource>(
|
public static double? Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double?> selector)
|
Func<TSource, double?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2515,7 +2515,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Average<TSource>(
|
public static double? Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double?> selector)
|
Func<TSource, double?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2540,7 +2540,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Min<TSource>(
|
public static double? Min<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double?> selector)
|
Func<TSource, double?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -2566,7 +2566,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static double? Max<TSource>(
|
public static double? Max<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, double?> selector)
|
Func<TSource, double?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -2595,7 +2595,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal Sum<TSource>(
|
public static decimal Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal> selector)
|
Func<TSource, decimal> selector)
|
||||||
{
|
{
|
||||||
CheckNotNull(source, "source");
|
CheckNotNull(source, "source");
|
||||||
CheckNotNull(selector, "selector");
|
CheckNotNull(selector, "selector");
|
||||||
|
@ -2642,7 +2642,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal Average<TSource>(
|
public static decimal Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal> selector)
|
Func<TSource, decimal> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2672,7 +2672,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal? Sum<TSource>(
|
public static decimal? Sum<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal?> selector)
|
Func<TSource, decimal?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Sum();
|
return source.Select(selector).Sum();
|
||||||
}
|
}
|
||||||
|
@ -2710,7 +2710,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal? Average<TSource>(
|
public static decimal? Average<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal?> selector)
|
Func<TSource, decimal?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Average();
|
return source.Select(selector).Average();
|
||||||
}
|
}
|
||||||
|
@ -2735,7 +2735,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal? Min<TSource>(
|
public static decimal? Min<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal?> selector)
|
Func<TSource, decimal?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Min();
|
return source.Select(selector).Min();
|
||||||
}
|
}
|
||||||
|
@ -2761,7 +2761,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
|
|
||||||
public static decimal? Max<TSource>(
|
public static decimal? Max<TSource>(
|
||||||
this IEnumerable<TSource> source,
|
this IEnumerable<TSource> source,
|
||||||
Serialization.Func<TSource, decimal?> selector)
|
Func<TSource, decimal?> selector)
|
||||||
{
|
{
|
||||||
return source.Select(selector).Max();
|
return source.Select(selector).Max();
|
||||||
}
|
}
|
||||||
|
@ -2802,7 +2802,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
IOrderedEnumerable<TElement> CreateOrderedEnumerable<TKey>(
|
IOrderedEnumerable<TElement> CreateOrderedEnumerable<TKey>(
|
||||||
Serialization.Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending);
|
Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2862,7 +2862,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public IEnumerable<TResult> ApplyResultSelector<TResult>(
|
public IEnumerable<TResult> ApplyResultSelector<TResult>(
|
||||||
Serialization.Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
|
Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
|
||||||
{
|
{
|
||||||
if (resultSelector == null)
|
if (resultSelector == null)
|
||||||
throw new ArgumentNullException("resultSelector");
|
throw new ArgumentNullException("resultSelector");
|
||||||
|
@ -2892,13 +2892,13 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
private readonly List<Comparison<T>> _comparisons;
|
private readonly List<Comparison<T>> _comparisons;
|
||||||
|
|
||||||
public OrderedEnumerable(IEnumerable<T> source,
|
public OrderedEnumerable(IEnumerable<T> source,
|
||||||
Serialization.Func<T, K> keySelector, IComparer<K> comparer, bool descending) :
|
Func<T, K> keySelector, IComparer<K> comparer, bool descending) :
|
||||||
this(source, null, keySelector, comparer, descending)
|
this(source, null, keySelector, comparer, descending)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderedEnumerable(IEnumerable<T> source, List<Comparison<T>> comparisons,
|
private OrderedEnumerable(IEnumerable<T> source, List<Comparison<T>> comparisons,
|
||||||
Serialization.Func<T, K> keySelector, IComparer<K> comparer, bool descending)
|
Func<T, K> keySelector, IComparer<K> comparer, bool descending)
|
||||||
{
|
{
|
||||||
if (source == null) throw new ArgumentNullException("source");
|
if (source == null) throw new ArgumentNullException("source");
|
||||||
if (keySelector == null) throw new ArgumentNullException("keySelector");
|
if (keySelector == null) throw new ArgumentNullException("keySelector");
|
||||||
|
@ -2917,7 +2917,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOrderedEnumerable<T> CreateOrderedEnumerable<KK>(
|
public IOrderedEnumerable<T> CreateOrderedEnumerable<KK>(
|
||||||
Serialization.Func<T, KK> keySelector, IComparer<KK> comparer, bool descending)
|
Func<T, KK> keySelector, IComparer<KK> comparer, bool descending)
|
||||||
{
|
{
|
||||||
return new OrderedEnumerable<T, KK>(_source, _comparisons, keySelector, comparer, descending);
|
return new OrderedEnumerable<T, KK>(_source, _comparisons, keySelector, comparer, descending);
|
||||||
}
|
}
|
||||||
|
@ -2934,7 +2934,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
// thus making the sort stable.
|
// thus making the sort stable.
|
||||||
//
|
//
|
||||||
|
|
||||||
var list = _source.Select(new Serialization.Func<T, int, Tuple<T, int>>(TagPosition)).ToList();
|
var list = _source.Select(new Func<T, int, Tuple<T, int>>(TagPosition)).ToList();
|
||||||
|
|
||||||
list.Sort((x, y) =>
|
list.Sort((x, y) =>
|
||||||
{
|
{
|
||||||
|
@ -2958,7 +2958,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge
|
||||||
return x.Second.CompareTo(y.Second);
|
return x.Second.CompareTo(y.Second);
|
||||||
});
|
});
|
||||||
|
|
||||||
return list.Select(new Serialization.Func<Tuple<T, int>, T>(GetFirst)).GetEnumerator();
|
return list.Select(new Func<Tuple<T, int>, T>(GetFirst)).GetEnumerator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
internal abstract class ReflectionDelegateFactory
|
internal abstract class ReflectionDelegateFactory
|
||||||
{
|
{
|
||||||
public Serialization.Func<T, object> CreateGet<T>(MemberInfo memberInfo)
|
public Func<T, object> CreateGet<T>(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
if (memberInfo is PropertyInfo propertyInfo)
|
if (memberInfo is PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
throw new Exception("Could not create getter for {0}.".FormatWith(CultureInfo.InvariantCulture, memberInfo));
|
throw new Exception("Could not create getter for {0}.".FormatWith(CultureInfo.InvariantCulture, memberInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serialization.Action<T, object> CreateSet<T>(MemberInfo memberInfo)
|
public Action<T, object> CreateSet<T>(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
if (memberInfo is PropertyInfo propertyInfo)
|
if (memberInfo is PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
|
@ -74,10 +74,10 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
public abstract MethodCall<T, object> CreateMethodCall<T>(MethodBase method);
|
public abstract MethodCall<T, object> CreateMethodCall<T>(MethodBase method);
|
||||||
public abstract ObjectConstructor<object> CreateParameterizedConstructor(MethodBase method);
|
public abstract ObjectConstructor<object> CreateParameterizedConstructor(MethodBase method);
|
||||||
public abstract Serialization.Func<T> CreateDefaultConstructor<T>(Type type);
|
public abstract Func<T> CreateDefaultConstructor<T>(Type type);
|
||||||
public abstract Serialization.Func<T, object> CreateGet<T>(PropertyInfo propertyInfo);
|
public abstract Func<T, object> CreateGet<T>(PropertyInfo propertyInfo);
|
||||||
public abstract Serialization.Func<T, object> CreateGet<T>(FieldInfo fieldInfo);
|
public abstract Func<T, object> CreateGet<T>(FieldInfo fieldInfo);
|
||||||
public abstract Serialization.Action<T, object> CreateSet<T>(FieldInfo fieldInfo);
|
public abstract Action<T, object> CreateSet<T>(FieldInfo fieldInfo);
|
||||||
public abstract Serialization.Action<T, object> CreateSet<T>(PropertyInfo propertyInfo);
|
public abstract Action<T, object> CreateSet<T>(PropertyInfo propertyInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,8 +40,8 @@ namespace Newtonsoft.Json.Utilities
|
||||||
internal class ReflectionMember
|
internal class ReflectionMember
|
||||||
{
|
{
|
||||||
public Type MemberType { get; set; }
|
public Type MemberType { get; set; }
|
||||||
public Serialization.Func<object, object> Getter { get; set; }
|
public Func<object, object> Getter { get; set; }
|
||||||
public Serialization.Action<object, object> Setter { get; set; }
|
public Action<object, object> Setter { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class ReflectionObject
|
internal class ReflectionObject
|
||||||
|
@ -57,13 +57,13 @@ namespace Newtonsoft.Json.Utilities
|
||||||
|
|
||||||
public object GetValue(object target, string member)
|
public object GetValue(object target, string member)
|
||||||
{
|
{
|
||||||
Serialization.Func<object, object> getter = Members[member].Getter;
|
Func<object, object> getter = Members[member].Getter;
|
||||||
return getter(target);
|
return getter(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue(object target, string member, object value)
|
public void SetValue(object target, string member, object value)
|
||||||
{
|
{
|
||||||
Serialization.Action<object, object> setter = Members[member].Setter;
|
Action<object, object> setter = Members[member].Setter;
|
||||||
setter(target, value);
|
setter(target, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
if (ReflectionUtils.HasDefaultConstructor(t, false))
|
if (ReflectionUtils.HasDefaultConstructor(t, false))
|
||||||
{
|
{
|
||||||
Serialization.Func<object> ctor = delegateFactory.CreateDefaultConstructor<object>(t);
|
Func<object> ctor = delegateFactory.CreateDefaultConstructor<object>(t);
|
||||||
|
|
||||||
creatorConstructor = args => ctor();
|
creatorConstructor = args => ctor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Utilities
|
namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
#if (DOTNET || PORTABLE || PORTABLE40) && !NETSTANDARD2_0
|
#if (DOTNET || PORTABLE) && !NETSTANDARD2_0
|
||||||
[Flags]
|
[Flags]
|
||||||
internal enum MemberTypes
|
internal enum MemberTypes
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace Newtonsoft.Json.Utilities
|
||||||
buffer[5] = MathUtils.IntToHex(c & '\x000f');
|
buffer[5] = MathUtils.IntToHex(c & '\x000f');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TSource ForgivingCaseSensitiveFind<TSource>(this IEnumerable<TSource> source, Serialization.Func<TSource, string> valueSelector, string testValue)
|
public static TSource ForgivingCaseSensitiveFind<TSource>(this IEnumerable<TSource> source, Func<TSource, string> valueSelector, string testValue)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,9 +44,9 @@ namespace Newtonsoft.Json.Utilities
|
||||||
private readonly object _lock = new object();
|
private readonly object _lock = new object();
|
||||||
private Dictionary<TKey, TValue> _store;
|
private Dictionary<TKey, TValue> _store;
|
||||||
#endif
|
#endif
|
||||||
private readonly Serialization.Func<TKey, TValue> _creator;
|
private readonly Func<TKey, TValue> _creator;
|
||||||
|
|
||||||
public ThreadSafeStore(Serialization.Func<TKey, TValue> creator)
|
public ThreadSafeStore(Func<TKey, TValue> creator)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(creator, nameof(creator));
|
ValidationUtils.ArgumentNotNull(creator, nameof(creator));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System.Reflection;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
// 有关程序集的一般信息由以下
|
||||||
// 控制。更改这些特性值可修改
|
// 控制。更改这些特性值可修改
|
||||||
|
@ -34,3 +36,5 @@ using System.Runtime.InteropServices;
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
[assembly: AllowPartiallyTrustedCallers]
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue