ReflectionDelegateFactory
using Newtonsoft.Json.Serialization;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Newtonsoft.Json.Utilities
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal abstract class ReflectionDelegateFactory
{
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public Func<T, object> CreateGet<[System.Runtime.CompilerServices.Nullable(2)] T>(MemberInfo memberInfo)
{
PropertyInfo propertyInfo = memberInfo as PropertyInfo;
if ((object)propertyInfo != null) {
if (propertyInfo.PropertyType.IsByRef)
throw new InvalidOperationException("Could not create getter for {0}. ByRef return values are not supported.".FormatWith(CultureInfo.InvariantCulture, propertyInfo));
return CreateGet<T>(propertyInfo);
}
FieldInfo fieldInfo = memberInfo as FieldInfo;
if ((object)fieldInfo != null)
return CreateGet<T>(fieldInfo);
throw new Exception("Could not create getter for {0}.".FormatWith(CultureInfo.InvariantCulture, memberInfo));
}
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public Action<T, object> CreateSet<[System.Runtime.CompilerServices.Nullable(2)] T>(MemberInfo memberInfo)
{
PropertyInfo propertyInfo = memberInfo as PropertyInfo;
if ((object)propertyInfo != null)
return CreateSet<T>(propertyInfo);
FieldInfo fieldInfo = memberInfo as FieldInfo;
if ((object)fieldInfo != null)
return CreateSet<T>(fieldInfo);
throw new Exception("Could not create setter for {0}.".FormatWith(CultureInfo.InvariantCulture, memberInfo));
}
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public abstract MethodCall<T, object> CreateMethodCall<[System.Runtime.CompilerServices.Nullable(2)] T>(MethodBase method);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
public abstract ObjectConstructor<object> CreateParameterizedConstructor(MethodBase method);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
public abstract Func<T> CreateDefaultConstructor<[System.Runtime.CompilerServices.Nullable(2)] T>([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers((System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)7)] Type type);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public abstract Func<T, object> CreateGet<[System.Runtime.CompilerServices.Nullable(2)] T>(PropertyInfo propertyInfo);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public abstract Func<T, object> CreateGet<[System.Runtime.CompilerServices.Nullable(2)] T>(FieldInfo fieldInfo);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public abstract Action<T, object> CreateSet<[System.Runtime.CompilerServices.Nullable(2)] T>(FieldInfo fieldInfo);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
public abstract Action<T, object> CreateSet<[System.Runtime.CompilerServices.Nullable(2)] T>(PropertyInfo propertyInfo);
}
}