Decompiled source of FuriousButtplug v1.0.0

FuriousButtplug/Buttplug.dll

Decompiled 6 months ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.WebSockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Buttplug.Core;
using Buttplug.Core.Messages;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Buttplug.Test")]
[assembly: InternalsVisibleTo("Buttplug.Client.Test")]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Nonpolynomial Labs, LLC")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright Nonpolynomial Labs, LLC")]
[assembly: AssemblyDescription("Buttplug Sex Toy Control Library. Contains Core (messages, errors, etc), Client, and Websocket Connector components")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.0+41a6e2363781583c9c9f475b1544b7ebee02bd52")]
[assembly: AssemblyProduct("Buttplug")]
[assembly: AssemblyTitle("Buttplug")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/buttplugio/buttplug-csharp")]
[assembly: AssemblyVersion("4.0.0.0")]
namespace Buttplug.Core
{
	public static class ButtplugConsts
	{
		public const uint SystemMsgId = 0u;

		public const uint DefaultMsgId = 1u;

		public const uint CurrentSpecVersion = 3u;
	}
	public class ButtplugDeviceException : ButtplugException
	{
		public ButtplugDeviceException(string message, uint id = 0u, Exception inner = null)
			: base(message, Error.ErrorClass.ERROR_DEVICE, id, inner)
		{
		}
	}
	public class ButtplugException : Exception
	{
		public Error ButtplugErrorMessage { get; }

		public static ButtplugException FromError(Error msg)
		{
			return msg.ErrorCode switch
			{
				Error.ErrorClass.ERROR_DEVICE => new ButtplugDeviceException(msg.ErrorMessage, msg.Id), 
				Error.ErrorClass.ERROR_INIT => new ButtplugHandshakeException(msg.ErrorMessage, msg.Id), 
				Error.ErrorClass.ERROR_MSG => new ButtplugMessageException(msg.ErrorMessage, msg.Id), 
				Error.ErrorClass.ERROR_PING => new ButtplugPingException(msg.ErrorMessage, msg.Id), 
				Error.ErrorClass.ERROR_UNKNOWN => new ButtplugException(msg.ErrorMessage, msg.Id), 
				_ => new ButtplugException(msg.ErrorMessage, msg.Id), 
			};
		}

		public ButtplugException(string message, uint id = 0u, Exception inner = null)
			: this(message, Error.ErrorClass.ERROR_UNKNOWN, id, inner)
		{
		}

		public ButtplugException(string message, Error.ErrorClass err = Error.ErrorClass.ERROR_UNKNOWN, uint id = 0u, Exception inner = null)
			: base(message, inner)
		{
			ButtplugErrorMessage = new Error(message, err, id);
		}
	}
	public class ButtplugExceptionEventArgs : EventArgs
	{
		public ButtplugException Exception { get; }

		public ButtplugExceptionEventArgs(ButtplugException ex)
		{
			Exception = ex;
		}
	}
	public class ButtplugHandshakeException : ButtplugException
	{
		public ButtplugHandshakeException(string message, uint id = 0u, Exception inner = null)
			: base(message, Error.ErrorClass.ERROR_INIT, id, inner)
		{
		}
	}
	public class ButtplugJsonMessageParser
	{
		private readonly Dictionary<string, Type> _messageTypes;

		private readonly JsonSerializer _serializer;

		public ButtplugJsonMessageParser()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			_serializer = new JsonSerializer
			{
				MissingMemberHandling = (MissingMemberHandling)1
			};
			_messageTypes = new Dictionary<string, Type>();
			foreach (Type allMessageType in ButtplugUtils.GetAllMessageTypes())
			{
				_messageTypes.Add(allMessageType.Name, allMessageType);
			}
			if (!_messageTypes.Any())
			{
				throw new ButtplugMessageException("No message types available.");
			}
		}

		public IEnumerable<ButtplugMessage> Deserialize(string jsonMsg)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0031: Expected O, but got Unknown
			//IL_005b: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			JsonTextReader val = new JsonTextReader((TextReader)new StringReader(jsonMsg))
			{
				CloseInput = false,
				SupportMultipleContent = true
			};
			List<ButtplugMessage> list = new List<ButtplugMessage>();
			while (true)
			{
				try
				{
					if (!((JsonReader)val).Read())
					{
						return list;
					}
				}
				catch (JsonReaderException val2)
				{
					JsonReaderException val3 = val2;
					throw new ButtplugMessageException("Not valid JSON: " + jsonMsg + " - " + ((Exception)(object)val3).Message);
				}
				JArray val4;
				try
				{
					val4 = JArray.Load((JsonReader)(object)val);
				}
				catch (JsonReaderException val5)
				{
					JsonReaderException val6 = val5;
					throw new ButtplugMessageException("Not valid JSON: " + jsonMsg + " - " + ((Exception)(object)val6).Message);
				}
				foreach (JObject item in ((JToken)val4).Children<JObject>())
				{
					string name = item.Properties().First().Name;
					if (!_messageTypes.ContainsKey(name))
					{
						throw new ButtplugMessageException(name + " is not a valid message class");
					}
					list.Add(DeserializeAs(item, _messageTypes[name]));
				}
			}
		}

		private ButtplugMessage DeserializeAs(JObject obj, Type msgType)
		{
			//IL_00c0: Expected O, but got Unknown
			if (!msgType.IsSubclassOf(typeof(ButtplugMessage)))
			{
				throw new ButtplugMessageException("Type " + msgType.Name + " is not a subclass of ButtplugMessage");
			}
			if (msgType.Namespace != "Buttplug.Core.Messages")
			{
				throw new ButtplugMessageException("Type " + msgType.Name + " (" + msgType.Namespace + ") is not in the namespace of Buttplug.Core.Messages");
			}
			string name = ButtplugMessage.GetName(msgType);
			try
			{
				return (ButtplugMessage)((JToken)Extensions.Value<JObject>((IEnumerable<JToken>)obj[name])).ToObject(msgType, _serializer);
			}
			catch (InvalidCastException ex)
			{
				throw new ButtplugMessageException($"Could not create message for JSON {obj}: {ex.Message}");
			}
			catch (JsonSerializationException val)
			{
				JsonSerializationException val2 = val;
				throw new ButtplugMessageException($"Could not create message for JSON {obj}: {((Exception)(object)val2).Message}");
			}
		}

		public string Serialize(ButtplugMessage msg)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (msg.GetType().Namespace != "Buttplug.Core.Messages")
			{
				throw new ButtplugMessageException("Type " + msg.GetType().Name + " (" + msg.GetType().Namespace + ") is not in the namespace of Buttplug.Core.Messages");
			}
			JObject val = ButtplugMessageToJObject(msg);
			if (val == null)
			{
				throw new ButtplugMessageException("Message cannot be converted to JSON.", msg.Id);
			}
			JArray val2 = new JArray();
			val2.Add((JToken)(object)val);
			return ((JToken)val2).ToString((Formatting)0, Array.Empty<JsonConverter>());
		}

		public string Serialize(IEnumerable<ButtplugMessage> msgs)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			JArray val = new JArray();
			foreach (ButtplugMessage msg in msgs)
			{
				JObject val2 = ButtplugMessageToJObject(msg);
				if (val2 != null)
				{
					val.Add((JToken)(object)val2);
				}
			}
			if (!((IEnumerable<JToken>)val).Any())
			{
				throw new ButtplugMessageException("No messages serialized.");
			}
			return ((JToken)val).ToString((Formatting)0, Array.Empty<JsonConverter>());
		}

		private JObject ButtplugMessageToJObject(ButtplugMessage msg)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return new JObject((object)new JProperty(msg.Name, (object)JObject.FromObject((object)msg)));
		}
	}
	public class ButtplugMessageException : ButtplugException
	{
		public ButtplugMessageException(string message, uint id = 0u, Exception inner = null)
			: base(message, Error.ErrorClass.ERROR_MSG, id, inner)
		{
		}
	}
	public class ButtplugPingException : ButtplugException
	{
		public ButtplugPingException(string message, uint id = 0u, Exception inner = null)
			: base(message, Error.ErrorClass.ERROR_PING, id, inner)
		{
		}
	}
	public static class ButtplugUtils
	{
		public static IEnumerable<Type> GetAllMessageTypes()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetAssembly(typeof(ButtplugMessage))?.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types;
			}
			return (enumerable ?? throw new InvalidOperationException()).Where((Type type) => type != null && type.IsClass && type.IsSubclassOf(typeof(ButtplugMessage)) && type != typeof(ButtplugDeviceMessage));
		}

		[DebuggerStepThrough]
		public static void ArgumentNotNull(object argument, string argumentName)
		{
			if (argument == null)
			{
				throw new ArgumentNullException(argumentName);
			}
		}

		public static Type GetMessageType(string messageName)
		{
			return Type.GetType("Buttplug.Core.Messages." + messageName);
		}
	}
}
namespace Buttplug.Core.Messages
{
	public class ButtplugDeviceMessage : ButtplugMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint DeviceIndex { get; set; }

		public ButtplugDeviceMessage(uint id = 1u, uint deviceIndex = uint.MaxValue)
			: base(id)
		{
			DeviceIndex = deviceIndex;
		}
	}
	public abstract class ButtplugMessage
	{
		private static readonly Dictionary<Type, ButtplugMessageMetadata> _metadataCache = new Dictionary<Type, ButtplugMessageMetadata>();

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint Id { get; set; }

		[JsonIgnore]
		public string Name => GetName(GetType());

		protected ButtplugMessage(uint id)
		{
			Id = id;
		}

		private static T GetMessageAttribute<T>(Type msgType, Func<ButtplugMessageMetadata, T> func)
		{
			ButtplugUtils.ArgumentNotNull(msgType, "msgType");
			ButtplugUtils.ArgumentNotNull(func, "func");
			if (!msgType.IsSubclassOf(typeof(ButtplugMessage)))
			{
				throw new ArgumentException("Argument " + msgType.Name + " must be a subclass of ButtplugMessage");
			}
			if (_metadataCache.ContainsKey(msgType))
			{
				return func(_metadataCache[msgType]);
			}
			Attribute[] customAttributes = Attribute.GetCustomAttributes(msgType);
			for (int i = 0; i < customAttributes.Length; i++)
			{
				if (customAttributes[i] is ButtplugMessageMetadata buttplugMessageMetadata)
				{
					_metadataCache[msgType] = buttplugMessageMetadata;
					return func(buttplugMessageMetadata);
				}
			}
			throw new ArgumentException($"Type {msgType} does not have ButtplugMessageMetadata Attributes");
		}

		public static string GetName(Type msgType)
		{
			return GetMessageAttribute(msgType, (ButtplugMessageMetadata md) => md.Name);
		}
	}
	public interface IButtplugMessageOutgoingOnly
	{
	}
	public interface IButtplugDeviceInfoMessage
	{
		string DeviceName { get; }

		uint DeviceIndex { get; }

		DeviceMessageAttributes DeviceMessages { get; }

		string DeviceDisplayName { get; }

		uint DeviceMessageTimingGap { get; }
	}
	[AttributeUsage(AttributeTargets.Class)]
	public class ButtplugMessageMetadata : Attribute
	{
		public string Name { get; }

		public ButtplugMessageMetadata(string name)
		{
			Name = name;
		}
	}
	[JsonConverter(typeof(StringEnumConverter))]
	public enum ActuatorType
	{
		[EnumMember(Value = "Unknown")]
		Unknown,
		[EnumMember(Value = "Vibrate")]
		Vibrate,
		[EnumMember(Value = "Rotate")]
		Rotate,
		[EnumMember(Value = "Oscillate")]
		Oscillate,
		[EnumMember(Value = "Constrict")]
		Constrict,
		[EnumMember(Value = "Inflate")]
		Inflate,
		[EnumMember(Value = "Position")]
		Position
	}
	[JsonConverter(typeof(StringEnumConverter))]
	public enum SensorType
	{
		[EnumMember(Value = "Unknown")]
		Unknown,
		[EnumMember(Value = "Battery")]
		Battery,
		[EnumMember(Value = "RSSI")]
		RSSI,
		[EnumMember(Value = "Button")]
		Button,
		[EnumMember(Value = "Pressure")]
		Pressure
	}
	public class GenericDeviceMessageAttributes
	{
		[JsonIgnore]
		internal uint _index;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly string FeatureDescriptor;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		[JsonConverter(typeof(StringEnumConverter))]
		public readonly ActuatorType ActuatorType;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint StepCount;

		[JsonIgnore]
		public uint Index => _index;
	}
	public class SensorDeviceMessageAttributes
	{
		[JsonIgnore]
		internal uint _index;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly string FeatureDescriptor;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		[JsonConverter(typeof(StringEnumConverter))]
		public readonly SensorType SensorType;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint[][] SensorRange;

		[JsonIgnore]
		public uint Index => _index;
	}
	public class RawDeviceMessageAttributes
	{
		public readonly string[] Endpoints;
	}
	public class NullDeviceMessageAttributes
	{
	}
	public class DeviceMessageAttributes
	{
		internal class EnumeratePair<T>
		{
			public readonly int index;

			public readonly T attr;

			public EnumeratePair(T attr, int index)
			{
				this.index = index;
				this.attr = attr;
			}
		}

		public GenericDeviceMessageAttributes[] ScalarCmd;

		public GenericDeviceMessageAttributes[] RotateCmd;

		public GenericDeviceMessageAttributes[] LinearCmd;

		public SensorDeviceMessageAttributes[] SensorReadCmd;

		public SensorDeviceMessageAttributes[] SensorSubscribeCmd;

		public readonly RawDeviceMessageAttributes[] RawReadCmd;

		public readonly RawDeviceMessageAttributes[] RawWriteCmd;

		public readonly RawDeviceMessageAttributes[] RawSubscribeCmd;

		public readonly NullDeviceMessageAttributes StopDeviceCmd;

		[OnDeserialized]
		internal void OnDeserializedMethod(StreamingContext context)
		{
			ScalarCmd?.Select((GenericDeviceMessageAttributes x, int i) => new EnumeratePair<GenericDeviceMessageAttributes>(x, i)).ToList().ForEach(delegate(EnumeratePair<GenericDeviceMessageAttributes> x)
			{
				x.attr._index = (uint)x.index;
			});
			RotateCmd?.Select((GenericDeviceMessageAttributes x, int i) => new EnumeratePair<GenericDeviceMessageAttributes>(x, i)).ToList().ForEach(delegate(EnumeratePair<GenericDeviceMessageAttributes> x)
			{
				x.attr._index = (uint)x.index;
			});
			LinearCmd?.Select((GenericDeviceMessageAttributes x, int i) => new EnumeratePair<GenericDeviceMessageAttributes>(x, i)).ToList().ForEach(delegate(EnumeratePair<GenericDeviceMessageAttributes> x)
			{
				x.attr._index = (uint)x.index;
			});
			SensorReadCmd?.Select((SensorDeviceMessageAttributes x, int i) => new EnumeratePair<SensorDeviceMessageAttributes>(x, i)).ToList().ForEach(delegate(EnumeratePair<SensorDeviceMessageAttributes> x)
			{
				x.attr._index = (uint)x.index;
			});
			SensorSubscribeCmd?.Select((SensorDeviceMessageAttributes x, int i) => new EnumeratePair<SensorDeviceMessageAttributes>(x, i)).ToList().ForEach(delegate(EnumeratePair<SensorDeviceMessageAttributes> x)
			{
				x.attr._index = (uint)x.index;
			});
		}
	}
	public class MessageReceivedEventArgs : EventArgs
	{
		public ButtplugMessage Message { get; }

		public MessageReceivedEventArgs(ButtplugMessage message)
		{
			Message = message;
		}
	}
	[ButtplugMessageMetadata("Ok")]
	public class Ok : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		public Ok(uint id)
			: base(id)
		{
		}
	}
	[ButtplugMessageMetadata("Test")]
	public class Test : ButtplugMessage
	{
		private string _testStringImpl;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public string TestString
		{
			get
			{
				return _testStringImpl;
			}
			set
			{
				if (value == "Error")
				{
					throw new ArgumentException("Got an Error Message");
				}
				_testStringImpl = value;
			}
		}

		public Test(string str, uint id = 1u)
			: base(id)
		{
			TestString = str;
		}
	}
	[ButtplugMessageMetadata("Error")]
	public class Error : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		public enum ErrorClass
		{
			ERROR_UNKNOWN,
			ERROR_INIT,
			ERROR_PING,
			ERROR_MSG,
			ERROR_DEVICE
		}

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public ErrorClass ErrorCode;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public string ErrorMessage;

		public Error(string errorMessage, ErrorClass errorCode, uint id)
			: base(id)
		{
			ErrorMessage = errorMessage;
			ErrorCode = errorCode;
		}
	}
	public class MessageAttributes : IEquatable<MessageAttributes>
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint? FeatureCount;

		public MessageAttributes()
		{
		}

		public MessageAttributes(uint featureCount)
		{
			FeatureCount = featureCount;
		}

		public bool Equals(MessageAttributes attrs)
		{
			return FeatureCount == attrs.FeatureCount;
		}
	}
	public class DeviceMessageInfo : IButtplugDeviceInfoMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly string DeviceName;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint DeviceIndex;

		public readonly string DeviceDisplayName;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint DeviceMessageTimingGap;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly DeviceMessageAttributes DeviceMessages;

		string IButtplugDeviceInfoMessage.DeviceName => DeviceName;

		uint IButtplugDeviceInfoMessage.DeviceIndex => DeviceIndex;

		DeviceMessageAttributes IButtplugDeviceInfoMessage.DeviceMessages => DeviceMessages;

		string IButtplugDeviceInfoMessage.DeviceDisplayName => DeviceDisplayName;

		uint IButtplugDeviceInfoMessage.DeviceMessageTimingGap => DeviceMessageTimingGap;

		public DeviceMessageInfo(uint index, string name, DeviceMessageAttributes messages)
		{
			DeviceName = name;
			DeviceIndex = index;
			DeviceMessages = messages;
		}
	}
	[ButtplugMessageMetadata("DeviceList")]
	public class DeviceList : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly DeviceMessageInfo[] Devices = new DeviceMessageInfo[0];

		public DeviceList(DeviceMessageInfo[] deviceList, uint id)
			: base(id)
		{
			Devices = deviceList;
		}

		internal DeviceList()
			: base(0u)
		{
		}
	}
	[ButtplugMessageMetadata("DeviceAdded")]
	public class DeviceAdded : ButtplugDeviceMessage, IButtplugMessageOutgoingOnly, IButtplugDeviceInfoMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public string DeviceName;

		public readonly string DeviceDisplayName;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint DeviceMessageTimingGap;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly DeviceMessageAttributes DeviceMessages;

		string IButtplugDeviceInfoMessage.DeviceName => DeviceName;

		uint IButtplugDeviceInfoMessage.DeviceIndex => base.DeviceIndex;

		DeviceMessageAttributes IButtplugDeviceInfoMessage.DeviceMessages => DeviceMessages;

		string IButtplugDeviceInfoMessage.DeviceDisplayName => DeviceDisplayName;

		uint IButtplugDeviceInfoMessage.DeviceMessageTimingGap => DeviceMessageTimingGap;

		public DeviceAdded(uint index, string name, DeviceMessageAttributes messages)
			: base(0u, index)
		{
			DeviceName = name;
			DeviceMessages = messages;
		}

		internal DeviceAdded()
			: base(0u)
		{
		}
	}
	[ButtplugMessageMetadata("DeviceRemoved")]
	public class DeviceRemoved : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint DeviceIndex;

		public DeviceRemoved(uint index)
			: base(0u)
		{
			DeviceIndex = index;
		}
	}
	[ButtplugMessageMetadata("RequestDeviceList")]
	public class RequestDeviceList : ButtplugMessage
	{
		public RequestDeviceList(uint id = 1u)
			: base(id)
		{
		}
	}
	[ButtplugMessageMetadata("StartScanning")]
	public class StartScanning : ButtplugMessage
	{
		public StartScanning(uint id = 1u)
			: base(id)
		{
		}
	}
	[ButtplugMessageMetadata("StopScanning")]
	public class StopScanning : ButtplugMessage
	{
		public StopScanning(uint id = 1u)
			: base(id)
		{
		}
	}
	[ButtplugMessageMetadata("ScanningFinished")]
	public class ScanningFinished : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		public ScanningFinished()
			: base(0u)
		{
		}
	}
	[ButtplugMessageMetadata("RequestServerInfo")]
	public class RequestServerInfo : ButtplugMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public string ClientName;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint MessageVersion;

		public RequestServerInfo(string clientName, uint id = 1u, uint schemversion = 3u)
			: base(id)
		{
			ClientName = clientName;
			MessageVersion = schemversion;
		}
	}
	[ButtplugMessageMetadata("ServerInfo")]
	public class ServerInfo : ButtplugMessage, IButtplugMessageOutgoingOnly
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint MessageVersion;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint MaxPingTime;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public string ServerName;

		public ServerInfo(string serverName, uint messageVersion, uint maxPingTime, uint id = 1u)
			: base(id)
		{
			ServerName = serverName;
			MessageVersion = messageVersion;
			MaxPingTime = maxPingTime;
		}
	}
	[ButtplugMessageMetadata("Ping")]
	public class Ping : ButtplugMessage
	{
		public Ping(uint id = 1u)
			: base(id)
		{
		}
	}
	public class GenericMessageSubcommand
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint Index;

		protected GenericMessageSubcommand(uint index)
		{
			Index = index;
		}
	}
	[ButtplugMessageMetadata("ScalarCmd")]
	public class ScalarCmd : ButtplugDeviceMessage
	{
		public class ScalarCommand
		{
			public readonly uint index;

			public readonly double scalar;

			public ScalarCommand(uint index, double scalar)
			{
				this.index = index;
				this.scalar = scalar;
			}
		}

		public class ScalarSubcommand : GenericMessageSubcommand
		{
			private double _scalarImpl;

			public readonly ActuatorType ActuatorType;

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public double Scalar
			{
				get
				{
					return _scalarImpl;
				}
				set
				{
					if (value < 0.0)
					{
						throw new ArgumentException("ScalarCmd value cannot be less than 0!");
					}
					if (value > 1.0)
					{
						throw new ArgumentException("ScalarCmd value cannot be greater than 1!");
					}
					_scalarImpl = value;
				}
			}

			public ScalarSubcommand(uint index, double scalar, ActuatorType actuatorType)
				: base(index)
			{
				Scalar = scalar;
				ActuatorType = actuatorType;
			}
		}

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public List<ScalarSubcommand> Scalars;

		[JsonConstructor]
		public ScalarCmd(uint deviceIndex, List<ScalarSubcommand> scalars, uint id = 1u)
			: base(id, deviceIndex)
		{
			Scalars = scalars;
		}

		public ScalarCmd(List<ScalarSubcommand> scalars)
			: this(uint.MaxValue, scalars)
		{
		}
	}
	[ButtplugMessageMetadata("RotateCmd")]
	public class RotateCmd : ButtplugDeviceMessage
	{
		public class RotateCommand
		{
			public readonly double speed;

			public readonly bool clockwise;

			public RotateCommand(double speed, bool clockwise)
			{
				this.speed = speed;
				this.clockwise = clockwise;
			}
		}

		public class RotateSubcommand : GenericMessageSubcommand
		{
			private double _speedImpl;

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public bool Clockwise;

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public double Speed
			{
				get
				{
					return _speedImpl;
				}
				set
				{
					if (value < 0.0)
					{
						throw new ArgumentException("RotateCmd Speed cannot be less than 0!");
					}
					if (value > 1.0)
					{
						throw new ArgumentException("RotateCmd Speed cannot be greater than 1!");
					}
					_speedImpl = value;
				}
			}

			public RotateSubcommand(uint index, double speed, bool clockwise)
				: base(index)
			{
				Speed = speed;
				Clockwise = clockwise;
			}
		}

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public List<RotateSubcommand> Rotations;

		public static RotateCmd Create(double speed, bool clockwise, uint cmdCount)
		{
			return Create(uint.MaxValue, 1u, Enumerable.Repeat(new RotateCommand(speed, clockwise), (int)cmdCount));
		}

		public static RotateCmd Create(IEnumerable<RotateCommand> cmds)
		{
			return Create(uint.MaxValue, 1u, cmds);
		}

		public static RotateCmd Create(uint deviceIndex, uint msgId, double speed, bool clockwise, uint cmdCount)
		{
			return Create(deviceIndex, msgId, Enumerable.Repeat(new RotateCommand(speed, clockwise), (int)cmdCount));
		}

		public static RotateCmd Create(uint deviceIndex, uint msgId, IEnumerable<RotateCommand> cmds)
		{
			List<RotateSubcommand> list = new List<RotateSubcommand>(cmds.Count());
			uint num = 0u;
			foreach (RotateCommand cmd in cmds)
			{
				list.Add(new RotateSubcommand(num, cmd.speed, cmd.clockwise));
				num++;
			}
			return new RotateCmd(deviceIndex, list, msgId);
		}

		[JsonConstructor]
		public RotateCmd(uint deviceIndex, List<RotateSubcommand> rotations, uint id = 1u)
			: base(id, deviceIndex)
		{
			Rotations = rotations;
		}

		public RotateCmd(List<RotateSubcommand> rotations)
			: this(uint.MaxValue, rotations)
		{
		}
	}
	[ButtplugMessageMetadata("LinearCmd")]
	public class LinearCmd : ButtplugDeviceMessage
	{
		public class VectorCommand
		{
			public readonly double position;

			public readonly uint duration;

			public VectorCommand(double position, uint duration)
			{
				this.position = position;
				this.duration = duration;
			}
		}

		public class VectorSubcommand : GenericMessageSubcommand
		{
			private double _positionImpl;

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public uint Duration;

			[JsonProperty(/*Could not decode attribute arguments.*/)]
			public double Position
			{
				get
				{
					return _positionImpl;
				}
				set
				{
					if (value < 0.0)
					{
						throw new ArgumentException("LinearCmd Speed cannot be less than 0!");
					}
					if (value > 1.0)
					{
						throw new ArgumentException("LinearCmd Speed cannot be greater than 1!");
					}
					_positionImpl = value;
				}
			}

			public VectorSubcommand(uint index, uint duration, double position)
				: base(index)
			{
				Duration = duration;
				Position = position;
			}
		}

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public List<VectorSubcommand> Vectors;

		public static LinearCmd Create(uint duration, double position, uint cmdCount)
		{
			return Create(uint.MaxValue, 1u, Enumerable.Repeat(new VectorCommand(position, duration), (int)cmdCount));
		}

		public static LinearCmd Create(uint deviceIndex, uint msgId, uint duration, double position, uint cmdCount)
		{
			return Create(deviceIndex, msgId, Enumerable.Repeat(new VectorCommand(position, duration), (int)cmdCount));
		}

		public static LinearCmd Create(IEnumerable<VectorCommand> cmds)
		{
			return Create(uint.MaxValue, 1u, cmds);
		}

		public static LinearCmd Create(uint deviceIndex, uint msgId, IEnumerable<VectorCommand> cmds)
		{
			List<VectorSubcommand> list = new List<VectorSubcommand>(cmds.Count());
			uint num = 0u;
			foreach (VectorCommand cmd in cmds)
			{
				list.Add(new VectorSubcommand(num, cmd.duration, cmd.position));
				num++;
			}
			return new LinearCmd(deviceIndex, list, msgId);
		}

		[JsonConstructor]
		public LinearCmd(uint deviceIndex, List<VectorSubcommand> vectors, uint id = 1u)
			: base(id, deviceIndex)
		{
			Vectors = vectors;
		}

		public LinearCmd(List<VectorSubcommand> vectors)
			: this(uint.MaxValue, vectors)
		{
		}
	}
	[ButtplugMessageMetadata("StopDeviceCmd")]
	public class StopDeviceCmd : ButtplugDeviceMessage
	{
		public StopDeviceCmd(uint deviceIndex = uint.MaxValue, uint id = 1u)
			: base(id, deviceIndex)
		{
		}
	}
	[ButtplugMessageMetadata("StopAllDevices")]
	public class StopAllDevices : ButtplugMessage
	{
		public StopAllDevices(uint id = 1u)
			: base(id)
		{
		}
	}
	[ButtplugMessageMetadata("SensorReadCmd")]
	public class SensorReadCmd : ButtplugDeviceMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public uint SensorIndex;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public SensorType SensorType;

		[JsonConstructor]
		public SensorReadCmd(uint deviceIndex, uint sensorIndex, SensorType sensorType, uint id = 1u)
			: base(id, deviceIndex)
		{
			SensorIndex = sensorIndex;
			SensorType = sensorType;
		}

		public SensorReadCmd(uint sensorIndex, SensorType sensorType)
			: this(uint.MaxValue, sensorIndex, sensorType)
		{
		}
	}
	[ButtplugMessageMetadata("SensorReading")]
	public class SensorReading : ButtplugDeviceMessage
	{
		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly uint SensorIndex;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly SensorType SensorType;

		[JsonProperty(/*Could not decode attribute arguments.*/)]
		public readonly List<int> data;
	}
}
namespace Buttplug.Client
{
	public class ButtplugClient : IDisposable
	{
		protected Timer _pingTimer;

		internal ButtplugClientMessageHandler _handler;

		private readonly ConcurrentDictionary<uint, ButtplugClientDevice> _devices = new ConcurrentDictionary<uint, ButtplugClientDevice>();

		private IButtplugClientConnector _connector;

		public string Name { get; }

		public ButtplugClientDevice[] Devices => _devices.Values.ToArray();

		public bool Connected => _connector?.Connected ?? false;

		public event EventHandler<DeviceAddedEventArgs> DeviceAdded;

		public event EventHandler<DeviceRemovedEventArgs> DeviceRemoved;

		public event EventHandler<ButtplugExceptionEventArgs> ErrorReceived;

		public event EventHandler ScanningFinished;

		public event EventHandler PingTimeout;

		public event EventHandler ServerDisconnect;

		public ButtplugClient(string clientName)
		{
			Name = clientName;
		}

		public async Task ConnectAsync(IButtplugClientConnector connector, CancellationToken token = default(CancellationToken))
		{
			if (Connected)
			{
				throw new ButtplugHandshakeException("Client already connected to a server.");
			}
			ButtplugUtils.ArgumentNotNull(connector, "connector");
			_connector = connector;
			_connector.Disconnected += delegate(object obj, EventArgs eventArgs)
			{
				this.ServerDisconnect?.Invoke(obj, eventArgs);
			};
			_connector.InvalidMessageReceived += ConnectorErrorHandler;
			_connector.MessageReceived += MessageReceivedHandler;
			_devices.Clear();
			_handler = new ButtplugClientMessageHandler(connector);
			await _connector.ConnectAsync(token).ConfigureAwait(continueOnCapturedContext: false);
			ButtplugMessage res = await _handler.SendMessageAsync(new RequestServerInfo(Name), token).ConfigureAwait(continueOnCapturedContext: false);
			if (!(res is ServerInfo si))
			{
				if (res is Error e)
				{
					await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
					throw ButtplugException.FromError(e);
				}
				await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
				throw new ButtplugHandshakeException("Unrecognized message " + res.Name + " during handshake", res.Id);
			}
			if (si.MaxPingTime != 0)
			{
				_pingTimer?.Dispose();
				_pingTimer = new Timer(OnPingTimer, null, 0, Convert.ToInt32(Math.Round((double)si.MaxPingTime / 2.0, 0)));
			}
			if (si.MessageVersion < 3)
			{
				await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
				throw new ButtplugHandshakeException($"Buttplug Server's schema version ({si.MessageVersion}) is less than the client's ({3u}). A newer server is required.", res.Id);
			}
			ButtplugMessage resp = await _handler.SendMessageAsync(new RequestDeviceList()).ConfigureAwait(continueOnCapturedContext: false);
			if (resp is DeviceList deviceList)
			{
				DeviceMessageInfo[] devices = deviceList.Devices;
				foreach (DeviceMessageInfo deviceMessageInfo in devices)
				{
					if (!_devices.ContainsKey(deviceMessageInfo.DeviceIndex))
					{
						ButtplugClientDevice buttplugClientDevice = new ButtplugClientDevice(_handler, deviceMessageInfo);
						_devices[deviceMessageInfo.DeviceIndex] = buttplugClientDevice;
						this.DeviceAdded?.Invoke(this, new DeviceAddedEventArgs(buttplugClientDevice));
					}
				}
				return;
			}
			await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
			if (resp is Error msg)
			{
				throw ButtplugException.FromError(msg);
			}
			throw new ButtplugHandshakeException("Received unknown response to DeviceList handshake query");
		}

		public async Task DisconnectAsync()
		{
			if (Connected)
			{
				_connector.MessageReceived -= MessageReceivedHandler;
				await _connector.DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
				this.ServerDisconnect?.Invoke(this, EventArgs.Empty);
			}
		}

		public async Task StartScanningAsync(CancellationToken token = default(CancellationToken))
		{
			await _handler.SendMessageExpectOk(new StartScanning(), token).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task StopScanningAsync(CancellationToken token = default(CancellationToken))
		{
			await _handler.SendMessageExpectOk(new StopScanning(), token).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task StopAllDevicesAsync(CancellationToken token = default(CancellationToken))
		{
			await _handler.SendMessageExpectOk(new StopAllDevices(), token).ConfigureAwait(continueOnCapturedContext: false);
		}

		private void ConnectorErrorHandler(object sender, ButtplugExceptionEventArgs exception)
		{
			this.ErrorReceived?.Invoke(this, exception);
		}

		private async void MessageReceivedHandler(object sender, MessageReceivedEventArgs args)
		{
			ButtplugMessage message = args.Message;
			if (!(message is DeviceAdded deviceAdded))
			{
				ButtplugClientDevice value;
				if (!(message is DeviceRemoved deviceRemoved))
				{
					if (!(message is ScanningFinished))
					{
						if (message is Error error)
						{
							this.ErrorReceived?.Invoke(this, new ButtplugExceptionEventArgs(ButtplugException.FromError(error)));
							if (error.ErrorCode == Error.ErrorClass.ERROR_PING)
							{
								this.PingTimeout?.Invoke(this, EventArgs.Empty);
								await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
							}
						}
						else
						{
							this.ErrorReceived?.Invoke(this, new ButtplugExceptionEventArgs(new ButtplugMessageException($"Got unhandled message: {message}", message.Id)));
						}
					}
					else
					{
						this.ScanningFinished?.Invoke(this, EventArgs.Empty);
					}
				}
				else if (!_devices.ContainsKey(deviceRemoved.DeviceIndex))
				{
					this.ErrorReceived?.Invoke(this, new ButtplugExceptionEventArgs(new ButtplugDeviceException("Got device removed message for unknown device.", message.Id)));
				}
				else if (_devices.TryRemove(deviceRemoved.DeviceIndex, out value))
				{
					this.DeviceRemoved?.Invoke(this, new DeviceRemovedEventArgs(value));
				}
			}
			else
			{
				ButtplugClientDevice dev = new ButtplugClientDevice(_handler, deviceAdded);
				_devices.AddOrUpdate(deviceAdded.DeviceIndex, dev, (uint u, ButtplugClientDevice device) => dev);
				this.DeviceAdded?.Invoke(this, new DeviceAddedEventArgs(dev));
			}
		}

		private async void OnPingTimer(object state)
		{
			try
			{
				await _handler.SendMessageExpectOk(new Ping()).ConfigureAwait(continueOnCapturedContext: false);
			}
			catch (Exception inner)
			{
				this.ErrorReceived?.Invoke(this, new ButtplugExceptionEventArgs(new ButtplugPingException("Exception thrown during ping update", 0u, inner)));
				await DisconnectAsync().ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		protected virtual void Dispose(bool disposing)
		{
			DisconnectAsync().GetAwaiter().GetResult();
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}
	}
	public class ButtplugClientConnectorException : ButtplugException
	{
		public ButtplugClientConnectorException(string message, Exception inner = null)
			: base(message, Error.ErrorClass.ERROR_UNKNOWN, 0u, inner)
		{
		}
	}
	public class ButtplugClientDevice
	{
		private readonly ButtplugClientMessageHandler _handler;

		public uint Index { get; }

		public string Name { get; }

		public string DisplayName { get; }

		public uint MessageTimingGap { get; }

		public DeviceMessageAttributes MessageAttributes { get; }

		public List<GenericDeviceMessageAttributes> VibrateAttributes => GenericAcutatorAttributes(ActuatorType.Vibrate);

		public List<GenericDeviceMessageAttributes> OscillateAttributes => GenericAcutatorAttributes(ActuatorType.Oscillate);

		public List<GenericDeviceMessageAttributes> RotateAttributes
		{
			get
			{
				if (MessageAttributes.RotateCmd != null)
				{
					return MessageAttributes.RotateCmd.ToList();
				}
				return Enumerable.Empty<GenericDeviceMessageAttributes>().ToList();
			}
		}

		public List<GenericDeviceMessageAttributes> LinearAttributes
		{
			get
			{
				if (MessageAttributes.LinearCmd != null)
				{
					return MessageAttributes.LinearCmd.ToList();
				}
				return Enumerable.Empty<GenericDeviceMessageAttributes>().ToList();
			}
		}

		public bool HasBattery => SensorReadAttributes(SensorType.Battery).Any();

		internal ButtplugClientDevice(ButtplugClientMessageHandler handler, IButtplugDeviceInfoMessage devInfo)
			: this(handler, devInfo.DeviceIndex, devInfo.DeviceName, devInfo.DeviceMessages, devInfo.DeviceDisplayName, devInfo.DeviceMessageTimingGap)
		{
			ButtplugUtils.ArgumentNotNull(devInfo, "devInfo");
		}

		internal ButtplugClientDevice(ButtplugClientMessageHandler handler, uint index, string name, DeviceMessageAttributes messages, string displayName, uint messageTimingGap)
		{
			ButtplugUtils.ArgumentNotNull(handler, "handler");
			_handler = handler;
			Index = index;
			Name = name;
			MessageAttributes = messages;
			DisplayName = displayName;
			MessageTimingGap = messageTimingGap;
		}

		public List<GenericDeviceMessageAttributes> GenericAcutatorAttributes(ActuatorType actuator)
		{
			if (MessageAttributes.ScalarCmd != null)
			{
				return MessageAttributes.ScalarCmd.Where((GenericDeviceMessageAttributes x) => x.ActuatorType == actuator).ToList();
			}
			return Enumerable.Empty<GenericDeviceMessageAttributes>().ToList();
		}

		public async Task ScalarAsync(ScalarCmd.ScalarSubcommand command)
		{
			List<ScalarCmd.ScalarSubcommand> scalars = new List<ScalarCmd.ScalarSubcommand>();
			GenericAcutatorAttributes(command.ActuatorType).ForEach(delegate(GenericDeviceMessageAttributes x)
			{
				scalars.Add(new ScalarCmd.ScalarSubcommand(x.Index, command.Scalar, command.ActuatorType));
			});
			if (!scalars.Any())
			{
				throw new ButtplugDeviceException("Scalar command for device " + Name + " did not generate any commands. Are you sure the device supports the ActuatorType sent?");
			}
			await _handler.SendMessageExpectOk(new ScalarCmd(Index, scalars)).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task ScalarAsync(List<ScalarCmd.ScalarSubcommand> command)
		{
			if (!command.Any())
			{
				throw new ArgumentException("Command List for ScalarAsync must have at least 1 command.");
			}
			await _handler.SendMessageExpectOk(new ScalarCmd(Index, command)).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task VibrateAsync(double speed)
		{
			await ScalarAsync(new ScalarCmd.ScalarSubcommand(uint.MaxValue, speed, ActuatorType.Vibrate));
		}

		public async Task VibrateAsync(IEnumerable<double> cmds)
		{
			List<GenericDeviceMessageAttributes> vibrateAttributes = VibrateAttributes;
			if (cmds.Count() > vibrateAttributes.Count())
			{
				throw new ButtplugDeviceException($"Device {Name} only has {vibrateAttributes.Count()} vibrators, but {cmds.Count()} commands given.");
			}
			await ScalarAsync(vibrateAttributes.Select((GenericDeviceMessageAttributes x, int i) => new ScalarCmd.ScalarSubcommand(x.Index, cmds.ElementAt(i), ActuatorType.Vibrate)).ToList()).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task VibrateAsync(IEnumerable<ScalarCmd.ScalarCommand> cmds)
		{
			await ScalarAsync(cmds.Select((ScalarCmd.ScalarCommand x) => new ScalarCmd.ScalarSubcommand(x.index, x.scalar, ActuatorType.Vibrate)).ToList()).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task OscillateAsync(double speed)
		{
			await ScalarAsync(new ScalarCmd.ScalarSubcommand(uint.MaxValue, speed, ActuatorType.Oscillate));
		}

		public async Task OscillateAsync(IEnumerable<double> cmds)
		{
			List<GenericDeviceMessageAttributes> oscillateAttributes = OscillateAttributes;
			if (cmds.Count() > oscillateAttributes.Count())
			{
				throw new ButtplugDeviceException($"Device {Name} only has {oscillateAttributes.Count()} vibrators, but {cmds.Count()} commands given.");
			}
			await ScalarAsync(oscillateAttributes.Select((GenericDeviceMessageAttributes x, int i) => new ScalarCmd.ScalarSubcommand(x.Index, cmds.ElementAt(i), ActuatorType.Oscillate)).ToList()).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task OscillateAsync(IEnumerable<ScalarCmd.ScalarCommand> cmds)
		{
			await ScalarAsync(cmds.Select((ScalarCmd.ScalarCommand x) => new ScalarCmd.ScalarSubcommand(x.index, x.scalar, ActuatorType.Oscillate)).ToList()).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task RotateAsync(double speed, bool clockwise)
		{
			if (!RotateAttributes.Any())
			{
				throw new ButtplugDeviceException("Device " + Name + " does not support rotation");
			}
			RotateCmd rotateCmd = RotateCmd.Create(speed, clockwise, (uint)RotateAttributes.Count);
			rotateCmd.DeviceIndex = Index;
			await _handler.SendMessageExpectOk(rotateCmd).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task RotateAsync(IEnumerable<RotateCmd.RotateCommand> cmds)
		{
			if (!RotateAttributes.Any())
			{
				throw new ButtplugDeviceException("Device " + Name + " does not support rotation");
			}
			RotateCmd rotateCmd = RotateCmd.Create(cmds);
			rotateCmd.DeviceIndex = Index;
			await _handler.SendMessageExpectOk(rotateCmd).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task LinearAsync(uint duration, double position)
		{
			if (!LinearAttributes.Any())
			{
				throw new ButtplugDeviceException("Device " + Name + " does not support linear position");
			}
			LinearCmd linearCmd = LinearCmd.Create(duration, position, (uint)LinearAttributes.Count);
			linearCmd.DeviceIndex = Index;
			await _handler.SendMessageExpectOk(linearCmd).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task LinearAsync(IEnumerable<LinearCmd.VectorCommand> cmds)
		{
			if (!LinearAttributes.Any())
			{
				throw new ButtplugDeviceException("Device " + Name + " does not support linear position");
			}
			LinearCmd linearCmd = LinearCmd.Create(cmds);
			linearCmd.DeviceIndex = Index;
			await _handler.SendMessageExpectOk(linearCmd).ConfigureAwait(continueOnCapturedContext: false);
		}

		public List<SensorDeviceMessageAttributes> SensorReadAttributes(SensorType sensor)
		{
			if (MessageAttributes.SensorReadCmd != null)
			{
				return MessageAttributes.SensorReadCmd.Where((SensorDeviceMessageAttributes x) => x.SensorType == sensor).ToList();
			}
			return Enumerable.Empty<SensorDeviceMessageAttributes>().ToList();
		}

		public async Task<double> BatteryAsync()
		{
			if (!HasBattery)
			{
				throw new ButtplugDeviceException("Device " + Name + " does not have battery capabilities.");
			}
			ButtplugMessage buttplugMessage = await _handler.SendMessageAsync(new SensorReadCmd(Index, SensorReadAttributes(SensorType.Battery).ElementAt(0).Index, SensorType.Battery)).ConfigureAwait(continueOnCapturedContext: false);
			if (!(buttplugMessage is SensorReading sensorReading))
			{
				if (buttplugMessage is Error msg)
				{
					throw ButtplugException.FromError(msg);
				}
				throw new ButtplugMessageException("Message type " + buttplugMessage.Name + " not handled by BatteryAsync", buttplugMessage.Id);
			}
			return (double)sensorReading.data[0] / 100.0;
		}

		public async Task Stop()
		{
			await _handler.SendMessageExpectOk(new StopDeviceCmd(Index)).ConfigureAwait(continueOnCapturedContext: false);
		}
	}
	internal class ButtplugClientMessageHandler
	{
		private IButtplugClientConnector _connector;

		internal ButtplugClientMessageHandler(IButtplugClientConnector connector)
		{
			_connector = connector;
		}

		public async Task<ButtplugMessage> SendMessageAsync(ButtplugMessage msg, CancellationToken token = default(CancellationToken))
		{
			if (!_connector.Connected)
			{
				throw new ButtplugClientConnectorException("Client not connected.");
			}
			return await _connector.SendAsync(msg, token).ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task SendMessageExpectOk(ButtplugMessage msg, CancellationToken token = default(CancellationToken))
		{
			ButtplugMessage buttplugMessage = await SendMessageAsync(msg, token).ConfigureAwait(continueOnCapturedContext: false);
			if (!(buttplugMessage is Ok))
			{
				if (buttplugMessage is Error msg2)
				{
					throw ButtplugException.FromError(msg2);
				}
				throw new ButtplugMessageException("Message type " + msg.Name + " not handled by SendMessageExpectOk", msg.Id);
			}
		}
	}
	public class ButtplugConnectorJSONParser
	{
		private readonly ButtplugJsonMessageParser _parser = new ButtplugJsonMessageParser();

		public string Serialize(ButtplugMessage msg)
		{
			return _parser.Serialize(msg);
		}

		public string Serialize(ButtplugMessage[] msgs)
		{
			return _parser.Serialize(msgs);
		}

		public IEnumerable<ButtplugMessage> Deserialize(string msg)
		{
			return _parser.Deserialize(msg);
		}
	}
	public class ButtplugConnectorMessageSorter : IDisposable
	{
		private int _counter;

		private readonly ConcurrentDictionary<uint, TaskCompletionSource<ButtplugMessage>> _waitingMsgs = new ConcurrentDictionary<uint, TaskCompletionSource<ButtplugMessage>>();

		public uint NextMsgId => Convert.ToUInt32(Interlocked.Increment(ref _counter));

		public Task<ButtplugMessage> PrepareMessage(ButtplugMessage msg)
		{
			msg.Id = NextMsgId;
			TaskCompletionSource<ButtplugMessage> taskCompletionSource = new TaskCompletionSource<ButtplugMessage>();
			_waitingMsgs.TryAdd(msg.Id, taskCompletionSource);
			return taskCompletionSource.Task;
		}

		public void CheckMessage(ButtplugMessage msg)
		{
			if (msg.Id == 0)
			{
				throw new ButtplugMessageException("Cannot sort message with System ID", msg.Id);
			}
			if (!_waitingMsgs.TryRemove(msg.Id, out var value))
			{
				throw new ButtplugMessageException("Message with non-matching ID received.", msg.Id);
			}
			if (msg is Error msg2)
			{
				value.SetException(ButtplugException.FromError(msg2));
			}
			else
			{
				value.SetResult(msg);
			}
		}

		protected virtual void Dispose(bool disposing)
		{
			foreach (TaskCompletionSource<ButtplugMessage> value in _waitingMsgs.Values)
			{
				value.TrySetException(new Exception("Sorter has been destroyed with live tasks still in queue."));
			}
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}
	}
	public class ReturnMessage
	{
		public readonly string Message;

		public readonly Task<ButtplugMessage> Promise;

		public ReturnMessage(string message, Task<ButtplugMessage> promise)
		{
			Message = message;
			Promise = promise;
		}
	}
	public class ButtplugRemoteJSONConnector : IDisposable
	{
		private readonly ButtplugConnectorJSONParser _jsonSerializer = new ButtplugConnectorJSONParser();

		private readonly ButtplugConnectorMessageSorter _msgSorter = new ButtplugConnectorMessageSorter();

		public event EventHandler<MessageReceivedEventArgs> MessageReceived;

		public event EventHandler<ButtplugExceptionEventArgs> InvalidMessageReceived;

		public ReturnMessage PrepareMessage(ButtplugMessage msg)
		{
			Task<ButtplugMessage> promise = _msgSorter.PrepareMessage(msg);
			return new ReturnMessage(_jsonSerializer.Serialize(msg), promise);
		}

		protected void ReceiveMessages(string jSONMsg)
		{
			IEnumerable<ButtplugMessage> enumerable;
			try
			{
				enumerable = _jsonSerializer.Deserialize(jSONMsg);
			}
			catch (ButtplugMessageException ex)
			{
				this.InvalidMessageReceived?.Invoke(this, new ButtplugExceptionEventArgs(ex));
				return;
			}
			foreach (ButtplugMessage item in enumerable)
			{
				if (item.Id == 0)
				{
					this.MessageReceived?.Invoke(this, new MessageReceivedEventArgs(item));
					continue;
				}
				try
				{
					_msgSorter.CheckMessage(item);
				}
				catch (ButtplugMessageException ex2)
				{
					this.InvalidMessageReceived?.Invoke(this, new ButtplugExceptionEventArgs(ex2));
				}
			}
		}

		protected virtual void Dispose(bool disposing)
		{
			_msgSorter.Dispose();
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}
	}
	public class ButtplugWebsocketConnector : ButtplugRemoteJSONConnector, IButtplugClientConnector
	{
		private ClientWebSocket _wsClient;

		private readonly SynchronizationContext _owningDispatcher = SynchronizationContext.Current ?? new SynchronizationContext();

		private readonly Uri _uri;

		private Task _readTask;

		public bool Connected
		{
			get
			{
				ClientWebSocket wsClient = _wsClient;
				if (wsClient == null)
				{
					return false;
				}
				return wsClient.State == WebSocketState.Open;
			}
		}

		public event EventHandler Disconnected;

		public ButtplugWebsocketConnector(Uri uri)
		{
			_uri = uri;
		}

		public async Task ConnectAsync(CancellationToken token = default(CancellationToken))
		{
			if (_wsClient != null)
			{
				throw new ButtplugHandshakeException("Websocket connector is already connected.");
			}
			try
			{
				_wsClient = new ClientWebSocket();
				await _wsClient.ConnectAsync(_uri, token).ConfigureAwait(continueOnCapturedContext: false);
			}
			catch (Exception inner)
			{
				throw new ButtplugClientConnectorException("Websocket Connection Exception! See Inner Exception", inner);
			}
			_readTask = Task.Run(async delegate
			{
				await RunClientLoop(token).ConfigureAwait(continueOnCapturedContext: false);
			}, token);
		}

		public async Task DisconnectAsync(CancellationToken token = default(CancellationToken))
		{
			if (_wsClient != null && (_wsClient.State == WebSocketState.Connecting || _wsClient.State == WebSocketState.Open))
			{
				await _wsClient.CloseAsync(WebSocketCloseStatus.NormalClosure, null, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
			}
			_wsClient?.Dispose();
			_wsClient = null;
			await _readTask.ConfigureAwait(continueOnCapturedContext: false);
		}

		public async Task<ButtplugMessage> SendAsync(ButtplugMessage msg, CancellationToken cancellationToken)
		{
			if (_wsClient == null)
			{
				throw new ButtplugException("Cannot send messages while disconnected", Error.ErrorClass.ERROR_MSG);
			}
			ReturnMessage returnMsg = PrepareMessage(msg);
			await _wsClient.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(returnMsg.Message)), WebSocketMessageType.Text, endOfMessage: true, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			return await returnMsg.Promise.ConfigureAwait(continueOnCapturedContext: false);
		}

		private async Task RunClientLoop(CancellationToken token)
		{
			try
			{
				new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false);
				byte[] buff = new byte[2048];
				while (Connected && !token.IsCancellationRequested)
				{
					WebSocketReceiveResult webSocketReceiveResult = await _wsClient.ReceiveAsync(new ArraySegment<byte>(buff), token).ConfigureAwait(continueOnCapturedContext: false);
					if (webSocketReceiveResult.MessageType == WebSocketMessageType.Text)
					{
						string @string = Encoding.Default.GetString(buff, 0, webSocketReceiveResult.Count);
						ReceiveMessages(@string);
					}
				}
			}
			catch (Exception)
			{
			}
			finally
			{
				if (_wsClient != null)
				{
					_wsClient.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", token).Dispose();
					_wsClient = null;
				}
				_owningDispatcher.Send(delegate
				{
					Dispose();
				}, null);
				_owningDispatcher.Send(delegate
				{
					this.Disconnected?.Invoke(this, EventArgs.Empty);
				}, null);
			}
		}
	}
	public class DeviceAddedEventArgs
	{
		public readonly ButtplugClientDevice Device;

		public DeviceAddedEventArgs(ButtplugClientDevice device)
		{
			Device = device;
		}
	}
	public class DeviceRemovedEventArgs
	{
		public readonly ButtplugClientDevice Device;

		public DeviceRemovedEventArgs(ButtplugClientDevice device)
		{
			Device = device;
		}
	}
	public interface IButtplugClientConnector
	{
		bool Connected { get; }

		event EventHandler<MessageReceivedEventArgs> MessageReceived;

		event EventHandler<ButtplugExceptionEventArgs> InvalidMessageReceived;

		event EventHandler Disconnected;

		Task ConnectAsync(CancellationToken token = default(CancellationToken));

		Task DisconnectAsync(CancellationToken token = default(CancellationToken));

		Task<ButtplugMessage> SendAsync(ButtplugMessage msg, CancellationToken token = default(CancellationToken));
	}
}

FuriousButtplug/FuriousButtplug.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Buttplug.Client;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("FuriousButtplug")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+30e48b4b0ba4b5b24b88c218de4e807a456fb832")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("FuriousButtplug")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FuriousButtplug
{
	internal class BPManager
	{
		private ButtplugClient client = new ButtplugClient("FuriousButtplug");

		private string _intifaceIP;

		private ManualLogSource _logger;

		private CancellationTokenSource _currentVibrationCts;

		private readonly object _vibrationLock = new object();

		private DateTime _lastVibrationTime;

		public BPManager(ManualLogSource logger)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_logger = logger;
		}

		private void LogInnerExceptions(Exception ex)
		{
			while (ex != null)
			{
				_logger.LogError((object)("Inner Exception: " + ex.Message));
				ex = ex.InnerException;
			}
		}

		public async Task ScanForDevices()
		{
			if (!client.Connected)
			{
				_logger.LogInfo((object)"Buttplug not connected, cannot scan for devices");
				return;
			}
			_logger.LogInfo((object)"Scanning for devices");
			await client.StartScanningAsync(default(CancellationToken));
			await Task.Delay(30000);
			_logger.LogInfo((object)"Stopping scanning for devices");
			await client.StopScanningAsync(default(CancellationToken));
		}

		public async Task ConnectButtplug(string meIntifaceIP)
		{
			_intifaceIP = meIntifaceIP;
			if (client.Connected)
			{
				_logger.LogInfo((object)"Buttplug already connected, skipping");
				return;
			}
			_logger.LogInfo((object)"Buttplug Client Connecting");
			_logger.LogInfo((object)("Connecting to " + _intifaceIP));
			client.Dispose();
			client = new ButtplugClient("FuriousButtplug");
			try
			{
				await client.ConnectAsync((IButtplugClientConnector)new ButtplugWebsocketConnector(new Uri("ws://" + _intifaceIP)), default(CancellationToken));
				_logger.LogInfo((object)"Connection successful");
			}
			catch (TypeInitializationException ex2) when (ex2.TypeName == "Newtonsoft.Json.JsonWriter")
			{
				_logger.LogError((object)("JsonWriter initialization failed: " + ex2.Message));
				LogInnerExceptions(ex2.InnerException);
				return;
			}
			catch (Exception ex3)
			{
				Exception ex = ex3;
				_logger.LogError((object)("Connection failed: " + ex.Message));
				return;
			}
			_logger.LogInfo((object)$"{client.Devices.Count()} devices found on startup.");
			ButtplugClientDevice[] devices = client.Devices;
			foreach (ButtplugClientDevice device in devices)
			{
				_logger.LogInfo((object)$"- {device.Name} ({device.DisplayName} : {device.Index})");
			}
			client.DeviceAdded += HandleDeviceAdded;
			client.DeviceRemoved += HandleDeviceRemoved;
			client.ServerDisconnect += delegate
			{
				_logger.LogInfo((object)"Intiface Server disconnected.");
			};
			_logger.LogInfo((object)"Buttplug Client Connected");
		}

		public async Task DisconnectButtplug()
		{
			if (!client.Connected)
			{
				_logger.LogInfo((object)"Buttplug not connected, skipping");
				return;
			}
			_logger.LogInfo((object)"Disconnecting Buttplug Client");
			await client.DisconnectAsync();
		}

		private void HandleDeviceAdded(object sender, DeviceAddedEventArgs e)
		{
			_logger.LogInfo((object)$"Buttplug Device {e.Device.Name} ({e.Device.DisplayName} : {e.Device.Index}) Added");
		}

		private void HandleDeviceRemoved(object sender, DeviceRemovedEventArgs e)
		{
			_logger.LogInfo((object)$"Buttplug Device {e.Device.Name} ({e.Device.DisplayName} : {e.Device.Index}) Removed");
		}

		private bool HasVibrators()
		{
			if (!client.Connected)
			{
				return false;
			}
			if (client.Devices.Count() == 0)
			{
				_logger.LogInfo((object)"Either buttplug is not connected or no devices are available");
				return false;
			}
			if (!client.Devices.Any((ButtplugClientDevice device) => device.VibrateAttributes.Count > 0))
			{
				_logger.LogInfo((object)"No connected devices have vibrators available.");
				return false;
			}
			return true;
		}

		public async Task VibrateDevice(float level)
		{
			if (!HasVibrators())
			{
				return;
			}
			float intensity = Mathf.Clamp(level, 0f, 100f) / 100f;
			ButtplugClientDevice[] devices = client.Devices;
			foreach (ButtplugClientDevice device in devices)
			{
				if (device.VibrateAttributes.Count > 0)
				{
					_logger.LogInfo((object)$"Vibrating at {intensity}");
					await device.VibrateAsync((double)intensity);
				}
				else
				{
					_logger.LogInfo((object)("No vibrators on device " + device.Name));
				}
			}
		}

		public async Task VibrateDevicePulse(float level)
		{
			await VibrateDevicePulse(level, 400);
		}

		public async Task VibrateDevicePulse(float level, int duration)
		{
			if (!HasVibrators())
			{
				return;
			}
			lock (_vibrationLock)
			{
				_currentVibrationCts?.Cancel();
				_currentVibrationCts = new CancellationTokenSource();
			}
			CancellationToken token = _currentVibrationCts.Token;
			float intensity = Mathf.Clamp(level, 0f, 100f);
			_logger.LogInfo((object)$"VibrateDevicePulse {intensity}");
			try
			{
				await VibrateDevice(intensity);
				_lastVibrationTime = DateTime.Now;
				try
				{
					await Task.Delay(duration, token);
				}
				catch (TaskCanceledException)
				{
					return;
				}
				if (!token.IsCancellationRequested)
				{
					await VibrateDevice(0f);
				}
			}
			catch (Exception ex)
			{
				_logger.LogInfo((object)("Error during vibration: " + ex.Message));
				await VibrateDevice(0f);
			}
		}

		private async Task VibrateDeviceWithDuration(float intensity, int duration)
		{
			await VibrateDevice(intensity);
			await Task.Delay(duration);
		}

		public async Task StopDevices()
		{
			await VibrateDevice(0f);
		}
	}
	[BepInPlugin("DryIcedMatcha.FuriousButtplug", "Garfield Kart Furious Buttplug", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(BonusEffectMgr))]
		[HarmonyPatch("ActivateBonusEffect")]
		public class BonusEffectMgrPatch
		{
			private static void Postfix(BonusEffectMgr __instance, EBonusEffect _BonusEffect)
			{
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Invalid comparison between Unknown and I4
				Kart target = __instance.Target;
				if (!((Object)(object)target != (Object)null) || !((Object)(object)target.Driver != (Object)null) || !target.Driver.IsLocal || !target.Driver.IsHuman)
				{
					return;
				}
				Logger.LogInfo((object)$"Local HUMAN Player {target.Driver.Id} hit by effect: {_BonusEffect}");
				if ((int)_BonusEffect != 0)
				{
					if ((int)_BonusEffect == 6)
					{
						if (Instance.configEnableUFOVibration.Value)
						{
							buttplugManager.VibrateDevicePulse(Instance.configPlayerUFOEffectIntensity.Value, 3000);
						}
					}
					else if (Instance.configEnablePlayerHitVibration.Value)
					{
						buttplugManager.VibrateDevicePulse(Instance.configPlayerHitEffectIntensity.Value);
					}
				}
				else if (Instance.configEnableBoostPadVibration.Value)
				{
					buttplugManager.VibrateDevicePulse(Instance.configBoostIntensity.Value, 1800);
				}
			}
		}

		[HarmonyPatch(typeof(Kart))]
		[HarmonyPatch("LaunchMiniBoost")]
		public class Kart_DriftBoostPatch
		{
			private static ManualLogSource Logger = Logger.CreateLogSource("DriftBoostMod");

			public static bool isBoostActive = false;

			public static long boostEndTime = 0L;

			private static void Postfix(Kart __instance)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Invalid comparison between Unknown and I4
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Invalid comparison between Unknown and I4
				if (!((Object)(object)__instance != (Object)null) || !((Object)(object)__instance.Driver != (Object)null) || !__instance.Driver.IsLocal || !__instance.Driver.IsHuman)
				{
					return;
				}
				DRIFT_STATE driftState = __instance.m_driftState;
				Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} STOPPED drifting via BOOST.");
				Kart_StartDriftPatch.isDrifting = false;
				if (!Instance.configEnableDriftBoostVibration.Value)
				{
					return;
				}
				DRIFT_STATE val = driftState;
				DRIFT_STATE val2 = val;
				if ((int)val2 != 2)
				{
					if ((int)val2 == 3)
					{
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} executed a Level 2 Drift Boost!");
						buttplugManager.VibrateDevicePulse(Instance.configMiniBoostLevel2Intensity.Value, 1800);
						isBoostActive = true;
					}
				}
				else
				{
					Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} executed a Level 1 Drift Boost!");
					buttplugManager.VibrateDevicePulse(Instance.configMiniBoostLevel1Intensity.Value, 600);
					isBoostActive = true;
				}
			}
		}

		[HarmonyPatch(typeof(Driver))]
		[HarmonyPatch("OnCollisionEnter")]
		public class Driver_CollisionPatch
		{
			private static ManualLogSource Logger = Logger.CreateLogSource("CollisionMod");

			private static void Postfix(Driver __instance, Collision collision)
			{
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				Kart kart = __instance.Kart;
				if (!((Object)(object)kart != (Object)null) || !__instance.IsLocal || !__instance.IsHuman || !Instance.configEnableCollisionVibration.Value)
				{
					return;
				}
				GameObject gameObject = collision.gameObject;
				int layer = gameObject.layer;
				string text = LayerMask.LayerToName(layer);
				if (text == "ColWall" || text == "Vehicle")
				{
					Vector3 relativeVelocity = collision.relativeVelocity;
					float magnitude = ((Vector3)(ref relativeVelocity)).magnitude;
					if (magnitude > 4f)
					{
						Logger.LogInfo((object)$"Local Player {__instance.Id} collided with {((Object)gameObject).name} (Layer: {text}) with force: {magnitude}");
						int num = Mathf.Min(100, Mathf.RoundToInt(magnitude * Instance.configCollisionForceMultiplier.Value));
						buttplugManager.VibrateDevicePulse(num, 300);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Kart))]
		[HarmonyPatch("SetDriftState")]
		public class Kart_StartDriftPatch
		{
			private static ManualLogSource Logger = Logger.CreateLogSource("DriftMod");

			public static bool isDrifting = false;

			private static void Prefix(Kart __instance, DRIFT_STATE state)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Invalid comparison between Unknown and I4
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Invalid comparison between Unknown and I4
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance != (Object)null) || !((Object)(object)__instance.Driver != (Object)null) || !__instance.Driver.IsLocal || !__instance.Driver.IsHuman)
				{
					return;
				}
				if ((int)__instance.m_driftState == 0 && (int)state > 0)
				{
					if (!isDrifting)
					{
						isDrifting = true;
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} STARTED drifting. New state: {state}");
						buttplugManager.VibrateDevice(Instance.configDriftBaseIntensity.Value);
					}
				}
				else if ((int)__instance.m_driftState != 0 && (int)state == 0)
				{
					Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} STOPPED drifting (SetDriftState to NONE)");
					isDrifting = false;
					if (!Kart_DriftBoostPatch.isBoostActive)
					{
						buttplugManager.VibrateDevice(0f);
					}
					Kart_DriftBoostPatch.isBoostActive = false;
				}
			}

			private static void Postfix(Kart __instance, DRIFT_STATE state)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Invalid comparison between Unknown and I4
				if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.Driver != (Object)null && __instance.Driver.IsLocal && __instance.Driver.IsHuman && (int)state == 0)
				{
					isDrifting = false;
				}
			}
		}

		[HarmonyPatch(typeof(Kart))]
		[HarmonyPatch("SetDriftState")]
		public class Kart_DriftStateChangePatch
		{
			private static ManualLogSource Logger = Logger.CreateLogSource("DriftMod");

			private static void Prefix(Kart __instance, DRIFT_STATE state)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected I4, but got Unknown
				if (!((Object)(object)__instance != (Object)null) || !((Object)(object)__instance.Driver != (Object)null) || !__instance.Driver.IsLocal || !__instance.Driver.IsHuman || !Instance.configEnableDriftChargeVibration.Value)
				{
					return;
				}
				DRIFT_STATE driftState = __instance.m_driftState;
				if (driftState != state)
				{
					switch ((int)state)
					{
					case 0:
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} Drift State changed to NONE. Stopping vibration.");
						break;
					case 1:
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} Drift State changed to NO_BOOST. Setting vibration intensity 1.");
						buttplugManager.VibrateDevice(Instance.configDriftBaseIntensity.Value);
						break;
					case 2:
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} Drift State changed to FIRST_THRESHOLD. Setting vibration intensity 2.");
						buttplugManager.VibrateDevice(Instance.configDriftLevel1Intensity.Value);
						break;
					case 3:
						Logger.LogInfo((object)$"Local Player {__instance.Driver.Id} Drift State changed to SECOND_THRESHOLD. Setting vibration intensity 3.");
						buttplugManager.VibrateDevice(Instance.configDriftLevel2Intensity.Value);
						break;
					}
				}
			}
		}

		[HarmonyPatch(typeof(RcVehicleRaceStats))]
		[HarmonyPatch("CrossStartLine")]
		public class RcVehicleRaceStats_LapFinishPatch
		{
			private static ManualLogSource Logger = Logger.CreateLogSource("LapFinishMod");

			private static void Postfix(RcVehicleRaceStats __instance, int _gameTime, bool _bReverse)
			{
				RcVehicle vehicle = __instance.GetVehicle();
				Kart val = (Kart)(object)((vehicle is Kart) ? vehicle : null);
				if ((Object)(object)val == (Object)null || (Object)(object)val.Driver == (Object)null || _bReverse || !val.Driver.IsLocal || !val.Driver.IsHuman)
				{
					return;
				}
				int nbLapCompleted = __instance.GetNbLapCompleted();
				int raceNbLap = __instance.GetRaceNbLap();
				if (__instance.IsRaceEnded())
				{
					Logger.LogInfo((object)$"Local Player {val.Driver.Id} FINISHED THE RACE!");
					if (Instance.configEnableRaceFinishVibration.Value)
					{
						buttplugManager.VibrateDevicePulse(Instance.configRaceFinishIntensity.Value, 2000);
					}
				}
				else if (nbLapCompleted > 0)
				{
					Logger.LogInfo((object)$"Local Player {val.Driver.Id} started NEW LAP ({nbLapCompleted}/{raceNbLap})!");
					if (Instance.configEnableLapCompleteVibration.Value)
					{
						buttplugManager.VibrateDevicePulse(Instance.configLapCompleteIntensity.Value, 700);
					}
				}
			}
		}

		internal static ManualLogSource Logger;

		private static BPManager buttplugManager;

		private Harmony harmony;

		private ConfigEntry<string> configServerAddress;

		private ConfigEntry<int> configDriftBaseIntensity;

		private ConfigEntry<int> configDriftLevel1Intensity;

		private ConfigEntry<int> configDriftLevel2Intensity;

		private ConfigEntry<int> configBoostIntensity;

		private ConfigEntry<int> configMiniBoostLevel1Intensity;

		private ConfigEntry<int> configMiniBoostLevel2Intensity;

		private ConfigEntry<float> configCollisionForceMultiplier;

		private ConfigEntry<int> configLapCompleteIntensity;

		private ConfigEntry<int> configRaceFinishIntensity;

		private ConfigEntry<int> configPlayerHitEffectIntensity;

		private ConfigEntry<int> configPlayerUFOEffectIntensity;

		private ConfigEntry<bool> configEnableDriftChargeVibration;

		private ConfigEntry<bool> configEnableDriftBoostVibration;

		private ConfigEntry<bool> configEnableCollisionVibration;

		private ConfigEntry<bool> configEnableLapCompleteVibration;

		private ConfigEntry<bool> configEnableRaceFinishVibration;

		private ConfigEntry<bool> configEnablePlayerHitVibration;

		private ConfigEntry<bool> configEnableUFOVibration;

		private ConfigEntry<bool> configEnableBoostPadVibration;

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Logger.LogInfo((object)"Plugin FuriousButtplug is loaded!");
			InitializeConfig();
			buttplugManager = new BPManager(Logger);
			harmony = new Harmony("com.dryicedmatcha.furiousbuttplug");
			harmony.PatchAll();
			Task.Run(async delegate
			{
				await buttplugManager.ConnectButtplug(configServerAddress.Value);
				await buttplugManager.ScanForDevices();
			});
		}

		private void InitializeConfig()
		{
			configServerAddress = ((BaseUnityPlugin)this).Config.Bind<string>("Connection", "ServerAddress", "localhost:12345", "Address of the Intiface/Buttplug server");
			configDriftBaseIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Drift", "BaseIntensity", 10, "Base vibration intensity when starting to drift (0-100)");
			configDriftLevel1Intensity = ((BaseUnityPlugin)this).Config.Bind<int>("Drift", "Level1Intensity", 20, "Vibration intensity at drift level 1 (blue sparks) (0-100)");
			configDriftLevel2Intensity = ((BaseUnityPlugin)this).Config.Bind<int>("Drift", "Level2Intensity", 30, "Vibration intensity at drift level 2 (red sparks) (0-100)");
			configBoostIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Boost", "Intensity", 100, "Vibration intensity when hitting a boost pad/item (0-100)");
			configMiniBoostLevel1Intensity = ((BaseUnityPlugin)this).Config.Bind<int>("MiniBoost", "Level1Intensity", 50, "Vibration intensity for level 1 drift mini-boost (0-100)");
			configMiniBoostLevel2Intensity = ((BaseUnityPlugin)this).Config.Bind<int>("MiniBoost", "Level2Intensity", 50, "Vibration intensity for level 2 drift mini-boost (0-100)");
			configCollisionForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Collision", "ForceMultiplier", 10f, "Multiplier for collision force to determine vibration intensity when colliding with cars/walls");
			configLapCompleteIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Lap", "CompleteIntensity", 60, "Vibration intensity when completing a lap (0-100)");
			configRaceFinishIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Lap", "RaceFinishIntensity", 60, "Vibration intensity when finishing the race (0-100)");
			configPlayerHitEffectIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Effects", "HitEffectIntensity", 60, "Vibration intensity when player is hit by an effect/item (0-100)");
			configPlayerUFOEffectIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("Effects", "UFOEffectIntensity", 60, "Vibration intensity for UFO/Levitate effect (0-100)");
			configEnableDriftChargeVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableDriftChargeVibration", true, "Enable vibration during drift charging");
			configEnableDriftBoostVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableDriftBoostVibration", true, "Enable vibration for drift boosts/miniturbo");
			configEnableCollisionVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableCollisionVibration", true, "Enable vibration when colliding with objects or vehicles");
			configEnableLapCompleteVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableLapCompleteVibration", true, "Enable vibration when completing a lap");
			configEnableRaceFinishVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableRaceFinishVibration", true, "Enable vibration when finishing the race");
			configEnablePlayerHitVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnablePlayerHitVibration", true, "Enable vibration when player is hit by items/effects");
			configEnableUFOVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableUFOVibration", true, "Enable vibration for UFO/levitate effect");
			configEnableBoostPadVibration = ((BaseUnityPlugin)this).Config.Bind<bool>("Vibration Toggles", "EnableBoostPadVibration", true, "Enable vibration for boost pads/items");
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FuriousButtplug";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

FuriousButtplug/Newtonsoft.Json.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq.JsonPath;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
[assembly: AssemblyCompany("Newtonsoft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
[assembly: AssemblyFileVersion("13.0.3.27908")]
[assembly: AssemblyInformationalVersion("13.0.3+0a2e291c0d9c0c7675d445703e51750363a549ef")]
[assembly: AssemblyProduct("Json.NET")]
[assembly: AssemblyTitle("Json.NET .NET 4.5")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/JamesNK/Newtonsoft.Json")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("13.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
}
namespace Newtonsoft.Json
{
	public enum ConstructorHandling
	{
		Default,
		AllowNonPublicDefaultConstructor
	}
	public enum DateFormatHandling
	{
		IsoDateFormat,
		MicrosoftDateFormat
	}
	public enum DateParseHandling
	{
		None,
		DateTime,
		DateTimeOffset
	}
	public enum DateTimeZoneHandling
	{
		Local,
		Utc,
		Unspecified,
		RoundtripKind
	}
	public class DefaultJsonNameTable : JsonNameTable
	{
		private class Entry
		{
			internal readonly string Value;

			internal readonly int HashCode;

			internal Entry Next;

			internal Entry(string value, int hashCode, Entry next)
			{
				Value = value;
				HashCode = hashCode;
				Next = next;
			}
		}

		private static readonly int HashCodeRandomizer;

		private int _count;

		private Entry[] _entries;

		private int _mask = 31;

		static DefaultJsonNameTable()
		{
			HashCodeRandomizer = Environment.TickCount;
		}

		public DefaultJsonNameTable()
		{
			_entries = new Entry[_mask + 1];
		}

		public override string? Get(char[] key, int start, int length)
		{
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			num += (num << 7) ^ key[start];
			int num2 = start + length;
			for (int i = start + 1; i < num2; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			int num3 = Volatile.Read(ref _mask);
			int num4 = num & num3;
			for (Entry entry = _entries[num4]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && TextEquals(entry.Value, key, start, length))
				{
					return entry.Value;
				}
			}
			return null;
		}

		public string Add(string key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			int length = key.Length;
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			for (int i = 0; i < key.Length; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal))
				{
					return entry.Value;
				}
			}
			return AddEntry(key, num);
		}

		private string AddEntry(string str, int hashCode)
		{
			int num = hashCode & _mask;
			Entry entry = new Entry(str, hashCode, _entries[num]);
			_entries[num] = entry;
			if (_count++ == _mask)
			{
				Grow();
			}
			return entry.Value;
		}

		private void Grow()
		{
			Entry[] entries = _entries;
			int num = _mask * 2 + 1;
			Entry[] array = new Entry[num + 1];
			for (int i = 0; i < entries.Length; i++)
			{
				Entry entry = entries[i];
				while (entry != null)
				{
					int num2 = entry.HashCode & num;
					Entry next = entry.Next;
					entry.Next = array[num2];
					array[num2] = entry;
					entry = next;
				}
			}
			_entries = array;
			Volatile.Write(ref _mask, num);
		}

		private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length)
		{
			if (str1.Length != str2Length)
			{
				return false;
			}
			for (int i = 0; i < str1.Length; i++)
			{
				if (str1[i] != str2[str2Start + i])
				{
					return false;
				}
			}
			return true;
		}
	}
	[Flags]
	public enum DefaultValueHandling
	{
		Include = 0,
		Ignore = 1,
		Populate = 2,
		IgnoreAndPopulate = 3
	}
	public enum FloatFormatHandling
	{
		String,
		Symbol,
		DefaultValue
	}
	public enum FloatParseHandling
	{
		Double,
		Decimal
	}
	public enum Formatting
	{
		None,
		Indented
	}
	public interface IArrayPool<T>
	{
		T[] Rent(int minimumLength);

		void Return(T[]? array);
	}
	public interface IJsonLineInfo
	{
		int LineNumber { get; }

		int LinePosition { get; }

		bool HasLineInfo();
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonArrayAttribute : JsonContainerAttribute
	{
		private bool _allowNullItems;

		public bool AllowNullItems
		{
			get
			{
				return _allowNullItems;
			}
			set
			{
				_allowNullItems = value;
			}
		}

		public JsonArrayAttribute()
		{
		}

		public JsonArrayAttribute(bool allowNullItems)
		{
			_allowNullItems = allowNullItems;
		}

		public JsonArrayAttribute(string id)
			: base(id)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)]
	public sealed class JsonConstructorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public abstract class JsonContainerAttribute : Attribute
	{
		internal bool? _isReference;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		private Type? _namingStrategyType;

		private object[]? _namingStrategyParameters;

		public string? Id { get; set; }

		public string? Title { get; set; }

		public string? Description { get; set; }

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType
		{
			get
			{
				return _namingStrategyType;
			}
			set
			{
				_namingStrategyType = value;
				NamingStrategyInstance = null;
			}
		}

		public object[]? NamingStrategyParameters
		{
			get
			{
				return _namingStrategyParameters;
			}
			set
			{
				_namingStrategyParameters = value;
				NamingStrategyInstance = null;
			}
		}

		internal NamingStrategy? NamingStrategyInstance { get; set; }

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		protected JsonContainerAttribute()
		{
		}

		protected JsonContainerAttribute(string id)
		{
			Id = id;
		}
	}
	public static class JsonConvert
	{
		public static readonly string True = "true";

		public static readonly string False = "false";

		public static readonly string Null = "null";

		public static readonly string Undefined = "undefined";

		public static readonly string PositiveInfinity = "Infinity";

		public static readonly string NegativeInfinity = "-Infinity";

		public static readonly string NaN = "NaN";

		public static Func<JsonSerializerSettings>? DefaultSettings { get; set; }

		public static string ToString(DateTime value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind);
		}

		public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
		{
			DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling);
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(DateTimeOffset value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat);
		}

		public static string ToString(DateTimeOffset value, DateFormatHandling format)
		{
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(bool value)
		{
			if (!value)
			{
				return False;
			}
			return True;
		}

		public static string ToString(char value)
		{
			return ToString(char.ToString(value));
		}

		public static string ToString(Enum value)
		{
			return value.ToString("D");
		}

		public static string ToString(int value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(short value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ushort value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(uint value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(long value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		private static string ToStringInternal(BigInteger value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ulong value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(float value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value)))
			{
				return text;
			}
			if (floatFormatHandling == FloatFormatHandling.DefaultValue)
			{
				if (nullable)
				{
					return Null;
				}
				return "0.0";
			}
			return quoteChar + text + quoteChar;
		}

		public static string ToString(double value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureDecimalPlace(double value, string text)
		{
			if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		private static string EnsureDecimalPlace(string text)
		{
			if (StringUtils.IndexOf(text, '.') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		public static string ToString(byte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(sbyte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(decimal value)
		{
			return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture));
		}

		public static string ToString(Guid value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(Guid value, char quoteChar)
		{
			string text = value.ToString("D", CultureInfo.InvariantCulture);
			string text2 = quoteChar.ToString(CultureInfo.InvariantCulture);
			return text2 + text + text2;
		}

		public static string ToString(TimeSpan value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(TimeSpan value, char quoteChar)
		{
			return ToString(value.ToString(), quoteChar);
		}

		public static string ToString(Uri? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ToString(value, '"');
		}

		internal static string ToString(Uri value, char quoteChar)
		{
			return ToString(value.OriginalString, quoteChar);
		}

		public static string ToString(string? value)
		{
			return ToString(value, '"');
		}

		public static string ToString(string? value, char delimiter)
		{
			return ToString(value, delimiter, StringEscapeHandling.Default);
		}

		public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling)
		{
			if (delimiter != '"' && delimiter != '\'')
			{
				throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
			}
			return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling);
		}

		public static string ToString(object? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ConvertUtils.GetTypeCode(value.GetType()) switch
			{
				PrimitiveTypeCode.String => ToString((string)value), 
				PrimitiveTypeCode.Char => ToString((char)value), 
				PrimitiveTypeCode.Boolean => ToString((bool)value), 
				PrimitiveTypeCode.SByte => ToString((sbyte)value), 
				PrimitiveTypeCode.Int16 => ToString((short)value), 
				PrimitiveTypeCode.UInt16 => ToString((ushort)value), 
				PrimitiveTypeCode.Int32 => ToString((int)value), 
				PrimitiveTypeCode.Byte => ToString((byte)value), 
				PrimitiveTypeCode.UInt32 => ToString((uint)value), 
				PrimitiveTypeCode.Int64 => ToString((long)value), 
				PrimitiveTypeCode.UInt64 => ToString((ulong)value), 
				PrimitiveTypeCode.Single => ToString((float)value), 
				PrimitiveTypeCode.Double => ToString((double)value), 
				PrimitiveTypeCode.DateTime => ToString((DateTime)value), 
				PrimitiveTypeCode.Decimal => ToString((decimal)value), 
				PrimitiveTypeCode.DBNull => Null, 
				PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), 
				PrimitiveTypeCode.Guid => ToString((Guid)value), 
				PrimitiveTypeCode.Uri => ToString((Uri)value), 
				PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), 
				PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), 
				_ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), 
			};
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value)
		{
			return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting)
		{
			return SerializeObject(value, formatting, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			jsonSerializer.Formatting = formatting;
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer)
		{
			StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture);
			using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter))
			{
				jsonTextWriter.Formatting = jsonSerializer.Formatting;
				jsonSerializer.Serialize(jsonTextWriter, value, type);
			}
			return stringWriter.ToString();
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value)
		{
			return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, JsonSerializerSettings settings)
		{
			return DeserializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type)
		{
			return DeserializeObject(value, type, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value)
		{
			return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
		{
			return DeserializeObject<T>(value);
		}

		[DebuggerStepThrough]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
		{
			return DeserializeObject<T>(value, settings);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value, params JsonConverter[] converters)
		{
			return (T)DeserializeObject(value, typeof(T), converters);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings)
		{
			return (T)DeserializeObject(value, typeof(T), settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return DeserializeObject(value, type, settings);
		}

		public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			if (!jsonSerializer.IsCheckAdditionalContentSet())
			{
				jsonSerializer.CheckAdditionalContent = true;
			}
			using JsonTextReader reader = new JsonTextReader(new StringReader(value));
			return jsonSerializer.Deserialize(reader, type);
		}

		[DebuggerStepThrough]
		public static void PopulateObject(string value, object target)
		{
			PopulateObject(value, target, null);
		}

		public static void PopulateObject(string value, object target, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			using JsonReader jsonReader = new JsonTextReader(new StringReader(value));
			jsonSerializer.Populate(jsonReader, target);
			if (settings == null || !settings.CheckAdditionalContent)
			{
				return;
			}
			while (jsonReader.Read())
			{
				if (jsonReader.TokenType != JsonToken.Comment)
				{
					throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object.");
				}
			}
		}

		public static string SerializeXmlNode(XmlNode? node)
		{
			return SerializeXmlNode(node, Formatting.None);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XmlDocument? DeserializeXmlNode(string value)
		{
			return DeserializeXmlNode(value, null);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter);
		}

		public static string SerializeXNode(XObject? node)
		{
			return SerializeXNode(node, Formatting.None);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting)
		{
			return SerializeXNode(node, formatting, omitRootObject: false);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XDocument? DeserializeXNode(string value)
		{
			return DeserializeXNode(value, null);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter);
		}
	}
	public abstract class JsonConverter
	{
		public virtual bool CanRead => true;

		public virtual bool CanWrite => true;

		public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer);

		public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer);

		public abstract bool CanConvert(Type objectType);
	}
	public abstract class JsonConverter<T> : JsonConverter
	{
		public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
		{
			if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T))))
			{
				throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			WriteJson(writer, (T)value, serializer);
		}

		public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer);

		public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
		{
			bool flag = existingValue == null;
			if (!flag && !(existingValue is T))
			{
				throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer);
		}

		public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer);

		public sealed override bool CanConvert(Type objectType)
		{
			return typeof(T).IsAssignableFrom(objectType);
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonConverterAttribute : Attribute
	{
		private readonly Type _converterType;

		public Type ConverterType => _converterType;

		public object[]? ConverterParameters { get; }

		public JsonConverterAttribute(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			_converterType = converterType;
		}

		public JsonConverterAttribute(Type converterType, params object[] converterParameters)
			: this(converterType)
		{
			ConverterParameters = converterParameters;
		}
	}
	public class JsonConverterCollection : Collection<JsonConverter>
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonDictionaryAttribute : JsonContainerAttribute
	{
		public JsonDictionaryAttribute()
		{
		}

		public JsonDictionaryAttribute(string id)
			: base(id)
		{
		}
	}
	[Serializable]
	public class JsonException : Exception
	{
		public JsonException()
		{
		}

		public JsonException(string message)
			: base(message)
		{
		}

		public JsonException(string message, Exception? innerException)
			: base(message, innerException)
		{
		}

		public JsonException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			return new JsonException(message);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public class JsonExtensionDataAttribute : Attribute
	{
		public bool WriteData { get; set; }

		public bool ReadData { get; set; }

		public JsonExtensionDataAttribute()
		{
			WriteData = true;
			ReadData = true;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonIgnoreAttribute : Attribute
	{
	}
	public abstract class JsonNameTable
	{
		public abstract string? Get(char[] key, int start, int length);
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)]
	public sealed class JsonObjectAttribute : JsonContainerAttribute
	{
		private MemberSerialization _memberSerialization;

		internal MissingMemberHandling? _missingMemberHandling;

		internal Required? _itemRequired;

		internal NullValueHandling? _itemNullValueHandling;

		public MemberSerialization MemberSerialization
		{
			get
			{
				return _memberSerialization;
			}
			set
			{
				_memberSerialization = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public NullValueHandling ItemNullValueHandling
		{
			get
			{
				return _itemNullValueHandling.GetValueOrDefault();
			}
			set
			{
				_itemNullValueHandling = value;
			}
		}

		public Required ItemRequired
		{
			get
			{
				return _itemRequired.GetValueOrDefault();
			}
			set
			{
				_itemRequired = value;
			}
		}

		public JsonObjectAttribute()
		{
		}

		public JsonObjectAttribute(MemberSerialization memberSerialization)
		{
			MemberSerialization = memberSerialization;
		}

		public JsonObjectAttribute(string id)
			: base(id)
		{
		}
	}
	internal enum JsonContainerType
	{
		None,
		Object,
		Array,
		Constructor
	}
	internal struct JsonPosition
	{
		private static readonly char[] SpecialCharacters = new char[18]
		{
			'.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t',
			'\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029'
		};

		internal JsonContainerType Type;

		internal int Position;

		internal string? PropertyName;

		internal bool HasIndex;

		public JsonPosition(JsonContainerType type)
		{
			Type = type;
			HasIndex = TypeHasIndex(type);
			Position = -1;
			PropertyName = null;
		}

		internal int CalculateLength()
		{
			switch (Type)
			{
			case JsonContainerType.Object:
				return PropertyName.Length + 5;
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				return MathUtils.IntLength((ulong)Position) + 2;
			default:
				throw new ArgumentOutOfRangeException("Type");
			}
		}

		internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer)
		{
			switch (Type)
			{
			case JsonContainerType.Object:
			{
				string propertyName = PropertyName;
				if (propertyName.IndexOfAny(SpecialCharacters) != -1)
				{
					sb.Append("['");
					if (writer == null)
					{
						writer = new StringWriter(sb);
					}
					JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer);
					sb.Append("']");
				}
				else
				{
					if (sb.Length > 0)
					{
						sb.Append('.');
					}
					sb.Append(propertyName);
				}
				break;
			}
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				sb.Append('[');
				sb.Append(Position);
				sb.Append(']');
				break;
			}
		}

		internal static bool TypeHasIndex(JsonContainerType type)
		{
			if (type != JsonContainerType.Array)
			{
				return type == JsonContainerType.Constructor;
			}
			return true;
		}

		internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition)
		{
			int num = 0;
			if (positions != null)
			{
				for (int i = 0; i < positions.Count; i++)
				{
					num += positions[i].CalculateLength();
				}
			}
			if (currentPosition.HasValue)
			{
				num += currentPosition.GetValueOrDefault().CalculateLength();
			}
			StringBuilder stringBuilder = new StringBuilder(num);
			StringWriter writer = null;
			char[] buffer = null;
			if (positions != null)
			{
				foreach (JsonPosition position in positions)
				{
					position.WriteTo(stringBuilder, ref writer, ref buffer);
				}
			}
			currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer);
			return stringBuilder.ToString();
		}

		internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message)
		{
			if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal))
			{
				message = message.Trim();
				if (!StringUtils.EndsWith(message, '.'))
				{
					message += ".";
				}
				message += " ";
			}
			message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path);
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
			}
			message += ".";
			return message;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
	public sealed class JsonPropertyAttribute : Attribute
	{
		internal NullValueHandling? _nullValueHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal bool? _isReference;

		internal int? _order;

		internal Required? _required;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType { get; set; }

		public object[]? NamingStrategyParameters { get; set; }

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling.GetValueOrDefault();
			}
			set
			{
				_typeNameHandling = value;
			}
		}

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public int Order
		{
			get
			{
				return _order.GetValueOrDefault();
			}
			set
			{
				_order = value;
			}
		}

		public Required Required
		{
			get
			{
				return _required.GetValueOrDefault();
			}
			set
			{
				_required = value;
			}
		}

		public string? PropertyName { get; set; }

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public JsonPropertyAttribute()
		{
		}

		public JsonPropertyAttribute(string propertyName)
		{
			PropertyName = propertyName;
		}
	}
	public abstract class JsonReader : IDisposable
	{
		protected internal enum State
		{
			Start,
			Complete,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			Closed,
			PostValue,
			ConstructorStart,
			Constructor,
			Error,
			Finished
		}

		private JsonToken _tokenType;

		private object? _value;

		internal char _quoteChar;

		internal State _currentState;

		private JsonPosition _currentPosition;

		private CultureInfo? _culture;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private int? _maxDepth;

		private bool _hasExceededMaxDepth;

		internal DateParseHandling _dateParseHandling;

		internal FloatParseHandling _floatParseHandling;

		private string? _dateFormatString;

		private List<JsonPosition>? _stack;

		protected State CurrentState => _currentState;

		public bool CloseInput { get; set; }

		public bool SupportMultipleContent { get; set; }

		public virtual char QuoteChar
		{
			get
			{
				return _quoteChar;
			}
			protected internal set
			{
				_quoteChar = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling;
			}
			set
			{
				if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateTimeZoneHandling = value;
			}
		}

		public DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling;
			}
			set
			{
				if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateParseHandling = value;
			}
		}

		public FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling;
			}
			set
			{
				if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_floatParseHandling = value;
			}
		}

		public string? DateFormatString
		{
			get
			{
				return _dateFormatString;
			}
			set
			{
				_dateFormatString = value;
			}
		}

		public int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
			}
		}

		public virtual JsonToken TokenType => _tokenType;

		public virtual object? Value => _value;

		public virtual Type? ValueType => _value?.GetType();

		public virtual int Depth
		{
			get
			{
				int num = _stack?.Count ?? 0;
				if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None)
				{
					return num;
				}
				return num + 1;
			}
		}

		public virtual string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null);
				return JsonPosition.BuildPath(_stack, currentPosition);
			}
		}

		public CultureInfo Culture
		{
			get
			{
				return _culture ?? CultureInfo.InvariantCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync();
		}

		public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			if (TokenType == JsonToken.PropertyName)
			{
				await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth)
				{
				}
			}
		}

		internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken)
		{
			if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
			{
				throw CreateUnexpectedEndException();
			}
		}

		public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean());
		}

		public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes());
		}

		internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken)
		{
			List<byte> buffer = new List<byte>();
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(buffer));
			byte[] array = buffer.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime());
		}

		public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset());
		}

		public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal());
		}

		public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return Task.FromResult(ReadAsDouble());
		}

		public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32());
		}

		public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString());
		}

		internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken)
		{
			bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (flag)
			{
				flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			return flag;
		}

		internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType = TokenType;
			if (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				return MoveToContentFromNonContentAsync(cancellationToken);
			}
			return AsyncUtils.True;
		}

		private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType;
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					return false;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment);
			return true;
		}

		internal JsonPosition GetPosition(int depth)
		{
			if (_stack != null && depth < _stack.Count)
			{
				return _stack[depth];
			}
			return _currentPosition;
		}

		protected JsonReader()
		{
			_currentState = State.Start;
			_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
			_dateParseHandling = DateParseHandling.DateTime;
			_floatParseHandling = FloatParseHandling.Double;
			_maxDepth = 64;
			CloseInput = true;
		}

		private void Push(JsonContainerType value)
		{
			UpdateScopeWithFinishedValue();
			if (_currentPosition.Type == JsonContainerType.None)
			{
				_currentPosition = new JsonPosition(value);
				return;
			}
			if (_stack == null)
			{
				_stack = new List<JsonPosition>();
			}
			_stack.Add(_currentPosition);
			_currentPosition = new JsonPosition(value);
			if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth)
			{
				return;
			}
			_hasExceededMaxDepth = true;
			throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth));
		}

		private JsonContainerType Pop()
		{
			JsonPosition currentPosition;
			if (_stack != null && _stack.Count > 0)
			{
				currentPosition = _currentPosition;
				_currentPosition = _stack[_stack.Count - 1];
				_stack.RemoveAt(_stack.Count - 1);
			}
			else
			{
				currentPosition = _currentPosition;
				_currentPosition = default(JsonPosition);
			}
			if (_maxDepth.HasValue && Depth <= _maxDepth)
			{
				_hasExceededMaxDepth = false;
			}
			return currentPosition.Type;
		}

		private JsonContainerType Peek()
		{
			return _currentPosition.Type;
		}

		public abstract bool Read();

		public virtual int? ReadAsInt32()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is int)
				{
					return (int)value;
				}
				int num;
				if (value is BigInteger bigInteger)
				{
					num = (int)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToInt32(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Integer, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadInt32String(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal int? ReadInt32String(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (int.TryParse(s, NumberStyles.Integer, Culture, out var result))
			{
				SetToken(JsonToken.Integer, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual string? ReadAsString()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.String:
				return (string)Value;
			default:
				if (JsonTokenUtils.IsPrimitiveToken(contentToken))
				{
					object value = Value;
					if (value != null)
					{
						string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture));
						SetToken(JsonToken.String, text, updateIndex: false);
						return text;
					}
				}
				throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		public virtual byte[]? ReadAsBytes()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.StartObject:
			{
				ReadIntoWrappedTypeObject();
				byte[] array2 = ReadAsBytes();
				ReaderReadAndAssert();
				if (TokenType != JsonToken.EndObject)
				{
					throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
				}
				SetToken(JsonToken.Bytes, array2, updateIndex: false);
				return array2;
			}
			case JsonToken.String:
			{
				string text = (string)Value;
				Guid g;
				byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray()));
				SetToken(JsonToken.Bytes, array3, updateIndex: false);
				return array3;
			}
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Bytes:
				if (Value is Guid guid)
				{
					byte[] array = guid.ToByteArray();
					SetToken(JsonToken.Bytes, array, updateIndex: false);
					return array;
				}
				return (byte[])Value;
			case JsonToken.StartArray:
				return ReadArrayIntoByteArray();
			default:
				throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal byte[] ReadArrayIntoByteArray()
		{
			List<byte> list = new List<byte>();
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(list));
			byte[] array = list.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer)
		{
			switch (TokenType)
			{
			case JsonToken.None:
				throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
			case JsonToken.Integer:
				buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
				return false;
			case JsonToken.EndArray:
				return true;
			case JsonToken.Comment:
				return false;
			default:
				throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		public virtual double? ReadAsDouble()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is double)
				{
					return (double)value;
				}
				double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger));
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDoubleString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal double? ReadDoubleString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual bool? ReadAsBoolean()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L));
				SetToken(JsonToken.Boolean, flag, updateIndex: false);
				return flag;
			}
			case JsonToken.String:
				return ReadBooleanString((string)Value);
			case JsonToken.Boolean:
				return (bool)Value;
			default:
				throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal bool? ReadBooleanString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (bool.TryParse(s, out var result))
			{
				SetToken(JsonToken.Boolean, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual decimal? ReadAsDecimal()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Integer:
			case JsonToken.Float:
			{
				object value = Value;
				if (value is decimal)
				{
					return (decimal)value;
				}
				decimal num;
				if (value is BigInteger bigInteger)
				{
					num = (decimal)bigInteger;
				}
				else
				{
					try
					{
						num = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
					}
					catch (Exception ex)
					{
						throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
					}
				}
				SetToken(JsonToken.Float, num, updateIndex: false);
				return num;
			}
			case JsonToken.String:
				return ReadDecimalString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal decimal? ReadDecimalString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result))
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success)
			{
				SetToken(JsonToken.Float, result, updateIndex: false);
				return result;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTime? ReadAsDateTime()
		{
			switch (GetContentToken())
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTimeOffset dateTimeOffset)
				{
					SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false);
				}
				return (DateTime)Value;
			case JsonToken.String:
				return ReadDateTimeString((string)Value);
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
			}
		}

		internal DateTime? ReadDateTimeString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		public virtual DateTimeOffset? ReadAsDateTimeOffset()
		{
			JsonToken contentToken = GetContentToken();
			switch (contentToken)
			{
			case JsonToken.None:
			case JsonToken.Null:
			case JsonToken.EndArray:
				return null;
			case JsonToken.Date:
				if (Value is DateTime dateTime)
				{
					SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false);
				}
				return (DateTimeOffset)Value;
			case JsonToken.String:
			{
				string s = (string)Value;
				return ReadDateTimeOffsetString(s);
			}
			default:
				throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
			}
		}

		internal DateTimeOffset? ReadDateTimeOffsetString(string? s)
		{
			if (StringUtils.IsNullOrEmpty(s))
			{
				SetToken(JsonToken.Null, null, updateIndex: false);
				return null;
			}
			if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
			{
				SetToken(JsonToken.Date, dt, updateIndex: false);
				return dt;
			}
			SetToken(JsonToken.String, s, updateIndex: false);
			throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s));
		}

		internal void ReaderReadAndAssert()
		{
			if (!Read())
			{
				throw CreateUnexpectedEndException();
			}
		}

		internal JsonReaderException CreateUnexpectedEndException()
		{
			return JsonReaderException.Create(this, "Unexpected end when reading JSON.");
		}

		internal void ReadIntoWrappedTypeObject()
		{
			ReaderReadAndAssert();
			if (Value != null && Value.ToString() == "$type")
			{
				ReaderReadAndAssert();
				if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal))
				{
					ReaderReadAndAssert();
					if (Value.ToString() == "$value")
					{
						return;
					}
				}
			}
			throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject));
		}

		public void Skip()
		{
			if (TokenType == JsonToken.PropertyName)
			{
				Read();
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (Read() && depth < Depth)
				{
				}
			}
		}

		protected void SetToken(JsonToken newToken)
		{
			SetToken(newToken, null, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value)
		{
			SetToken(newToken, value, updateIndex: true);
		}

		protected void SetToken(JsonToken newToken, object? value, bool updateIndex)
		{
			_tokenType = newToken;
			_value = value;
			switch (newToken)
			{
			case JsonToken.StartObject:
				_currentState = State.ObjectStart;
				Push(JsonContainerType.Object);
				break;
			case JsonToken.StartArray:
				_currentState = State.ArrayStart;
				Push(JsonContainerType.Array);
				break;
			case JsonToken.StartConstructor:
				_currentState = State.ConstructorStart;
				Push(JsonContainerType.Constructor);
				break;
			case JsonToken.EndObject:
				ValidateEnd(JsonToken.EndObject);
				break;
			case JsonToken.EndArray:
				ValidateEnd(JsonToken.EndArray);
				break;
			case JsonToken.EndConstructor:
				ValidateEnd(JsonToken.EndConstructor);
				break;
			case JsonToken.PropertyName:
				_currentState = State.Property;
				_currentPosition.PropertyName = (string)value;
				break;
			case JsonToken.Raw:
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				SetPostValueState(updateIndex);
				break;
			case JsonToken.Comment:
				break;
			}
		}

		internal void SetPostValueState(bool updateIndex)
		{
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
			if (updateIndex)
			{
				UpdateScopeWithFinishedValue();
			}
		}

		private void UpdateScopeWithFinishedValue()
		{
			if (_currentPosition.HasIndex)
			{
				_currentPosition.Position++;
			}
		}

		private void ValidateEnd(JsonToken endToken)
		{
			JsonContainerType jsonContainerType = Pop();
			if (GetTypeForCloseToken(endToken) != jsonContainerType)
			{
				throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType));
			}
			if (Peek() != 0 || SupportMultipleContent)
			{
				_currentState = State.PostValue;
			}
			else
			{
				SetFinished();
			}
		}

		protected void SetStateBasedOnCurrent()
		{
			JsonContainerType jsonContainerType = Peek();
			switch (jsonContainerType)
			{
			case JsonContainerType.Object:
				_currentState = State.Object;
				break;
			case JsonContainerType.Array:
				_currentState = State.Array;
				break;
			case JsonContainerType.Constructor:
				_currentState = State.Constructor;
				break;
			case JsonContainerType.None:
				SetFinished();
				break;
			default:
				throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType));
			}
		}

		private void SetFinished()
		{
			_currentState = ((!SupportMultipleContent) ? State.Finished : State.Start);
		}

		private JsonContainerType GetTypeForCloseToken(JsonToken token)
		{
			return token switch
			{
				JsonToken.EndObject => JsonContainerType.Object, 
				JsonToken.EndArray => JsonContainerType.Array, 
				JsonToken.EndConstructor => JsonContainerType.Constructor, 
				_ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), 
			};
		}

		void IDisposable.Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (_currentState != State.Closed && disposing)
			{
				Close();
			}
		}

		public virtual void Close()
		{
			_currentState = State.Closed;
			_tokenType = JsonToken.None;
			_value = null;
		}

		internal void ReadAndAssert()
		{
			if (!Read())
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter)
		{
			if (!ReadForType(contract, hasConverter))
			{
				throw JsonSerializationException.Create(this, "Unexpected end when reading JSON.");
			}
		}

		internal bool ReadForType(JsonContract? contract, bool hasConverter)
		{
			if (hasConverter)
			{
				return Read();
			}
			switch (contract?.InternalReadType ?? ReadType.Read)
			{
			case ReadType.Read:
				return ReadAndMoveToContent();
			case ReadType.ReadAsInt32:
				ReadAsInt32();
				break;
			case ReadType.ReadAsInt64:
			{
				bool result = ReadAndMoveToContent();
				if (TokenType == JsonToken.Undefined)
				{
					throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long)));
				}
				return result;
			}
			case ReadType.ReadAsDecimal:
				ReadAsDecimal();
				break;
			case ReadType.ReadAsDouble:
				ReadAsDouble();
				break;
			case ReadType.ReadAsBytes:
				ReadAsBytes();
				break;
			case ReadType.ReadAsBoolean:
				ReadAsBoolean();
				break;
			case ReadType.ReadAsString:
				ReadAsString();
				break;
			case ReadType.ReadAsDateTime:
				ReadAsDateTime();
				break;
			case ReadType.ReadAsDateTimeOffset:
				ReadAsDateTimeOffset();
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			return TokenType != JsonToken.None;
		}

		internal bool ReadAndMoveToContent()
		{
			if (Read())
			{
				return MoveToContent();
			}
			return false;
		}

		internal bool MoveToContent()
		{
			JsonToken tokenType = TokenType;
			while (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				if (!Read())
				{
					return false;
				}
				tokenType = TokenType;
			}
			return true;
		}

		private JsonToken GetContentToken()
		{
			JsonToken tokenType;
			do
			{
				if (!Read())
				{
					SetToken(JsonToken.None);
					return JsonToken.None;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.Comment);
			return tokenType;
		}
	}
	[Serializable]
	public class JsonReaderException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonReaderException()
		{
		}

		public JsonReaderException(string message)
			: base(message)
		{
		}

		public JsonReaderException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonReaderException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonReaderException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonReaderException(message, path, lineNumber, linePosition, ex);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	public sealed class JsonRequiredAttribute : Attribute
	{
	}
	[Serializable]
	public class JsonSerializationException : JsonException
	{
		public int LineNumber { get; }

		public int LinePosition { get; }

		public string? Path { get; }

		public JsonSerializationException()
		{
		}

		public JsonSerializationException(string message)
			: base(message)
		{
		}

		public JsonSerializationException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		public JsonSerializationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException)
			: base(message, innerException)
		{
			Path = path;
			LineNumber = lineNumber;
			LinePosition = linePosition;
		}

		internal static JsonSerializationException Create(JsonReader reader, string message)
		{
			return Create(reader, message, null);
		}

		internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex)
		{
			return Create(reader as IJsonLineInfo, reader.Path, message, ex);
		}

		internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			int lineNumber;
			int linePosition;
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				lineNumber = lineInfo.LineNumber;
				linePosition = lineInfo.LinePosition;
			}
			else
			{
				lineNumber = 0;
				linePosition = 0;
			}
			return new JsonSerializationException(message, path, lineNumber, linePosition, ex);
		}
	}
	public class JsonSerializer
	{
		internal TypeNameHandling _typeNameHandling;

		internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling;

		internal PreserveReferencesHandling _preserveReferencesHandling;

		internal ReferenceLoopHandling _referenceLoopHandling;

		internal MissingMemberHandling _missingMemberHandling;

		internal ObjectCreationHandling _objectCreationHandling;

		internal NullValueHandling _nullValueHandling;

		internal DefaultValueHandling _defaultValueHandling;

		internal ConstructorHandling _constructorHandling;

		internal MetadataPropertyHandling _metadataPropertyHandling;

		internal JsonConverterCollection? _converters;

		internal IContractResolver _contractResolver;

		internal ITraceWriter? _traceWriter;

		internal IEqualityComparer? _equalityComparer;

		internal ISerializationBinder _serializationBinder;

		internal StreamingContext _context;

		private IReferenceResolver? _referenceResolver;

		private Formatting? _formatting;

		private DateFormatHandling? _dateFormatHandling;

		private DateTimeZoneHandling? _dateTimeZoneHandling;

		private DateParseHandling? _dateParseHandling;

		private FloatFormatHandling? _floatFormatHandling;

		private FloatParseHandling? _floatParseHandling;

		private StringEscapeHandling? _stringEscapeHandling;

		private CultureInfo _culture;

		private int? _maxDepth;

		private bool _maxDepthSet;

		private bool? _checkAdditionalContent;

		private string? _dateFormatString;

		private bool _dateFormatStringSet;

		public virtual IReferenceResolver? ReferenceResolver
		{
			get
			{
				return GetReferenceResolver();
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Reference resolver cannot be null.");
				}
				_referenceResolver = value;
			}
		}

		[Obsolete("Binder is obsolete. Use SerializationBinder instead.")]
		public virtual SerializationBinder Binder
		{
			get
			{
				if (_serializationBinder is SerializationBinder result)
				{
					return result;
				}
				if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter)
				{
					return serializationBinderAdapter.SerializationBinder;
				}
				throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set.");
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value);
			}
		}

		public virtual ISerializationBinder SerializationBinder
		{
			get
			{
				return _serializationBinder;
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException("value", "Serialization binder cannot be null.");
				}
				_serializationBinder = value;
			}
		}

		public virtual ITraceWriter? TraceWriter
		{
			get
			{
				return _traceWriter;
			}
			set
			{
				_traceWriter = value;
			}
		}

		public virtual IEqualityComparer? EqualityComparer
		{
			get
			{
				return _equalityComparer;
			}
			set
			{
				_equalityComparer = value;
			}
		}

		public virtual TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling;
			}
			set
			{
				if (value < TypeNameHandling.None || value > TypeNameHandling.Auto)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameHandling = value;
			}
		}

		[Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
		public virtual FormatterAssemblyStyle TypeNameAssemblyFormat
		{
			get
			{
				return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value;
			}
		}

		public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling
		{
			get
			{
				return _typeNameAssemblyFormatHandling;
			}
			set
			{
				if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_typeNameAssemblyFormatHandling = value;
			}
		}

		public virtual PreserveReferencesHandling PreserveReferencesHandling
		{
			get
			{
				return _preserveReferencesHandling;
			}
			set
			{
				if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_preserveReferencesHandling = value;
			}
		}

		public virtual ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling;
			}
			set
			{
				if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_referenceLoopHandling = value;
			}
		}

		public virtual MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling;
			}
			set
			{
				if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_missingMemberHandling = value;
			}
		}

		public virtual NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling;
			}
			set
			{
				if (value < NullValueHandling.Include || value > NullValueHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_nullValueHandling = value;
			}
		}

		public virtual DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling;
			}
			set
			{
				if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_defaultValueHandling = value;
			}
		}

		public virtual ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling;
			}
			set
			{
				if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_objectCreationHandling = value;
			}
		}

		public virtual ConstructorHandling ConstructorHandling
		{
			get
			{
				return _constructorHandling;
			}
			set
			{
				if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_constructorHandling = value;
			}
		}

		public virtual MetadataPropertyHandling MetadataPropertyHandling
		{
			get
			{
				return _metadataPropertyHandling;
			}
			set
			{
				if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_metadataPropertyHandling = value;
			}
		}

		public virtual JsonConverterCollection Converters
		{
			get
			{
				if (_converters == null)
				{
					_converters = new JsonConverterCollection();
				}
				return _converters;
			}
		}

		public virtual IContractResolver ContractResolver
		{
			get
			{
				return _contractResolver;
			}
			set
			{
				_contractResolver = value ?? DefaultContractResolver.Instance;
			}
		}

		public virtual StreamingContext Context
		{
			get
			{
				return _context;
			}
			set
			{
				_context = value;
			}
		}

		public virtual Formatting Formatting
		{
			get
			{
				return _formatting.GetValueOrDefault();
			}
			set
			{
				_formatting = value;
			}
		}

		public virtual DateFormatHandling DateFormatHandling
		{
			get
			{
				return _dateFormatHandling.GetValueOrDefault();
			}
			set
			{
				_dateFormatHandling = value;
			}
		}

		public virtual DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling ?? DateTimeZoneHandling.RoundtripKind;
			}
			set
			{
				_dateTimeZoneHandling = value;
			}
		}

		public virtual DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling ?? DateParseHandling.DateTime;
			}
			set
			{
				_dateParseHandling = value;
			}
		}

		public virtual FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling.GetValueOrDefault();
			}
			set
			{
				_floatParseHandling = value;
			}
		}

		public virtual FloatFormatHandling FloatFormatHandling
		{
			get
			{
				return _floatFormatHandling.GetValueOrDefault();
			}
			set
			{
				_floatFormatHandling = value;
			}
		}

		public virtual StringEscapeHandling StringEscapeHandling
		{
			get
			{
				return _stringEscapeHandling.GetValueOrDefault();
			}
			set
			{
				_stringEscapeHandling = value;
			}
		}

		public virtual string DateFormatString
		{
			get
			{
				return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
			}
			set
			{
				_dateFormatString = value;
				_dateFormatStringSet = true;
			}
		}

		public virtual CultureInfo Culture
		{
			get
			{
				return _culture ?? JsonSerializerSettings.DefaultCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
				_maxDepthSet = true;
			}
		}

		public virtual bool CheckAdditionalContent
		{
			get
			{
				return _checkAdditionalContent.GetValueOrDefault();
			}
			set
			{
				_checkAdditionalContent = value;
			}
		}

		public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error;

		internal bool IsCheckAdditionalContentSet()
		{
			return _checkAdditionalContent.HasValue;
		}

		public JsonSerializer()
		{
			_referenceLoopHandling = ReferenceLoopHandling.Error;
			_missingMemberHandling = MissingMemberHandling.Ignore;
			_nullValueHandling = NullValueHandling.Include;
			_defaultValueHandling = DefaultValueHandling.Include;
			_objectCreationHandling = ObjectCreationHandling.Auto;
			_preserveReferencesHandling = PreserveReferencesHandling.None;
			_constructorHandling = ConstructorHandling.Default;
			_typeNameHandling = TypeNameHandling.None;
			_metadataPropertyHandling = MetadataPropertyHandling.Default;
			_context = JsonSerializerSettings.DefaultContext;
			_serializationBinder = DefaultSerializationBinder.Instance;
			_culture = JsonSerializerSettings.DefaultCulture;
			_contractResolver = DefaultContractResolver.Instance;
		}

		public static JsonSerializer Create()
		{
			return new JsonSerializer();
		}

		public static JsonSerializer Create(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = Create();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		public static JsonSerializer CreateDefault()
		{
			return Create(JsonConvert.DefaultSettings?.Invoke());
		}

		public static JsonSerializer CreateDefault(JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = CreateDefault();
			if (settings != null)
			{
				ApplySerializerSettings(jsonSerializer, settings);
			}
			return jsonSerializer;
		}

		private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings)
		{
			if (!CollectionUtils.IsNullOrEmpty(settings.Converters))
			{
				for (int i = 0; i < settings.Converters.Count; i++)
				{
					serializer.Converters.Insert(i, settings.Converters[i]);
				}
			}
			if (settings._typeNameHandling.HasValue)
			{
				serializer.TypeNameHandling = settings.TypeNameHandling;
			}
			if (settings._metadataPropertyHandling.HasValue)
			{
				serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling;
			}
			if (settings._typeNameAssemblyFormatHandling.HasValue)
			{
				serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling;
			}
			if (settings._preserveReferencesHandling.HasValue)
			{
				serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling;
			}
			if (settings._referenceLoopHandling.HasValue)
			{
				serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling;
			}
			if (settings._missingMemberHandling.HasValue)
			{
				serializer.MissingMemberHandling = settings.MissingMemberHandling;
			}
			if (settings._objectCreationHandling.HasValue)
			{
				serializer.ObjectCreationHandling = settings.ObjectCreationHandling;
			}
			if (settings._nullValueHandling.HasValue)
			{
				serializer.NullValueHandling = settings.NullValueHandling;
			}
			if (settings._defaultValueHandling.HasValue)
			{
				serializer.DefaultValueHandling = settings.DefaultValueHandling;
			}
			if (settings._constructorHandling.HasValue)
			{
				serializer.ConstructorHandling = settings.ConstructorHandling;
			}
			if (settings._context.HasValue)
			{
				serializer.Context = settings.Context;
			}
			if (settings._checkAdditionalContent.HasValue)
			{
				serializer._checkAdditionalContent = settings._checkAdditionalContent;
			}
			if (settings.Error != null)
			{
				serializer.Error += settings.Error;
			}
			if (settings.ContractResolver != null)
			{
				serializer.ContractResolver = settings.ContractResolver;
			}
			if (settings.ReferenceResolverProvider != null)
			{
				serializer.ReferenceResolver = settings.ReferenceResolverProvider();
			}
			if (settings.TraceWriter != null)
			{
				serializer.TraceWriter = settings.TraceWriter;
			}
			if (settings.EqualityComparer != null)
			{
				serializer.EqualityComparer = settings.EqualityComparer;
			}
			if (settings.SerializationBinder != null)
			{
				serializer.SerializationBinder = settings.SerializationBinder;
			}
			if (settings._formatting.HasValue)
			{
				serializer._formatting = settings._formatting;
			}
			if (settings._dateFormatHandling.HasValue)
			{
				serializer._dateFormatHandling = settings._dateFormatHandling;
			}
			if (settings._dateTimeZoneHandling.HasValue)
			{
				serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling;
			}
			if (settings._dateParseHandling.HasValue)
			{
				serializer._dateParseHandling = settings._dateParseHandling;
			}
			if (settings._dateFormatStringSet)
			{
				serializer._dateFormatString = settings._dateFormatString;
				serializer._dateFormatStringSet = settings._dateFormatStringSet;
			}
			if (settings._floatFormatHandling.HasValue)
			{
				serializer._floatFormatHandling = settings._floatFormatHandling;
			}
			if (settings._floatParseHandling.HasValue)
			{
				serializer._floatParseHandling = settings._floatParseHandling;
			}
			if (settings._stringEscapeHandling.HasValue)
			{
				serializer._stringEscapeHandling = settings._stringEscapeHandling;
			}
			if (settings._culture != null)
			{
				serializer._culture = settings._culture;
			}
			if (settings._maxDepthSet)
			{
				serializer._maxDepth = settings._maxDepth;
				serializer._maxDepthSet = settings._maxDepthSet;
			}
		}

		[DebuggerStepThrough]
		public void Populate(TextReader reader, object target)
		{
			Populate(new JsonTextReader(reader), target);
		}

		[DebuggerStepThrough]
		public void Populate(JsonReader reader, object target)
		{
			PopulateInternal(reader, target);
		}

		internal virtual void PopulateInternal(JsonReader reader, object target)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			ValidationUtils.ArgumentNotNull(target, "target");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			new JsonSerializerInternalReader(this).Populate(traceJsonReader ?? reader, target);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader)
		{
			return Deserialize(reader, null);
		}

		[DebuggerStepThrough]
		public object? Deserialize(TextReader reader, Type objectType)
		{
			return Deserialize(new JsonTextReader(reader), objectType);
		}

		[DebuggerStepThrough]
		public T? Deserialize<T>(JsonReader reader)
		{
			return (T)Deserialize(reader, typeof(T));
		}

		[DebuggerStepThrough]
		public object? Deserialize(JsonReader reader, Type? objectType)
		{
			return DeserializeInternal(reader, objectType);
		}

		internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString);
			TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null);
			object? result = new JsonSerializerInternalReader(this).Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent);
			if (traceJsonReader != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null);
			}
			ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString);
			return result;
		}

		internal void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString)
		{
			if (_culture != null && !_culture.Equals(reader.Culture))
			{
				previousCulture = reader.Culture;
				reader.Culture = _culture;
			}
			else
			{
				previousCulture = null;
			}
			if (_dateTimeZoneHandling.HasValue && reader.DateTimeZoneHandling != _dateTimeZoneHandling)
			{
				previousDateTimeZoneHandling = reader.DateTimeZoneHandling;
				reader.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault();
			}
			else
			{
				previousDateTimeZoneHandling = null;
			}
			if (_dateParseHandling.HasValue && reader.DateParseHandling != _dateParseHandling)
			{
				previousDateParseHandling = reader.DateParseHandling;
				reader.DateParseHandling = _dateParseHandling.GetValueOrDefault();
			}
			else
			{
				previousDateParseHandling = null;
			}
			if (_floatParseHandling.HasValue && reader.FloatParseHandling != _floatParseHandling)
			{
				previousFloatParseHandling = reader.FloatParseHandling;
				reader.FloatParseHandling = _floatParseHandling.GetValueOrDefault();
			}
			else
			{
				previousFloatParseHandling = null;
			}
			if (_maxDepthSet && reader.MaxDepth != _maxDepth)
			{
				previousMaxDepth = reader.MaxDepth;
				reader.MaxDepth = _maxDepth;
			}
			else
			{
				previousMaxDepth = null;
			}
			if (_dateFormatStringSet && reader.DateFormatString != _dateFormatString)
			{
				previousDateFormatString = reader.DateFormatString;
				reader.DateFormatString = _dateFormatString;
			}
			else
			{
				previousDateFormatString = null;
			}
			if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable == null && _contractResolver is DefaultContractResolver defaultContractResolver)
			{
				jsonTextReader.PropertyNameTable = defaultContractResolver.GetNameTable();
			}
		}

		private void ResetReader(JsonReader reader, CultureInfo? previousCulture, DateTimeZoneHandling? previousDateTimeZoneHandling, DateParseHandling? previousDateParseHandling, FloatParseHandling? previousFloatParseHandling, int? previousMaxDepth, string? previousDateFormatString)
		{
			if (previousCulture != null)
			{
				reader.Culture = previousCulture;
			}
			if (previousDateTimeZoneHandling.HasValue)
			{
				reader.DateTimeZoneHandling = previousDateTimeZoneHandling.GetValueOrDefault();
			}
			if (previousDateParseHandling.HasValue)
			{
				reader.DateParseHandling = previousDateParseHandling.GetValueOrDefault();
			}
			if (previousFloatParseHandling.HasValue)
			{
				reader.FloatParseHandling = previousFloatParseHandling.GetValueOrDefault();
			}
			if (_maxDepthSet)
			{
				reader.MaxDepth = previousMaxDepth;
			}
			if (_dateFormatStringSet)
			{
				reader.DateFormatString = previousDateFormatString;
			}
			if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable != null && _contractResolver is DefaultContractResolver defaultContractResolver && jsonTextReader.PropertyNameTable == defaultContractResolver.GetNameTable())
			{
				jsonTextReader.PropertyNameTable = null;
			}
		}

		public void Serialize(TextWriter textWriter, object? value)
		{
			Serialize(new JsonTextWriter(textWriter), value);
		}

		public void Serialize(JsonWriter jsonWriter, object? value, Type? objectType)
		{
			SerializeInternal(jsonWriter, value, objectType);
		}

		public void Serialize(TextWriter textWriter, object? value, Type objectType)
		{
			Serialize(new JsonTextWriter(textWriter), value, objectType);
		}

		public void Serialize(JsonWriter jsonWriter, object? value)
		{
			SerializeInternal(jsonWriter, value, null);
		}

		private TraceJsonReader CreateTraceJsonReader(JsonReader reader)
		{
			TraceJsonReader traceJsonReader = new TraceJsonReader(reader);
			if (reader.TokenType != 0)
			{
				traceJsonReader.WriteCurrentToken();
			}
			return traceJsonReader;
		}

		internal virtual void SerializeInternal(JsonWriter jsonWriter, object? value, Type? objectType)
		{
			ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter");
			Formatting? formatting = null;
			if (_formatting.HasValue && jsonWriter.Formatting != _formatting)
			{
				formatting = jsonWriter.Formatting;
				jsonWriter.Formatting = _formatting.GetValueOrDefault();
			}
			DateFormatHandling? dateFormatHandling = null;
			if (_dateFormatHandling.HasValue && jsonWriter.DateFormatHandling != _dateFormatHandling)
			{
				dateFormatHandling = jsonWriter.DateFormatHandling;
				jsonWriter.DateFormatHandling = _dateFormatHandling.GetValueOrDefault();
			}
			DateTimeZoneHandling? dateTimeZoneHandling = null;
			if (_dateTimeZoneHandling.HasValue && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling)
			{
				dateTimeZoneHandling = jsonWriter.DateTimeZoneHandling;
				jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault();
			}
			FloatFormatHandling? floatFormatHandling = null;
			if (_floatFormatHandling.HasValue && jsonWriter.FloatFormatHandling != _floatFormatHandling)
			{
				floatFormatHandling = jsonWriter.FloatFormatHandling;
				jsonWriter.FloatFormatHandling = _floatFormatHandling.GetValueOrDefault();
			}
			StringEscapeHandling? stringEscapeHandling = null;
			if (_stringEscapeHandling.HasValue && jsonWriter.StringEscapeHandling != _stringEscapeHandling)
			{
				stringEscapeHandling = jsonWriter.StringEscapeHandling;
				jsonWriter.StringEscapeHandling = _stringEscapeHandling.GetValueOrDefault();
			}
			CultureInfo cultureInfo = null;
			if (_culture != null && !_culture.Equals(jsonWriter.Culture))
			{
				cultureInfo = jsonWriter.Culture;
				jsonWriter.Culture = _culture;
			}
			string dateFormatString = null;
			if (_dateFormatStringSet && jsonWriter.DateFormatString != _dateFormatString)
			{
				dateFormatString = jsonWriter.DateFormatString;
				jsonWriter.DateFormatString = _dateFormatString;
			}
			TraceJsonWriter traceJsonWriter = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? new TraceJsonWriter(jsonWriter) : null);
			new JsonSerializerInternalWriter(this).Serialize(traceJsonWriter ?? jsonWriter, value, objectType);
			if (traceJsonWriter != null)
			{
				TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter.GetSerializedJsonMessage(), null);
			}
			if (formatting.HasValue)
			{
				jsonWriter.Formatting = formatting.GetValueOrDefault();
			}
			if (dateFormatHandling.HasValue)
			{
				jsonWriter.DateFormatHandling = dateFormatHandling.GetValueOrDefault();
			}
			if (dateTimeZoneHandling.HasValue)
			{
				jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.GetValueOrDefault();
			}
			if (floatFormatHandling.HasValue)
			{
				jsonWriter.FloatFormatHandling = floatFormatHandling.GetValueOrDefault();
			}
			if (stringEscapeHandling.HasValue)
			{
				jsonWriter.StringEscapeHandling = stringEscapeHandling.GetValueOrDefault();
			}
			if (_dateFormatStringSet)
			{
				jsonWriter.DateFormatString = dateFormatString;
			}
			if (cultureInfo != null)
			{
				jsonWriter.Culture = cultureInfo;
			}
		}

		internal IReferenceResolver GetReferenceResolver()
		{
			if (_referenceResolver == null)
			{
				_referenceResolver = new DefaultReferenceResolver();
			}
			return _referenceResolver;
		}

		internal JsonConverter? GetMatchingConverter(Type type)
		{
			return GetMatchingConverter(_converters, type);
		}

		internal static JsonConverter? GetMatchingConverter(IList<JsonConverter>? converters, Type objectType)
		{
			if (converters != null)
			{
				for (int i = 0; i < converters.Count; i++)
				{
					JsonConverter jsonConverter = converters[i];
					if (jsonConverter.CanConvert(objectType))
					{
						return jsonConverter;
					}
				}
			}
			return null;
		}

		internal void OnError(Newtonsoft.Json.Serialization.ErrorEventArgs e)
		{
			this.Error?.Invoke(this, e);
		}
	}
	public class JsonSerializerSettings
	{
		internal const ReferenceLoopHandling DefaultReferenceLoopHandling = ReferenceLoopHandling.Error;

		internal const MissingMemberHandling DefaultMissingMemberHandling = MissingMemberHandling.Ignore;

		internal const NullValueHandling DefaultNullValueHandling = NullValueHandling.Include;

		internal const DefaultValueHandling DefaultDefaultValueHandling = DefaultValueHandling.Include;

		internal const ObjectCreationHandling DefaultObjectCreationHandling = ObjectCreationHandling.Auto;

		internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None;

		internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default;

		internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None;

		internal const MetadataPropertyHandling DefaultMetadataPropertyHandling = MetadataPropertyHandling.Default;

		internal static readonly StreamingContext DefaultContext;

		internal const Formatting DefaultFormatting = Formatting.None;

		internal const DateFormatHandling DefaultDateFormatHandling = DateFormatHandling.IsoDateFormat;

		internal const DateTimeZoneHandling DefaultDateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;

		internal const DateParseHandling DefaultDateParseHandling = DateParseHandling.DateTime;

		internal const FloatParseHandling DefaultFloatParseHandling = FloatParseHandling.Double;

		internal const FloatFormatHandling DefaultFloatFormatHandling = FloatFormatHandling.String;

		internal const StringEscapeHandling DefaultStringEscapeHandling = StringEscapeHandling.Default;

		internal const TypeNameAssemblyFormatHandling DefaultTypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple;

		internal static readonly CultureInfo DefaultCulture;

		internal const bool DefaultCheckAdditionalContent = false;

		internal const string DefaultDateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";

		internal const int DefaultMaxDepth = 64;

		internal Formatting? _formatting;

		internal DateFormatHandling? _dateFormatHandling;

		internal DateTimeZoneHandling? _dateTimeZoneHandling;

		internal DateParseHandling? _dateParseHandling;

		internal FloatFormatHandling? _floatFormatHandling;

		internal FloatParseHandling? _floatParseHandling;

		internal StringEscapeHandling? _stringEscapeHandling;

		internal CultureInfo? _culture;

		internal bool? _checkAdditionalContent;

		internal int? _maxDepth;

		internal bool _maxDepthSet;

		internal string? _dateFormatString;

		internal bool _dateFormatStringSet;

		internal TypeNameAssemblyFormatHandling? _typeNameAssemblyFormatHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal PreserveReferencesHandling? _preserveReferencesHandling;

		internal NullValueHandling? _nullValueHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal MissingMemberHandling? _missingMemberHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal StreamingContext? _context;

		internal ConstructorHandling? _constructorHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal MetadataPropertyHandling? _metadataPropertyHandling;

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public IList<JsonConverter> Converters { get; set; }

		public PreserveReferencesHandling PreserveReferencesHandling
		{
			get
			{
				return _preserveReferencesHandling.GetValueOrDef

FuriousButtplug/System.Data.dll

Decompiled 6 months ago
#define TRACE
#define DEBUG
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Data.ProviderBase;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Dynamic;
using System.EnterpriseServices;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime.Caching;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Services;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.Serialization.Advanced;
using System.Xml.XPath;
using <CppImplementationDetails>;
using <CrtImplementationDetails>;
using Microsoft.SqlServer.Server;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;

[assembly: AssemblyDescription("System.Data.dll")]
[assembly: SecurityRules(SecurityRuleSet.Level1)]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyTitle("System.Data.dll")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
[assembly: AssemblyDefaultAlias("System.Data.dll")]
[assembly: AssemblySignatureKey("002400000c800000140100000602000000240000525341310008000001000100613399aff18ef1a2c2514a273a42d9042b72321f1757102df9ebada69923e2738406c21e5b801552ab8d200a65a235e001ac9adc25f2d811eb09496a4c6a59d4619589c69f5baf0c4179a47311d92555cd006acc8b5959f2bd6e10e360c34537a1d266da8085856583c85d81da7f3ec01ed9564c58d93d713cd0172c8e23a10f0239b80c96b07736f5d8b022542a4e74251a5f432824318b3539a5a087f8e53d2f135f9ca47f3bb2e10aff0af0849504fb7cea3ff192dc8de0edad64c68efde34c56d302ad55fd6e80f302d5efcdeae953658d3452561b5f36c542efdbdd9f888538d374cef106acf7d93a4445c3c73cd911f0571aaf3d54da12b11ddec375b3", "a5a866e1ee186f807668209f3b11236ace5e21f117803a3143abb126dd035d7d2f876b6938aaf2ee3414d5420d753621400db44a49c486ce134300a2106adb6bdb433590fef8ad5c43cba82290dc49530effd86523d9483c00f458af46890036b0e2c61d077d7fbac467a506eba29e467a87198b053c749aa2a4d2840c784e6d")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: InternalsVisibleTo("System.Data.DataSetExtensions, PublicKey=00000000000000000400000000000000")]
[assembly: InternalsVisibleTo("SqlAccess, PublicKey=0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: ComCompatibleVersion(1, 0, 3300, 0)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyKeyFile("f:\\dd\\tools\\devdiv\\EcmaPublicKey.snk")]
[assembly: AssemblyDelaySign(true)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SatelliteContractVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.8.9214.0")]
[assembly: AssemblyFileVersion("4.8.9214.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.0.0")]
[module: CLSCompliant(true)]
[module: UnverifiableCode]
[module: BidIdentity("System.Data.1")]
[module: BidMetaText(":FormatControl: InstanceID='' ")]
[module: BidMetaText("<CountHint> Trace=1200; Scope=250;")]
[module: BidMetaText("<Alias>  ds = System.Data;comm = System.Data.Common;odbc = System.Data.Odbc;oledb= System.Data.OleDb;prov = System.Data.ProviderBase;sc   = System.Data.Sql;sql  = System.Data.SqlClient;cqt  = System.Data.Common.CommandTrees;cqti = System.Data.Common.CommandTrees.Internal;esql = System.Data.Common.EntitySql;ec   = System.Data.EntityClient;dobj = System.Data.Objects;md   = System.Data.Metadata;ra   = System.Data.Query.ResultAssembly;pc   = System.Data.Query.PlanCompiler;iqt  = System.Data.Query.InternalTrees;mp   = System.Data.Mapping;upd  = System.Data.Mapping.Update;vgen = System.Data.Mapping.ViewGeneration;")]
[module: BidMetaText("<ApiGroup|ProviderBase|CPOOL> 0x00001000: Connection Pooling")]
[module: BidMetaText("<ApiGroup|SqlClient|DEP> 0x00002000: SqlDependency Notifications")]
[module: BidMetaText("<ApiGroup|System.Data.Query|RA> 0x00004000: Result Assembly")]
[module: BidMetaText("<ApiGroup|System.Data.Query.PlanCompiler|PC> 0x00008000: Plan Compilation")]
[module: BidMetaText("<ApiGroup|SqlClient|Correlation> 0x00040000: Correlation")]
internal class <Module>
{
	internal static $ArrayType$$$BY08$$CBG ??_C@_1BC@LEJJAHNB@?$AAs?$AAe?$AAs?$AAs?$AAi?$AAo?$AAn?$AA?3@/* Not supported: data(73 00 65 00 73 00 73 00 69 00 6F 00 6E 00 3A 00 00 00) */;

	internal static __s_GUID _GUID_cb2f6723_ab3a_11d2_9c40_00c04fa30a3e/* Not supported: data(23 67 2F CB 3A AB D2 11 9C 40 00 C0 4F A3 0A 3E) */;

	internal static __s_GUID _GUID_cb2f6722_ab3a_11d2_9c40_00c04fa30a3e/* Not supported: data(22 67 2F CB 3A AB D2 11 9C 40 00 C0 4F A3 0A 3E) */;

	internal unsafe static void* ?data@SqlDependencyProcessDispatcherStorage@@0PEAXEA/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal static int ?size@SqlDependencyProcessDispatcherStorage@@0HA/* Not supported: data(00 00 00 00) */;

	internal static volatile int ?lock@SqlDependencyProcessDispatcherStorage@@0JC/* Not supported: data(00 00 00 00) */;

	public unsafe static delegate*<void*, ulong, void*, ulong, int> __m2mep@?memcpy_s@?A0x9ea9c69e@@$$J0YAHQEAX_KQEBX1@Z/* Not supported: data(01 00 00 06 00 00 00 00) */;

	private unsafe static int** __unep@?SNIWriteAsyncWrapper@@$$FYAKPEAUSNI_ConnWrapper@@PEAVSNI_Packet@@@Z/* Not supported: data(D0 2C 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIReadAsyncWrapper@@$$FYAKPEAUSNI_ConnWrapper@@PEAPEAVSNI_Packet@@@Z/* Not supported: data(B0 2D 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIPacketGetDataWrapper@@$$FYAKPEAVSNI_Packet@@PEAEKPEAK@Z/* Not supported: data(50 32 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIServerEnumClose@@$$J0YAXPEAX@Z/* Not supported: data(30 3D 01 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIClose@@$$J0YAKPEAVSNI_Conn@@@Z/* Not supported: data(5C A8 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNITerminate@@$$J0YAKXZ/* Not supported: data(C0 DA 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNICheckConnection@@$$J0YAKPEAVSNI_Conn@@@Z/* Not supported: data(B4 A7 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIPacketAllocate@@$$J0YAPEAVSNI_Packet@@PEAVSNI_Conn@@W4SNI_Packet_IOType@@@Z/* Not supported: data(10 C6 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIPacketRelease@@$$J0YAXPEAVSNI_Packet@@@Z/* Not supported: data(4C C9 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIPacketReset@@$$J0YAXPEAVSNI_Conn@@W4SNI_Packet_IOType@@PEAVSNI_Packet@@W4ConsumerNum@@@Z/* Not supported: data(C4 CA 00 80 01 00 00 00) */;

	private unsafe static int** __unep@?SNIPacketSetData@@$$J0YAXPEAVSNI_Packet@@PEBEK@Z/* Not supported: data(0C CB 00 80 01 00 00 00) */;

	[FixedAddressValueType]
	internal static int ?Uninitialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA;

	internal unsafe static delegate*<void> ?A0x201c0761.?Uninitialized$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(17 00 00 06 00 00 00 00) */;

	[FixedAddressValueType]
	internal static Progress ?InitializedNative@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A;

	internal unsafe static delegate*<void> ?A0x201c0761.?InitializedNative$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(1A 00 00 06 00 00 00 00) */;

	internal static __s_GUID _GUID_90f1a06c_7712_4762_86b5_7a5eba6bdb02/* Not supported: data(6C A0 F1 90 12 77 62 47 86 B5 7A 5E BA 6B DB 02) */;

	internal static __s_GUID _GUID_90f1a06e_7712_4762_86b5_7a5eba6bdb02/* Not supported: data(6E A0 F1 90 12 77 62 47 86 B5 7A 5E BA 6B DB 02) */;

	[FixedAddressValueType]
	internal static Progress ?InitializedPerAppDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A;

	internal static bool ?Entered@DefaultDomain@<CrtImplementationDetails>@@2_NA/*Field data (rva=0x34f9a4) could not be foundin any section!*/;

	internal static TriBool ?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A/* Not supported: data() */;

	internal static bool ?InitializedPerProcess@DefaultDomain@<CrtImplementationDetails>@@2_NA/*Field data (rva=0x34f9a7) could not be foundin any section!*/;

	internal static int ?Count@AllDomains@<CrtImplementationDetails>@@2HA/*Field data (rva=0x34f9a0) could not be foundin any section!*/;

	[FixedAddressValueType]
	internal static int ?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA;

	internal static bool ?InitializedNativeFromCCTOR@DefaultDomain@<CrtImplementationDetails>@@2_NA/*Field data (rva=0x34f9a6) could not be foundin any section!*/;

	[FixedAddressValueType]
	internal static bool ?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA;

	[FixedAddressValueType]
	internal static Progress ?InitializedVtables@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A;

	internal static bool ?InitializedNative@DefaultDomain@<CrtImplementationDetails>@@2_NA/*Field data (rva=0x34f9a5) could not be foundin any section!*/;

	[FixedAddressValueType]
	internal static Progress ?InitializedPerProcess@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A;

	internal static TriBool ?hasPerProcess@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A/* Not supported: data() */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xc_mp_z/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xi_vt_z/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal unsafe static delegate*<void> ?A0x201c0761.?InitializedPerProcess$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(1B 00 00 06 00 00 00 00) */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xc_ma_a/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xc_ma_z/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal unsafe static delegate*<void> ?A0x201c0761.?InitializedPerAppDomain$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(1C 00 00 06 00 00 00 00) */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xi_vt_a/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal unsafe static delegate*<void> ?A0x201c0761.?Initialized$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(16 00 00 06 00 00 00 00) */;

	internal static $ArrayType$$$BY00Q6MPEBXXZ __xc_mp_a/* Not supported: data(00 00 00 00 00 00 00 00) */;

	internal unsafe static delegate*<void> ?A0x201c0761.?InitializedVtables$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(19 00 00 06 00 00 00 00) */;

	internal unsafe static delegate*<void> ?A0x201c0761.?IsDefaultDomain$initializer$@CurrentDomain@<CrtImplementationDetails>@@$$Q2P6MXXZEA/* Not supported: data(18 00 00 06 00 00 00 00) */;

	public unsafe static delegate*<void*, int> __m2mep@?DoNothing@DefaultDomain@<CrtImplementationDetails>@@$$FCAJPEAX@Z/* Not supported: data(10 00 00 06 00 00 00 00) */;

	public unsafe static delegate*<void*, int> __m2mep@?_UninitializeDefaultDomain@LanguageSupport@<CrtImplementationDetails>@@$$FCAJPEAX@Z/* Not supported: data(25 00 00 06 00 00 00 00) */;

	public unsafe static int** __unep@?DoNothing@DefaultDomain@<CrtImplementationDetails>@@$$FCAJPEAX@Z/* Not supported: data(10 B0 14 80 01 00 00 00) */;

	public unsafe static int** __unep@?_UninitializeDefaultDomain@LanguageSupport@<CrtImplementationDetails>@@$$FCAJPEAX@Z/* Not supported: data(20 B0 14 80 01 00 00 00) */;

	internal unsafe static delegate*<void>* ?A0x9a16e6c2.__onexitbegin_m/*Field data (rva=0x34fb10) could not be foundin any section!*/;

	internal static ulong ?A0x9a16e6c2.__exit_list_size/*Field data (rva=0x34fb08) could not be foundin any section!*/;

	[FixedAddressValueType]
	internal unsafe static delegate*<void>* __onexitend_app_domain;

	[FixedAddressValueType]
	internal unsafe static void* ?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA;

	[FixedAddressValueType]
	internal static int ?_ref_count@AtExitLock@<CrtImplementationDetails>@@$$Q0HA;

	internal unsafe static delegate*<void>* ?A0x9a16e6c2.__onexitend_m/*Field data (rva=0x34fb18) could not be foundin any section!*/;

	[FixedAddressValueType]
	internal static ulong __exit_list_size_app_domain;

	[FixedAddressValueType]
	internal unsafe static delegate*<void>* __onexitbegin_app_domain;

	internal static uint SNI_MAX_COMPOSED_SPN/* Not supported: data(0A 05 00 00) */;

	internal static _GUID IID_ITransactionLocal/* Not supported: data(5F 3A 73 0C 1C 2A CE 11 AD E5 00 AA 00 44 77 3D) */;

	internal static _GUID IID_IChapteredRowset/* Not supported: data(93 3A 73 0C 1C 2A CE 11 AD E5 00 AA 00 44 77 3D) */;

	internal static $ArrayType$$$BY0A@P6AHXZ __xi_z/* Not supported: data(00) */;

	internal static __scrt_native_startup_state __scrt_current_native_startup_state/* Not supported: data() */;

	internal unsafe static void* __scrt_native_startup_lock/*Field data (rva=0x34f948) could not be foundin any section!*/;

	internal static $ArrayType$$$BY0A@P6AXXZ __xc_a/* Not supported: data(00) */;

	internal static $ArrayType$$$BY0A@P6AHXZ __xi_a/* Not supported: data(00) */;

	internal static uint __scrt_native_dllmain_reason/* Not supported: data(FF FF FF FF) */;

	internal static $ArrayType$$$BY0A@P6AXXZ __xc_z/* Not supported: data(00) */;

	internal unsafe static int ?A0x9ea9c69e.memcpy_s(void* _Destination, ulong _DestinationSize, void* _Source, ulong _SourceSize)
	{
		//IL_0031: Expected I4, but got I8
		//IL_0027: Expected I4, but got I8
		if (_SourceSize == 0L)
		{
			return 0;
		}
		if (_Destination == null)
		{
			*_errno() = 22;
			_invalid_parameter_noinfo();
			return 22;
		}
		if (_Source != null && _DestinationSize >= _SourceSize)
		{
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(_Destination, _Source, _SourceSize);
			return 0;
		}
		// IL initblk instruction
		System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(_Destination, 0, _DestinationSize);
		if (_Source == null)
		{
			*_errno() = 22;
			_invalid_parameter_noinfo();
			return 22;
		}
		if (_DestinationSize < _SourceSize)
		{
			*_errno() = 34;
			_invalid_parameter_noinfo();
			return 34;
		}
		return 22;
	}

	internal unsafe static Sni_Consumer_Info* Sni_Consumer_Info.{ctor}(Sni_Consumer_Info* P_0)
	{
		*(int*)P_0 = 0;
		*(long*)((ulong)(nint)P_0 + 8uL) = 0L;
		*(long*)((ulong)(nint)P_0 + 16uL) = 0L;
		*(long*)((ulong)(nint)P_0 + 24uL) = 0L;
		*(long*)((ulong)(nint)P_0 + 32uL) = 0L;
		*(long*)((ulong)(nint)P_0 + 40uL) = 0L;
		*(int*)((ulong)(nint)P_0 + 48uL) = 0;
		*(long*)((ulong)(nint)P_0 + 56uL) = 0L;
		*(long*)((ulong)(nint)P_0 + 64uL) = 0L;
		return P_0;
	}

	internal unsafe static SNI_CLIENT_CONSUMER_INFO* SNI_CLIENT_CONSUMER_INFO.{ctor}(SNI_CLIENT_CONSUMER_INFO* P_0)
	{
		Sni_Consumer_Info.{ctor}((Sni_Consumer_Info*)P_0);
		*(long*)((ulong)(nint)P_0 + 72uL) = 0L;
		*(int*)((ulong)(nint)P_0 + 80uL) = 0;
		*(long*)((ulong)(nint)P_0 + 88uL) = 0L;
		*(int*)((ulong)(nint)P_0 + 96uL) = 0;
		*(long*)((ulong)(nint)P_0 + 104uL) = 0L;
		*(int*)((ulong)(nint)P_0 + 112uL) = 0;
		*(int*)((ulong)(nint)P_0 + 116uL) = 0;
		*(int*)((ulong)(nint)P_0 + 120uL) = 0;
		*(int*)((ulong)(nint)P_0 + 124uL) = -1;
		*(int*)((ulong)(nint)P_0 + 128uL) = 0;
		*(sbyte*)((ulong)(nint)P_0 + 132uL) = 0;
		*(int*)((ulong)(nint)P_0 + 136uL) = -1;
		*(sbyte*)((ulong)(nint)P_0 + 140uL) = 0;
		return P_0;
	}

	internal unsafe static Guid ?A0x9ea9c69e.FromGUID(_GUID* guid)
	{
		return new Guid(*(uint*)guid, *(ushort*)((ulong)(nint)guid + 4uL), *(ushort*)((ulong)(nint)guid + 6uL), *(byte*)((ulong)(nint)guid + 8uL), *(byte*)((ulong)(nint)guid + 9uL), *(byte*)((ulong)(nint)guid + 10uL), *(byte*)((ulong)(nint)guid + 11uL), *(byte*)((ulong)(nint)guid + 12uL), *(byte*)((ulong)(nint)guid + 13uL), *(byte*)((ulong)(nint)guid + 14uL), *(byte*)((ulong)(nint)guid + 15uL));
	}

	internal unsafe static IUnknown* ?A0x9ea9c69e.GetDefaultAppDomain()
	{
		//IL_0003: Expected I, but got I8
		//IL_002e: Expected I, but got I8
		//IL_0033: Expected I, but got I8
		//IL_0042: Expected I, but got I8
		//IL_004f: Expected I, but got I8
		//IL_0059: Expected I, but got I8
		//IL_0058->IL0058: Incompatible stack types: I vs I8
		ICorRuntimeHost* ptr = null;
		try
		{
			Guid riid = ?A0x9ea9c69e.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_cb2f6722_ab3a_11d2_9c40_00c04fa30a3e));
			ptr = (ICorRuntimeHost*)RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(?A0x9ea9c69e.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_cb2f6723_ab3a_11d2_9c40_00c04fa30a3e)), riid).ToPointer();
		}
		catch (Exception)
		{
			return null;
		}
		IUnknown* ptr2 = null;
		int num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, IUnknown**, int>)(*(ulong*)(*(long*)ptr + 104)))((nint)ptr, &ptr2);
		ICorRuntimeHost* intPtr = ptr;
		((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)intPtr + 16)))((nint)intPtr);
		return (IUnknown*)((num < 0) ? 0 : ((nint)ptr2));
	}

	internal static void <CrtImplementationDetails>.ThrowNestedModuleLoadException(Exception innerException, Exception nestedException)
	{
		throw new ModuleLoadExceptionHandlerException("A nested exception occurred after the primary exception that caused the C++ module to fail to load.\n", innerException, nestedException);
	}

	internal static void <CrtImplementationDetails>.ThrowModuleLoadException(string errorMessage)
	{
		throw new ModuleLoadException(errorMessage);
	}

	internal static void <CrtImplementationDetails>.ThrowModuleLoadException(string errorMessage, Exception innerException)
	{
		throw new ModuleLoadException(errorMessage, innerException);
	}

	internal static void <CrtImplementationDetails>.RegisterModuleUninitializer(EventHandler handler)
	{
		ModuleUninitializer._ModuleUninitializer.AddHandler(handler);
	}

	[SecuritySafeCritical]
	internal unsafe static Guid <CrtImplementationDetails>.FromGUID(_GUID* guid)
	{
		return new Guid(*(uint*)guid, *(ushort*)((ulong)(nint)guid + 4uL), *(ushort*)((ulong)(nint)guid + 6uL), *(byte*)((ulong)(nint)guid + 8uL), *(byte*)((ulong)(nint)guid + 9uL), *(byte*)((ulong)(nint)guid + 10uL), *(byte*)((ulong)(nint)guid + 11uL), *(byte*)((ulong)(nint)guid + 12uL), *(byte*)((ulong)(nint)guid + 13uL), *(byte*)((ulong)(nint)guid + 14uL), *(byte*)((ulong)(nint)guid + 15uL));
	}

	[SecurityCritical]
	internal unsafe static int __get_default_appdomain(IUnknown** ppUnk)
	{
		//IL_0003: Expected I, but got I8
		//IL_0046: Expected I, but got I8
		//IL_0054: Expected I, but got I8
		ICorRuntimeHost* ptr = null;
		int num;
		try
		{
			Guid riid = <CrtImplementationDetails>.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_cb2f6722_ab3a_11d2_9c40_00c04fa30a3e));
			ptr = (ICorRuntimeHost*)RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(<CrtImplementationDetails>.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_cb2f6723_ab3a_11d2_9c40_00c04fa30a3e)), riid).ToPointer();
		}
		catch (Exception e)
		{
			num = Marshal.GetHRForException(e);
			goto IL_0032;
		}
		goto IL_0036;
		IL_0032:
		if (num >= 0)
		{
			goto IL_0036;
		}
		goto IL_0055;
		IL_0036:
		long num2 = *(long*)(*(long*)ptr + 104);
		num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, IUnknown**, int>)num2)((nint)ptr, ppUnk);
		ICorRuntimeHost* intPtr = ptr;
		((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)intPtr + 16)))((nint)intPtr);
		goto IL_0055;
		IL_0055:
		return num;
	}

	internal unsafe static void __release_appdomain(IUnknown* ppUnk)
	{
		//IL_000d: Expected I, but got I8
		((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)ppUnk + 16)))((nint)ppUnk);
	}

	[SecurityCritical]
	internal unsafe static AppDomain <CrtImplementationDetails>.GetDefaultDomain()
	{
		//IL_0003: Expected I, but got I8
		IUnknown* ptr = null;
		int num = __get_default_appdomain(&ptr);
		if (num >= 0)
		{
			try
			{
				IntPtr pUnk = new IntPtr(ptr);
				return (AppDomain)Marshal.GetObjectForIUnknown(pUnk);
			}
			finally
			{
				__release_appdomain(ptr);
			}
		}
		Marshal.ThrowExceptionForHR(num);
		return null;
	}

	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.DoCallBackInDefaultDomain(delegate* unmanaged[Cdecl, Cdecl]<void*, int> function, void* cookie)
	{
		//IL_005e: Expected I, but got I8
		//IL_0044: Expected I, but got I8
		Guid riid = <CrtImplementationDetails>.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_90f1a06c_7712_4762_86b5_7a5eba6bdb02));
		ICLRRuntimeHost* ptr = (ICLRRuntimeHost*)RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(<CrtImplementationDetails>.FromGUID((_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _GUID_90f1a06e_7712_4762_86b5_7a5eba6bdb02)), riid).ToPointer();
		try
		{
			AppDomain appDomain = <CrtImplementationDetails>.GetDefaultDomain();
			long num = *(long*)(*(long*)ptr + 64);
			uint id = (uint)appDomain.Id;
			int num2 = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint, delegate* unmanaged[Cdecl, Cdecl]<void*, int>, void*, int>)num)((nint)ptr, id, function, cookie);
			if (num2 < 0)
			{
				Marshal.ThrowExceptionForHR(num2);
			}
		}
		finally
		{
			((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)ptr + 16)))((nint)ptr);
		}
	}

	[return: MarshalAs(UnmanagedType.U1)]
	internal static bool __scrt_is_safe_for_managed_code()
	{
		uint _scrt_native_dllmain_reason = __scrt_native_dllmain_reason;
		if (_scrt_native_dllmain_reason != 0 && _scrt_native_dllmain_reason != 1)
		{
			return true;
		}
		return false;
	}

	[SecuritySafeCritical]
	internal unsafe static int <CrtImplementationDetails>.DefaultDomain.DoNothing(void* cookie)
	{
		GC.KeepAlive(int.MaxValue);
		return 0;
	}

	[SecuritySafeCritical]
	[return: MarshalAs(UnmanagedType.U1)]
	internal unsafe static bool <CrtImplementationDetails>.DefaultDomain.HasPerProcess()
	{
		//IL_0023: Expected I, but got I8
		if (?hasPerProcess@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A == (TriBool)2)
		{
			void** ptr = (void**)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_mp_a);
			if (System.Runtime.CompilerServices.Unsafe.IsAddressLessThan(ref __xc_mp_a, ref __xc_mp_z))
			{
				do
				{
					if (*(long*)ptr == 0L)
					{
						ptr = (void**)((ulong)(nint)ptr + 8uL);
						continue;
					}
					?hasPerProcess@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A = (TriBool)(-1);
					return true;
				}
				while (ptr < System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_mp_z));
			}
			?hasPerProcess@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A = (TriBool)0;
			return false;
		}
		return ?hasPerProcess@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A == (TriBool)(-1);
	}

	[SecuritySafeCritical]
	[return: MarshalAs(UnmanagedType.U1)]
	internal unsafe static bool <CrtImplementationDetails>.DefaultDomain.HasNative()
	{
		//IL_0023: Expected I, but got I8
		//IL_0050: Expected I, but got I8
		if (?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A == (TriBool)2)
		{
			void** ptr = (void**)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_a);
			if (System.Runtime.CompilerServices.Unsafe.IsAddressLessThan(ref __xi_a, ref __xi_z))
			{
				do
				{
					if (*(long*)ptr == 0L)
					{
						ptr = (void**)((ulong)(nint)ptr + 8uL);
						continue;
					}
					?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A = (TriBool)(-1);
					return true;
				}
				while (ptr < System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_z));
			}
			void** ptr2 = (void**)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_a);
			if (System.Runtime.CompilerServices.Unsafe.IsAddressLessThan(ref __xc_a, ref __xc_z))
			{
				do
				{
					if (*(long*)ptr2 == 0L)
					{
						ptr2 = (void**)((ulong)(nint)ptr2 + 8uL);
						continue;
					}
					?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A = (TriBool)(-1);
					return true;
				}
				while (ptr2 < System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_z));
			}
			?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A = (TriBool)0;
			return false;
		}
		return ?hasNative@DefaultDomain@<CrtImplementationDetails>@@0W4TriBool@2@A == (TriBool)(-1);
	}

	[SecuritySafeCritical]
	[return: MarshalAs(UnmanagedType.U1)]
	internal static bool <CrtImplementationDetails>.DefaultDomain.NeedsInitialization()
	{
		int num = (((<CrtImplementationDetails>.DefaultDomain.HasPerProcess() && !?InitializedPerProcess@DefaultDomain@<CrtImplementationDetails>@@2_NA) || (<CrtImplementationDetails>.DefaultDomain.HasNative() && !?InitializedNative@DefaultDomain@<CrtImplementationDetails>@@2_NA && __scrt_current_native_startup_state == (__scrt_native_startup_state)0)) ? 1 : 0);
		return (byte)num != 0;
	}

	[return: MarshalAs(UnmanagedType.U1)]
	internal static bool <CrtImplementationDetails>.DefaultDomain.NeedsUninitialization()
	{
		return ?Entered@DefaultDomain@<CrtImplementationDetails>@@2_NA;
	}

	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.DefaultDomain.Initialize()
	{
		//IL_000c: Expected I, but got I8
		<CrtImplementationDetails>.DoCallBackInDefaultDomain((delegate* unmanaged[Cdecl, Cdecl]<void*, int>)__unep@?DoNothing@DefaultDomain@<CrtImplementationDetails>@@$$FCAJPEAX@Z, null);
	}

	internal static void ?A0x201c0761.??__E?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA@@YMXXZ()
	{
		?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA = 0;
	}

	internal static void ?A0x201c0761.??__E?Uninitialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA@@YMXXZ()
	{
		?Uninitialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA = 0;
	}

	internal static void ?A0x201c0761.??__E?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA@@YMXXZ()
	{
		?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA = false;
	}

	internal static void ?A0x201c0761.??__E?InitializedVtables@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A@@YMXXZ()
	{
		?InitializedVtables@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)0;
	}

	internal static void ?A0x201c0761.??__E?InitializedNative@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A@@YMXXZ()
	{
		?InitializedNative@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)0;
	}

	internal static void ?A0x201c0761.??__E?InitializedPerProcess@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A@@YMXXZ()
	{
		?InitializedPerProcess@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)0;
	}

	internal static void ?A0x201c0761.??__E?InitializedPerAppDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A@@YMXXZ()
	{
		?InitializedPerAppDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)0;
	}

	[DebuggerStepThrough]
	[SecuritySafeCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializeVtables(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load during vtable initialization.\n");
		?InitializedVtables@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)1;
		_initterm_m((delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_vt_a), (delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_vt_z));
		?InitializedVtables@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)2;
	}

	[SecuritySafeCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load while attempting to initialize the default appdomain.\n");
		<CrtImplementationDetails>.DefaultDomain.Initialize();
	}

	[DebuggerStepThrough]
	[SecuritySafeCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializeNative(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load during native initialization.\n");
		__security_init_cookie();
		?InitializedNative@DefaultDomain@<CrtImplementationDetails>@@2_NA = true;
		if (!__scrt_is_safe_for_managed_code())
		{
			abort();
		}
		if (__scrt_current_native_startup_state == (__scrt_native_startup_state)1)
		{
			abort();
		}
		if (__scrt_current_native_startup_state == (__scrt_native_startup_state)0)
		{
			?InitializedNative@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)1;
			__scrt_current_native_startup_state = (__scrt_native_startup_state)1;
			if (_initterm_e((delegate* unmanaged[Cdecl, Cdecl]<int>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_a), (delegate* unmanaged[Cdecl, Cdecl]<int>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xi_z)) != 0)
			{
				<CrtImplementationDetails>.ThrowModuleLoadException(gcroot<System::String ^>..PE$AAVString@System@@((gcroot<System::String ^>*)P_0));
			}
			_initterm((delegate* unmanaged[Cdecl, Cdecl]<void>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_a), (delegate* unmanaged[Cdecl, Cdecl]<void>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_z));
			__scrt_current_native_startup_state = (__scrt_native_startup_state)2;
			?InitializedNativeFromCCTOR@DefaultDomain@<CrtImplementationDetails>@@2_NA = true;
			?InitializedNative@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)2;
		}
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializePerProcess(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load during process initialization.\n");
		?InitializedPerProcess@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)1;
		_initatexit_m();
		_initterm_m((delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_mp_a), (delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_mp_z));
		?InitializedPerProcess@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)2;
		?InitializedPerProcess@DefaultDomain@<CrtImplementationDetails>@@2_NA = true;
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializePerAppDomain(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load during appdomain initialization.\n");
		?InitializedPerAppDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)1;
		_initatexit_app_domain();
		_initterm_m((delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_ma_a), (delegate*<void*>*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref __xc_ma_z));
		?InitializedPerAppDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2W4Progress@2@A = (Progress)2;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.InitializeUninitializer(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load during registration for the unload events.\n");
		<CrtImplementationDetails>.RegisterModuleUninitializer([ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [PrePrepareMethod] [SecurityCritical] (object A_0, EventArgs A_1) =>
		{
			if (?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA != 0 && Interlocked.Exchange(ref ?Uninitialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA, 1) == 0)
			{
				bool num = Interlocked.Decrement(ref ?Count@AllDomains@<CrtImplementationDetails>@@2HA) == 0;
				<CrtImplementationDetails>.LanguageSupport.UninitializeAppDomain();
				if (num)
				{
					<CrtImplementationDetails>.LanguageSupport.UninitializeDefaultDomain();
				}
			}
		});
	}

	[DebuggerStepThrough]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* P_0)
	{
		//IL_0049: Expected I8, but got I
		//IL_004a: Expected I, but got I8
		?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA = AppDomain.CurrentDomain.IsDefaultAppDomain();
		?Entered@DefaultDomain@<CrtImplementationDetails>@@2_NA = ?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA || ?Entered@DefaultDomain@<CrtImplementationDetails>@@2_NA;
		void* ptr = _getFiberPtrId();
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			while (num2 == 0)
			{
				try
				{
				}
				finally
				{
					void* ptr2 = (void*)Interlocked.CompareExchange(ref System.Runtime.CompilerServices.Unsafe.As<void*, long>(ref __scrt_native_startup_lock), (nint)ptr, 0L);
					if (ptr2 == null)
					{
						num2 = 1;
					}
					else if (ptr2 == ptr)
					{
						num = 1;
						num2 = 1;
					}
				}
				if (num2 == 0)
				{
					Sleep(1000u);
				}
			}
			<CrtImplementationDetails>.LanguageSupport.InitializeVtables(P_0);
			if (?IsDefaultDomain@CurrentDomain@<CrtImplementationDetails>@@$$Q2_NA)
			{
				<CrtImplementationDetails>.LanguageSupport.InitializeNative(P_0);
				<CrtImplementationDetails>.LanguageSupport.InitializePerProcess(P_0);
			}
			else
			{
				num3 = (<CrtImplementationDetails>.DefaultDomain.NeedsInitialization() ? 1 : num3);
			}
		}
		finally
		{
			if (num == 0)
			{
				Interlocked.Exchange(ref System.Runtime.CompilerServices.Unsafe.As<void*, long>(ref __scrt_native_startup_lock), 0L);
			}
		}
		if (num3 != 0)
		{
			<CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(P_0);
		}
		<CrtImplementationDetails>.LanguageSupport.InitializePerAppDomain(P_0);
		?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA = 1;
		<CrtImplementationDetails>.LanguageSupport.InitializeUninitializer(P_0);
	}

	[SecurityCritical]
	internal static void <CrtImplementationDetails>.LanguageSupport.UninitializeAppDomain()
	{
		_app_exit_callback();
	}

	[SecurityCritical]
	internal unsafe static int <CrtImplementationDetails>.LanguageSupport._UninitializeDefaultDomain(void* cookie)
	{
		_exit_callback();
		?InitializedPerProcess@DefaultDomain@<CrtImplementationDetails>@@2_NA = false;
		if (?InitializedNativeFromCCTOR@DefaultDomain@<CrtImplementationDetails>@@2_NA)
		{
			_cexit();
			__scrt_current_native_startup_state = (__scrt_native_startup_state)0;
			?InitializedNativeFromCCTOR@DefaultDomain@<CrtImplementationDetails>@@2_NA = false;
		}
		?InitializedNative@DefaultDomain@<CrtImplementationDetails>@@2_NA = false;
		return 0;
	}

	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.UninitializeDefaultDomain()
	{
		//IL_0029: Expected I, but got I8
		//IL_001a: Expected I, but got I8
		if (<CrtImplementationDetails>.DefaultDomain.NeedsUninitialization())
		{
			if (AppDomain.CurrentDomain.IsDefaultAppDomain())
			{
				<CrtImplementationDetails>.LanguageSupport._UninitializeDefaultDomain(null);
			}
			else
			{
				<CrtImplementationDetails>.DoCallBackInDefaultDomain((delegate* unmanaged[Cdecl, Cdecl]<void*, int>)__unep@?_UninitializeDefaultDomain@LanguageSupport@<CrtImplementationDetails>@@$$FCAJPEAX@Z, null);
			}
		}
	}

	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[PrePrepareMethod]
	[SecurityCritical]
	internal static void <CrtImplementationDetails>.LanguageSupport.DomainUnload(object A_0, EventArgs A_1)
	{
		if (?Initialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA != 0 && Interlocked.Exchange(ref ?Uninitialized@CurrentDomain@<CrtImplementationDetails>@@$$Q2HA, 1) == 0)
		{
			bool num = Interlocked.Decrement(ref ?Count@AllDomains@<CrtImplementationDetails>@@2HA) == 0;
			<CrtImplementationDetails>.LanguageSupport.UninitializeAppDomain();
			if (num)
			{
				<CrtImplementationDetails>.LanguageSupport.UninitializeDefaultDomain();
			}
		}
	}

	[SecurityCritical]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[DebuggerStepThrough]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.Cleanup(LanguageSupport* P_0, Exception innerException)
	{
		try
		{
			bool flag = Interlocked.Decrement(ref ?Count@AllDomains@<CrtImplementationDetails>@@2HA) == 0;
			<CrtImplementationDetails>.LanguageSupport.UninitializeAppDomain();
			if (flag)
			{
				<CrtImplementationDetails>.LanguageSupport.UninitializeDefaultDomain();
			}
		}
		catch (Exception nestedException)
		{
			<CrtImplementationDetails>.ThrowNestedModuleLoadException(innerException, nestedException);
		}
		catch
		{
			<CrtImplementationDetails>.ThrowNestedModuleLoadException(innerException, null);
		}
	}

	[SecurityCritical]
	internal unsafe static LanguageSupport* <CrtImplementationDetails>.LanguageSupport.{ctor}(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.{ctor}((gcroot<System::String ^>*)P_0);
		return P_0;
	}

	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.{dtor}(LanguageSupport* P_0)
	{
		gcroot<System::String ^>.{dtor}((gcroot<System::String ^>*)P_0);
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	internal unsafe static void <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* P_0)
	{
		bool flag = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			gcroot<System::String ^>.=((gcroot<System::String ^>*)P_0, "The C++ module failed to load.\n");
			RuntimeHelpers.PrepareConstrainedRegions();
			try
			{
			}
			finally
			{
				Interlocked.Increment(ref ?Count@AllDomains@<CrtImplementationDetails>@@2HA);
				flag = true;
			}
			<CrtImplementationDetails>.LanguageSupport._Initialize(P_0);
		}
		catch (Exception innerException)
		{
			if (flag)
			{
				<CrtImplementationDetails>.LanguageSupport.Cleanup(P_0, innerException);
			}
			<CrtImplementationDetails>.ThrowModuleLoadException(gcroot<System::String ^>..PE$AAVString@System@@((gcroot<System::String ^>*)P_0), innerException);
		}
		catch
		{
			if (flag)
			{
				<CrtImplementationDetails>.LanguageSupport.Cleanup(P_0, null);
			}
			<CrtImplementationDetails>.ThrowModuleLoadException(gcroot<System::String ^>..PE$AAVString@System@@((gcroot<System::String ^>*)P_0), null);
		}
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	static unsafe <Module>()
	{
		System.Runtime.CompilerServices.Unsafe.SkipInit(out LanguageSupport languageSupport);
		<CrtImplementationDetails>.LanguageSupport.{ctor}(&languageSupport);
		try
		{
			<CrtImplementationDetails>.LanguageSupport.Initialize(&languageSupport);
		}
		catch
		{
			//try-fault
			___CxxCallUnwindDtor((delegate*<void*, void>)(delegate*<LanguageSupport*, void>)(&<CrtImplementationDetails>.LanguageSupport.{dtor}), &languageSupport);
			throw;
		}
		<CrtImplementationDetails>.LanguageSupport.{dtor}(&languageSupport);
	}

	[SecuritySafeCritical]
	internal unsafe static string gcroot<System::String ^>..PE$AAVString@System@@(gcroot<System::String ^>* P_0)
	{
		//IL_0009: Expected I, but got I8
		IntPtr intPtr = new IntPtr((void*)(*(ulong*)P_0));
		return (string)((GCHandle)intPtr).Target;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static gcroot<System::String ^>* gcroot<System::String ^>.=(gcroot<System::String ^>* P_0, string t)
	{
		//IL_0009: Expected I, but got I8
		IntPtr intPtr = new IntPtr((void*)(*(ulong*)P_0));
		GCHandle gCHandle = (GCHandle)intPtr;
		gCHandle.Target = t;
		return P_0;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static void gcroot<System::String ^>.{dtor}(gcroot<System::String ^>* P_0)
	{
		//IL_0009: Expected I, but got I8
		IntPtr intPtr = new IntPtr((void*)(*(ulong*)P_0));
		((GCHandle)intPtr).Free();
		*(long*)P_0 = 0L;
	}

	[DebuggerStepThrough]
	[SecuritySafeCritical]
	internal unsafe static gcroot<System::String ^>* gcroot<System::String ^>.{ctor}(gcroot<System::String ^>* P_0)
	{
		//IL_0015: Expected I8, but got I
		*(long*)P_0 = (nint)((IntPtr)GCHandle.Alloc(null)).ToPointer();
		return P_0;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static System.ValueType <CrtImplementationDetails>.AtExitLock._handle()
	{
		if (?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA != null)
		{
			IntPtr value = new IntPtr(?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA);
			return GCHandle.FromIntPtr(value);
		}
		return null;
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static void <CrtImplementationDetails>.AtExitLock._lock_Construct(object value)
	{
		//IL_0007: Expected I, but got I8
		?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA = null;
		<CrtImplementationDetails>.AtExitLock._lock_Set(value);
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static void <CrtImplementationDetails>.AtExitLock._lock_Set(object value)
	{
		System.ValueType valueType = <CrtImplementationDetails>.AtExitLock._handle();
		if (valueType == null)
		{
			valueType = GCHandle.Alloc(value);
			?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA = GCHandle.ToIntPtr((GCHandle)valueType).ToPointer();
		}
		else
		{
			((GCHandle)valueType).Target = value;
		}
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal static object <CrtImplementationDetails>.AtExitLock._lock_Get()
	{
		System.ValueType valueType = <CrtImplementationDetails>.AtExitLock._handle();
		if (valueType != null)
		{
			return ((GCHandle)valueType).Target;
		}
		return null;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal unsafe static void <CrtImplementationDetails>.AtExitLock._lock_Destruct()
	{
		//IL_001b: Expected I, but got I8
		System.ValueType valueType = <CrtImplementationDetails>.AtExitLock._handle();
		if (valueType != null)
		{
			((GCHandle)valueType).Free();
			?_lock@AtExitLock@<CrtImplementationDetails>@@$$Q0PEAXEA = null;
		}
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	[return: MarshalAs(UnmanagedType.U1)]
	internal static bool <CrtImplementationDetails>.AtExitLock.IsInitialized()
	{
		return <CrtImplementationDetails>.AtExitLock._lock_Get() != null;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal static void <CrtImplementationDetails>.AtExitLock.AddRef()
	{
		if (!<CrtImplementationDetails>.AtExitLock.IsInitialized())
		{
			<CrtImplementationDetails>.AtExitLock._lock_Construct(new object());
			?_ref_count@AtExitLock@<CrtImplementationDetails>@@$$Q0HA = 0;
		}
		?_ref_count@AtExitLock@<CrtImplementationDetails>@@$$Q0HA++;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal static void <CrtImplementationDetails>.AtExitLock.RemoveRef()
	{
		?_ref_count@AtExitLock@<CrtImplementationDetails>@@$$Q0HA += -1;
		if (?_ref_count@AtExitLock@<CrtImplementationDetails>@@$$Q0HA == 0)
		{
			<CrtImplementationDetails>.AtExitLock._lock_Destruct();
		}
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	[return: MarshalAs(UnmanagedType.U1)]
	internal static bool ?A0x9a16e6c2.__alloc_global_lock()
	{
		<CrtImplementationDetails>.AtExitLock.AddRef();
		return <CrtImplementationDetails>.AtExitLock.IsInitialized();
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	internal static void ?A0x9a16e6c2.__dealloc_global_lock()
	{
		<CrtImplementationDetails>.AtExitLock.RemoveRef();
	}

	[SecurityCritical]
	internal unsafe static void _exit_callback()
	{
		//IL_003d: Expected I, but got I8
		//IL_004a: Expected I, but got I8
		//IL_0053: Expected I, but got I8
		//IL_005b: Expected I, but got I8
		//IL_005c: Expected I8, but got I
		if (?A0x9a16e6c2.__exit_list_size == 0L)
		{
			return;
		}
		delegate*<void>* ptr = (delegate*<void>*)DecodePointer(?A0x9a16e6c2.__onexitbegin_m);
		delegate*<void>* ptr2 = (delegate*<void>*)DecodePointer(?A0x9a16e6c2.__onexitend_m);
		if ((nint)ptr != -1L && ptr != null && ptr2 != null)
		{
			delegate*<void>* ptr3 = ptr;
			delegate*<void>* ptr4 = ptr2;
			while (true)
			{
				ptr2 = (delegate*<void>*)((ulong)(nint)ptr2 - 8uL);
				if (ptr2 < ptr)
				{
					break;
				}
				if (*(long*)ptr2 != (nint)EncodePointer(null))
				{
					void* intPtr = DecodePointer((void*)(*(ulong*)ptr2));
					*(long*)ptr2 = (nint)EncodePointer(null);
					((delegate*<void>)intPtr)();
					delegate*<void>* ptr5 = (delegate*<void>*)DecodePointer(?A0x9a16e6c2.__onexitbegin_m);
					delegate*<void>* ptr6 = (delegate*<void>*)DecodePointer(?A0x9a16e6c2.__onexitend_m);
					if (ptr3 != ptr5 || ptr4 != ptr6)
					{
						ptr3 = ptr5;
						ptr = ptr5;
						ptr4 = ptr6;
						ptr2 = ptr6;
					}
				}
			}
			IntPtr hglobal = new IntPtr(ptr);
			Marshal.FreeHGlobal(hglobal);
		}
		?A0x9a16e6c2.__dealloc_global_lock();
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static int _initatexit_m()
	{
		int result = 0;
		if (?A0x9a16e6c2.__alloc_global_lock())
		{
			?A0x9a16e6c2.__onexitbegin_m = (delegate*<void>*)EncodePointer(Marshal.AllocHGlobal(256).ToPointer());
			?A0x9a16e6c2.__onexitend_m = ?A0x9a16e6c2.__onexitbegin_m;
			?A0x9a16e6c2.__exit_list_size = 32uL;
			result = 1;
		}
		return result;
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static int _initatexit_app_domain()
	{
		if (?A0x9a16e6c2.__alloc_global_lock())
		{
			__onexitbegin_app_domain = (delegate*<void>*)EncodePointer(Marshal.AllocHGlobal(256).ToPointer());
			__onexitend_app_domain = __onexitbegin_app_domain;
			__exit_list_size_app_domain = 32uL;
		}
		return 1;
	}

	[SecurityCritical]
	[HandleProcessCorruptedStateExceptions]
	internal unsafe static void _app_exit_callback()
	{
		//IL_003c: Expected I, but got I8
		//IL_0046: Expected I, but got I8
		//IL_004a: Expected I, but got I8
		//IL_004f: Expected I, but got I8
		//IL_005c: Expected I, but got I8
		//IL_006b: Expected I, but got I8
		//IL_0075: Expected I, but got I8
		//IL_0076: Expected I8, but got I
		if (__exit_list_size_app_domain == 0L)
		{
			return;
		}
		delegate*<void>* ptr = (delegate*<void>*)DecodePointer(__onexitbegin_app_domain);
		delegate*<void>* ptr2 = (delegate*<void>*)DecodePointer(__onexitend_app_domain);
		try
		{
			if ((nint)ptr == -1L || ptr == null || ptr2 == null)
			{
				return;
			}
			delegate*<void> delegate* = null;
			delegate*<void>* ptr3 = ptr;
			delegate*<void>* ptr4 = ptr2;
			while (true)
			{
				delegate*<void>* ptr5 = null;
				delegate*<void>* ptr6 = null;
				do
				{
					ptr2 = (delegate*<void>*)((ulong)(nint)ptr2 - 8uL);
				}
				while (ptr2 >= ptr && *(long*)ptr2 == (nint)EncodePointer(null));
				if (ptr2 >= ptr)
				{
					delegate* = (delegate*<void>)DecodePointer((void*)(*(ulong*)ptr2));
					*(long*)ptr2 = (nint)EncodePointer(null);
					delegate*();
					delegate*<void>* ptr7 = (delegate*<void>*)DecodePointer(__onexitbegin_app_domain);
					delegate*<void>* ptr8 = (delegate*<void>*)DecodePointer(__onexitend_app_domain);
					if (ptr3 != ptr7 || ptr4 != ptr8)
					{
						ptr3 = ptr7;
						ptr = ptr7;
						ptr4 = ptr8;
						ptr2 = ptr8;
					}
					continue;
				}
				break;
			}
		}
		finally
		{
			IntPtr hglobal = new IntPtr(ptr);
			Marshal.FreeHGlobal(hglobal);
			?A0x9a16e6c2.__dealloc_global_lock();
		}
	}

	[DllImport("KERNEL32.dll")]
	[SuppressUnmanagedCodeSecurity]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[SecurityCritical]
	public unsafe static extern void* DecodePointer(void* _Ptr);

	[DllImport("KERNEL32.dll")]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	public unsafe static extern void* EncodePointer(void* _Ptr);

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static int _initterm_e(delegate* unmanaged[Cdecl, Cdecl]<int>* pfbegin, delegate* unmanaged[Cdecl, Cdecl]<int>* pfend)
	{
		//IL_001c: Expected I, but got I8
		//IL_0015: Expected I, but got I8
		int num = 0;
		if (pfbegin < pfend)
		{
			while (num == 0)
			{
				ulong num2 = *(ulong*)pfbegin;
				if (num2 != 0L)
				{
					num = ((delegate* unmanaged[Cdecl, Cdecl]<int>)num2)();
				}
				pfbegin = (delegate* unmanaged[Cdecl, Cdecl]<int>*)((ulong)(nint)pfbegin + 8uL);
				if (pfbegin >= pfend)
				{
					break;
				}
			}
		}
		return num;
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static void _initterm(delegate* unmanaged[Cdecl, Cdecl]<void>* pfbegin, delegate* unmanaged[Cdecl, Cdecl]<void>* pfend)
	{
		//IL_0016: Expected I, but got I8
		//IL_0010: Expected I, but got I8
		if (pfbegin >= pfend)
		{
			return;
		}
		do
		{
			ulong num = *(ulong*)pfbegin;
			if (num != 0L)
			{
				((delegate* unmanaged[Cdecl, Cdecl]<void>)num)();
			}
			pfbegin = (delegate* unmanaged[Cdecl, Cdecl]<void>*)((ulong)(nint)pfbegin + 8uL);
		}
		while (pfbegin < pfend);
	}

	[DebuggerStepThrough]
	internal static ModuleHandle <CrtImplementationDetails>.ThisModule.Handle()
	{
		return typeof(ThisModule).Module.ModuleHandle;
	}

	[SecurityCritical]
	[DebuggerStepThrough]
	[SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)]
	internal unsafe static void _initterm_m(delegate*<void*>* pfbegin, delegate*<void*>* pfend)
	{
		//IL_001c: Expected I, but got I8
		//IL_0010: Expected I, but got I8
		if (pfbegin >= pfend)
		{
			return;
		}
		do
		{
			ulong num = *(ulong*)pfbegin;
			if (num != 0L)
			{
				<CrtImplementationDetails>.ThisModule.ResolveMethod<void const * __clrcall(void)>((delegate*<void*>)num)();
			}
			pfbegin = (delegate*<void*>*)((ulong)(nint)pfbegin + 8uL);
		}
		while (pfbegin < pfend);
	}

	[DebuggerStepThrough]
	[SecurityCritical]
	internal unsafe static delegate*<void*> <CrtImplementationDetails>.ThisModule.ResolveMethod<void const * __clrcall(void)>(delegate*<void*> methodToken)
	{
		return (delegate*<void*>)<CrtImplementationDetails>.ThisModule.Handle().ResolveMethodHandle((int)methodToken).GetFunctionPointer().ToPointer();
	}

	[HandleProcessCorruptedStateExceptions]
	[SecurityCritical]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)]
	internal unsafe static void ___CxxCallUnwindDtor(delegate*<void*, void> pDtor, void* pThis)
	{
		try
		{
			pDtor(pThis);
		}
		catch when (__FrameUnwindFilter((_EXCEPTION_POINTERS*)Marshal.GetExceptionPointers()) != 0)
		{
		}
	}

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern void* SqlDependencyProcessDispatcherStorage.NativeGetData(int* P_0);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	[return: MarshalAs(UnmanagedType.U1)]
	internal unsafe static extern bool SqlDependencyProcessDispatcherStorage.NativeSetData(void* P_0, int P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIWriteSyncOverAsync(SNI_ConnWrapper* P_0, SNI_Packet* P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIReadSyncOverAsync(SNI_ConnWrapper* P_0, SNI_Packet** P_1, int P_2);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNIOpenWrapper(Sni_Consumer_Info* P_0, ushort* P_1, void* P_2, SNI_ConnWrapper** P_3, int P_4);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern void* SNI_ConnWrapper.__delDtor(SNI_ConnWrapper* P_0, uint P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNIOpenSyncExWrapper(SNI_CLIENT_CONSUMER_INFO* P_0, SNI_ConnWrapper** P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint UnmanagedIsTokenRestricted(void* P_0, int* P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern int SNIServerEnumRead(void* P_0, ushort* P_1, int P_2, int* P_3);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNISecGenClientContext(SNI_Conn* P_0, byte* P_1, uint P_2, byte* P_3, uint* P_4, int* P_5, ushort* P_6, uint P_7, ushort* P_8, ushort* P_9);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIQueryInfo(uint P_0, void* P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal static extern uint SNISecADALInitialize();

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern int* _errno();

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNIWaitForSSLHandshakeToComplete(SNI_Conn* P_0, uint P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern void* SNIServerEnumOpen(ushort* P_0, int P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNISetInfo(SNI_Conn* P_0, uint P_1, void* P_2);

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal static extern void _invalid_parameter_noinfo();

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIInitialize(void* P_0);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIAddProvider(SNI_Conn* P_0, ProviderNum P_1, void* P_2);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNISecInitPackage(uint* P_0);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNIGetInfo(SNI_Conn* P_0, uint P_1, void* P_2);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern uint SNISecADALGetAccessToken(ushort* P_0, ushort* P_1, ushort* P_2, ushort* P_3, _GUID* P_4, ushort* P_5, bool* P_6, ushort** P_7, uint* P_8, ushort** P_9, uint* P_10, uint* P_11, uint* P_12, _FILETIME* P_13);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern uint SNIRemoveProvider(SNI_Conn* P_0, ProviderNum P_1);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern void delete[](void* P_0);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern void SNIGetLastError(SNI_ERROR* P_0);

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal unsafe static extern void* _getFiberPtrId();

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal static extern void _cexit();

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal static extern void Sleep(uint P_0);

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal static extern void abort();

	[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig, MethodCodeType = MethodCodeType.Native)]
	[SecurityCritical]
	[SuppressUnmanagedCodeSecurity]
	internal static extern void __security_init_cookie();

	[DllImport("", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
	[MethodImpl(MethodImplOptions.Unmanaged, MethodCodeType = MethodCodeType.Native)]
	[SuppressUnmanagedCodeSecurity]
	[SecurityCritical]
	internal unsafe static extern int __FrameUnwindFilter(_EXCEPTION_POINTERS* P_0);
}
[CLSCompliant(false)]
internal class SNINativeMethodWrapper
{
	internal enum QTypes
	{
		SNI_QUERY_CONN_INFO = 0,
		SNI_QUERY_CONN_BUFSIZE = 1,
		SNI_QUERY_CONN_KEY = 2,
		SNI_QUERY_CLIENT_ENCRYPT_POSSIBLE = 3,
		SNI_QUERY_SERVER_ENCRYPT_POSSIBLE = 4,
		SNI_QUERY_CERTIFICATE = 5,
		SNI_QUERY_CONN_ENCRYPT = 7,
		SNI_QUERY_CONN_PROVIDERNUM = 8,
		SNI_QUERY_CONN_CONNID = 9,
		SNI_QUERY_CONN_PARENTCONNID = 10,
		SNI_QUERY_CONN_SECPKG = 11,
		SNI_QUERY_CONN_NETPACKETSIZE = 12,
		SNI_QUERY_CONN_NODENUM = 13,
		SNI_QUERY_CONN_PACKETSRECD = 14,
		SNI_QUERY_CONN_PACKETSSENT = 15,
		SNI_QUERY_CONN_PEERADDR = 16,
		SNI_QUERY_CONN_PEERPORT = 17,
		SNI_QUERY_CONN_LASTREADTIME = 18,
		SNI_QUERY_CONN_LASTWRITETIME = 19,
		SNI_QUERY_CONN_CONSUMER_ID = 20,
		SNI_QUERY_CONN_CONNECTTIME = 21,
		SNI_QUERY_CONN_HTTPENDPOINT = 22,
		SNI_QUERY_CONN_LOCALADDR = 23,
		SNI_QUERY_CONN_LOCALPORT = 24,
		SNI_QUERY_CONN_SSLHANDSHAKESTATE = 25,
		SNI_QUERY_CONN_SOBUFAUTOTUNING = 26,
		SNI_QUERY_CONN_SECPKGNAME = 27,
		SNI_QUERY_CONN_SECPKGMUTUALAUTH = 28,
		SNI_QUERY_CONN_CONSUMERCONNID = 29,
		SNI_QUERY_CONN_SNIUCI = 30,
		SNI_QUERY_LOCALDB_HMODULE = 6,
		SNI_QUERY_TCP_SKIP_IO_COMPLETION_ON_SUCCESS = 35
	}

	internal enum ProviderEnum
	{
		HTTP_PROV,
		NP_PROV,
		SESSION_PROV,
		SIGN_PROV,
		SM_PROV,
		SMUX_PROV,
		SSL_PROV,
		TCP_PROV,
		VIA_PROV,
		MAX_PROVS,
		INVALID_PROV
	}

	internal enum IOType
	{
		READ,
		WRITE
	}

	internal enum ConsumerNumber
	{
		SNI_Consumer_SNI,
		SNI_Consumer_SSB,
		SNI_Consumer_PacketIsReleased,
		SNI_Consumer_Invalid
	}

	internal delegate void SqlAsyncCallbackDelegate(IntPtr ptr1, IntPtr ptr2, uint num);

	[CLSCompliant(false)]
	internal class ConsumerInfo
	{
		internal int defaultBufferSize;

		internal SqlAsyncCallbackDelegate readDelegate;

		internal SqlAsyncCallbackDelegate writeDelegate;

		internal IntPtr key;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	[CLSCompliant(false)]
	internal class SNI_Error
	{
		internal ProviderEnum provider;

		internal char[] errorMessage;

		internal uint nativeError;

		internal uint sniError;

		internal string fileName;

		internal string function;

		internal uint lineNumber;
	}

	internal static int SniMaxComposedSpnLength = (int)global::<Module>.SNI_MAX_COMPOSED_SPN;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, uint> SNICheckConnectionPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, uint>)global::<Module>.__unep@?SNICheckConnection@@$$J0YAKPEAVSNI_Conn@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_ConnWrapper*, SNI_Packet*, uint> SNIWriteAsyncWrapperPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_ConnWrapper*, SNI_Packet*, uint>)global::<Module>.__unep@?SNIWriteAsyncWrapper@@$$FYAKPEAUSNI_ConnWrapper@@PEAVSNI_Packet@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_ConnWrapper*, SNI_Packet**, uint> SNIReadAsyncWrapperPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_ConnWrapper*, SNI_Packet**, uint>)global::<Module>.__unep@?SNIReadAsyncWrapper@@$$FYAKPEAUSNI_ConnWrapper@@PEAPEAVSNI_Packet@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, SNI_Packet_IOType, SNI_Packet*> SNIPacketAllocatePtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, SNI_Packet_IOType, SNI_Packet*>)global::<Module>.__unep@?SNIPacketAllocate@@$$J0YAPEAVSNI_Packet@@PEAVSNI_Conn@@W4SNI_Packet_IOType@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, void> SNIPacketReleasePtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, void>)global::<Module>.__unep@?SNIPacketRelease@@$$J0YAXPEAVSNI_Packet@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, SNI_Packet_IOType, SNI_Packet*, ConsumerNum, void> SNIPacketResetPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, SNI_Packet_IOType, SNI_Packet*, ConsumerNum, void>)global::<Module>.__unep@?SNIPacketReset@@$$J0YAXPEAVSNI_Conn@@W4SNI_Packet_IOType@@PEAVSNI_Packet@@W4ConsumerNum@@@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, byte*, uint, uint*, uint> SNIPacketGetDataWrapperPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, byte*, uint, uint*, uint>)global::<Module>.__unep@?SNIPacketGetDataWrapper@@$$FYAKPEAVSNI_Packet@@PEAEKPEAK@Z;

	private unsafe static delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, byte*, uint, void> SNIPacketSetDataPtr = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Packet*, byte*, uint, void>)global::<Module>.__unep@?SNIPacketSetData@@$$J0YAXPEAVSNI_Packet@@PEBEK@Z;

	[ResourceExposure(ResourceScope.Process)]
	[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
	internal unsafe static byte[] GetData()
	{
		System.Runtime.CompilerServices.Unsafe.SkipInit(out int num);
		IntPtr intPtr = (IntPtr)global::<Module>.SqlDependencyProcessDispatcherStorage.NativeGetData(&num);
		byte[] array = null;
		if (intPtr != IntPtr.Zero)
		{
			array = new byte[num];
			Marshal.Copy(intPtr, array, 0, num);
		}
		return array;
	}

	[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
	[ResourceExposure(ResourceScope.Process)]
	internal unsafe static void SetData(byte[] data)
	{
		fixed (byte* ptr = &data[0])
		{
			global::<Module>.SqlDependencyProcessDispatcherStorage.NativeSetData(ptr, data.Length);
		}
	}

	[ResourceExposure(ResourceScope.Process)]
	[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
	internal unsafe static _AppDomain GetDefaultAppDomain()
	{
		IntPtr pUnk = (IntPtr)global::<Module>.?A0x9ea9c69e.GetDefaultAppDomain();
		object objectForIUnknown = Marshal.GetObjectForIUnknown(pUnk);
		Marshal.Release(pUnk);
		return (_AppDomain)((objectForIUnknown is _AppDomain) ? objectForIUnknown : null);
	}

	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static IntPtr SNIServerEnumOpen()
	{
		//IL_000a: Expected I, but got I8
		return new IntPtr(global::<Module>.SNIServerEnumOpen(null, 1));
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static int SNIServerEnumRead(IntPtr handle, char[] wStr, int pcbBuf, ref bool fMore)
	{
		fixed (ushort* ptr = &System.Runtime.CompilerServices.Unsafe.As<char, ushort>(ref wStr[0]))
		{
			int num = (fMore ? 1 : 0);
			int result = global::<Module>.SNIServerEnumRead(handle.ToPointer(), ptr, pcbBuf, &num);
			byte b = (byte)((num != 0) ? 1 : 0);
			fMore = b != 0;
			return result;
		}
	}

	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static void SNIServerEnumClose(IntPtr handle)
	{
		((delegate* unmanaged[Cdecl, Cdecl]<void*, void>)global::<Module>.__unep@?SNIServerEnumClose@@$$J0YAXPEAX@Z)(handle.ToPointer());
	}

	[ResourceExposure(ResourceScope.None)]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	internal unsafe static uint SNIClose(IntPtr pConn)
	{
		//IL_0016: Expected I, but got I8
		delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, uint> _unep@?SNIClose@@$$J0YAKPEAVSNI_Conn@@@Z = (delegate* unmanaged[Cdecl, Cdecl]<SNI_Conn*, uint>)global::<Module>.__unep@?SNIClose@@$$J0YAKPEAVSNI_Conn@@@Z;
		SNI_ConnWrapper* ptr = (SNI_ConnWrapper*)pConn.ToPointer();
		uint result = _unep@?SNIClose@@$$J0YAKPEAVSNI_Conn@@@Z((SNI_Conn*)(*(ulong*)ptr));
		global::<Module>.SNI_ConnWrapper.__delDtor(ptr, 1u);
		return result;
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static uint SNIInitialize()
	{
		//IL_0007: Expected I, but got I8
		return global::<Module>.SNIInitialize(null);
	}

	[ResourceExposure(ResourceScope.None)]
	private unsafe static void MarshalConsumerInfo(ConsumerInfo consumerInfo, Sni_Consumer_Info* native_consumerInfo)
	{
		//IL_0019: Expected I, but got I8
		//IL_0036: Expected I8, but got I
		//IL_0047: Expected I, but got I8
		//IL_0064: Expected I8, but got I
		//IL_0074: Expected I8, but got I
		*(int*)native_consumerInfo = consumerInfo.defaultBufferSize;
		void* ptr = ((!(null == consumerInfo.readDelegate)) ? Marshal.GetFunctionPointerForDelegate((Delegate)consumerInfo.readDelegate).ToPointer() : null);
		*(long*)((ulong)(nint)native_consumerInfo + 16uL) = (nint)ptr;
		void* ptr2 = ((!(null == consumerInfo.writeDelegate)) ? Marshal.GetFunctionPointerForDelegate((Delegate)consumerInfo.writeDelegate).ToPointer() : null);
		*(long*)((ulong)(nint)native_consumerInfo + 24uL) = (nint)ptr2;
		*(long*)((ulong)(nint)native_consumerInfo + 8uL) = (nint)consumerInfo.key.ToPointer();
	}

	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIOpenSyncEx(ConsumerInfo consumerInfo, string constring, ref IntPtr pConn, byte[] spnBuffer, byte[] instanceName, [MarshalAs(UnmanagedType.U1)] bool fOverrideCache, [MarshalAs(UnmanagedType.U1)] bool fSync, int timeout, [MarshalAs(UnmanagedType.U1)] bool fParallel, int transparentNetworkResolutionStateNo, int totalTimeout, [MarshalAs(UnmanagedType.U1)] bool isAzureSqlServerEndpoint)
	{
		//IL_0034: Expected I, but got I8
		//IL_003b->IL0042: Incompatible stack types: I8 vs Ref
		System.Runtime.CompilerServices.Unsafe.SkipInit(out SNI_CLIENT_CONSUMER_INFO sNI_CLIENT_CONSUMER_INFO);
		global::<Module>.SNI_CLIENT_CONSUMER_INFO.{ctor}(&sNI_CLIENT_CONSUMER_INFO);
		ref byte reference = ref *(byte*)constring;
		if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference) != null)
		{
			reference = ref *(byte*)((ref *(?*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, ?>(ref reference)));
		}
		fixed (ushort* ptr2 = &System.Runtime.CompilerServices.Unsafe.As<byte, ushort>(ref reference))
		{
			byte condition = ((0L == (nint)pConn.ToPointer()) ? ((byte)1) : ((byte)0));
			Debug.Assert(condition != 0, "Verrifying variable is really not initallized.");
			SNI_ConnWrapper* ptr = null;
			fixed (byte* ptr3 = &(spnBuffer != null ? ref spnBuffer[0] : ref *(byte*)null))
			{
				fixed (byte* ptr4 = &instanceName[0])
				{
					MarshalConsumerInfo(consumerInfo, (Sni_Consumer_Info*)(&sNI_CLIENT_CONSUMER_INFO));
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, long>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 72)) = (nint)ptr2;
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 80)) = 0;
					if (spnBuffer != null)
					{
						System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, long>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 88)) = (nint)ptr3;
						System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 96)) = spnBuffer.Length;
					}
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, long>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 104)) = (nint)ptr4;
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 112)) = instanceName.Length;
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 116)) = (fOverrideCache ? 1 : 0);
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 120)) = (fSync ? 1 : 0);
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 124)) = timeout;
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 128)) = (fParallel ? 1 : 0);
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, bool>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 140)) = isAzureSqlServerEndpoint;
					switch (transparentNetworkResolutionStateNo)
					{
					case 2:
						System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, sbyte>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 132)) = 2;
						break;
					case 1:
						System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, sbyte>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 132)) = 1;
						break;
					case 0:
						System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, sbyte>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 132)) = 0;
						break;
					}
					System.Runtime.CompilerServices.Unsafe.As<SNI_CLIENT_CONSUMER_INFO, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_CLIENT_CONSUMER_INFO, 136)) = totalTimeout;
					uint result = global::<Module>.SNIOpenSyncExWrapper(&sNI_CLIENT_CONSUMER_INFO, &ptr);
					IntPtr intPtr = (IntPtr)ptr;
					pConn = intPtr;
					return result;
				}
			}
		}
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static uint SNIOpenMarsSession(ConsumerInfo consumerInfo, SafeHandle parent, ref IntPtr pConn, [MarshalAs(UnmanagedType.U1)] bool fSync)
	{
		//IL_0020: Expected I, but got I8
		//IL_0058: Expected I, but got I8
		uint result = 0u;
		System.Runtime.CompilerServices.Unsafe.SkipInit(out Sni_Consumer_Info sni_Consumer_Info);
		global::<Module>.Sni_Consumer_Info.{ctor}(&sni_Consumer_Info);
		System.Runtime.CompilerServices.Unsafe.SkipInit(out $ArrayType$$$BY08G $ArrayType$$$BY08G);
		// IL cpblk instruction
		System.Runtime.CompilerServices.Unsafe.CopyBlock(ref $ArrayType$$$BY08G, ref global::<Module>.??_C@_1BC@LEJJAHNB@?$AAs?$AAe?$AAs?$AAs?$AAi?$AAo?$AAn?$AA?3@, 18);
		MarshalConsumerInfo(consumerInfo, &sni_Consumer_Info);
		SNI_ConnWrapper* ptr = null;
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			parent.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			void* ptr2 = parent.DangerousGetHandle().ToPointer();
			result = global::<Module>.SNIOpenWrapper(&sni_Consumer_Info, (ushort*)(&$ArrayType$$$BY08G), (void*)(*(ulong*)ptr2), &ptr, fSync ? 1 : 0);
		}
		finally
		{
			if (success)
			{
				parent.DangerousRelease();
			}
		}
		IntPtr intPtr = (IntPtr)ptr;
		pConn = intPtr;
		return result;
	}

	[HandleProcessCorruptedStateExceptions]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static void SNIPacketAllocate(SafeHandle pConn, IOType ioType, ref IntPtr ret)
	{
		//IL_003d: Expected I, but got I8
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			SNI_ConnWrapper* ptr = (SNI_ConnWrapper*)pConn.DangerousGetHandle().ToPointer();
			RuntimeHelpers.PrepareConstrainedRegions();
			try
			{
			}
			finally
			{
				IntPtr intPtr = (IntPtr)SNIPacketAllocatePtr((SNI_Conn*)(*(ulong*)ptr), (SNI_Packet_IOType)ioType);
				ret = intPtr;
			}
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIPacketGetData(IntPtr packet, byte[] readBuffer, ref uint dataSize)
	{
		fixed (SNI_Packet* ptr = &System.Runtime.CompilerServices.Unsafe.AsRef<SNI_Packet>((SNI_Packet*)packet.ToPointer()))
		{
			fixed (byte* ptr2 = &readBuffer[0])
			{
				uint num = 0u;
				uint result = SNIPacketGetDataWrapperPtr(ptr, ptr2, (uint)readBuffer.Length, &num);
				dataSize = num;
				return result;
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[HandleProcessCorruptedStateExceptions]
	internal unsafe static void SNIPacketReset(SafeHandle pConn, IOType ioType, SafeHandle packet, ConsumerNumber consNum)
	{
		//IL_005b: Expected I, but got I8
		bool success = false;
		bool success2 = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			packet.DangerousAddRef(ref success2);
			Debug.Assert(success2, "AddRef Failed!");
			void* intPtr = pConn.DangerousGetHandle().ToPointer();
			SNI_Packet* ptr = (SNI_Packet*)packet.DangerousGetHandle().ToPointer();
			SNIPacketResetPtr((SNI_Conn*)(*(ulong*)intPtr), (SNI_Packet_IOType)ioType, ptr, (ConsumerNum)consNum);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
			if (success2)
			{
				packet.DangerousRelease();
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	internal unsafe static void SNIPacketRelease(IntPtr packet)
	{
		fixed (SNI_Packet* ptr = &System.Runtime.CompilerServices.Unsafe.AsRef<SNI_Packet>((SNI_Packet*)packet.ToPointer()))
		{
			SNIPacketReleasePtr(ptr);
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[HandleProcessCorruptedStateExceptions]
	internal unsafe static void SNIPacketSetData(SafeHandle packet, byte[] data, int length, SecureString[] passwords, int[] passwordOffsets)
	{
		//IL_00b3: Expected I, but got I8
		//IL_00d0: Expected I, but got I8
		//IL_00d7: Expected I, but got I8
		byte condition = (byte)((passwords == null || (passwordOffsets != null && (nint)passwords.LongLength == (nint)passwordOffsets.LongLength)) ? 1 : 0);
		Debug.Assert(condition != 0, "The number of passwords does not match the number of password offsets");
		fixed (byte* ptr3 = &data[0])
		{
			bool success = false;
			bool flag = false;
			IntPtr intPtr = IntPtr.Zero;
			RuntimeHelpers.PrepareConstrainedRegions();
			try
			{
				if (passwords != null)
				{
					for (int i = 0; i < (nint)passwords.LongLength; i++)
					{
						if (passwords[i] == null)
						{
							continue;
						}
						RuntimeHelpers.PrepareConstrainedRegions();
						try
						{
							intPtr = Marshal.SecureStringToCoTaskMemUnicode(passwords[i]);
							ushort* ptr = (ushort*)intPtr.ToPointer();
							byte* ptr2 = (byte*)intPtr.ToPointer();
							int length2 = passwords[i].Length;
							for (int j = 0; j < length2; j++)
							{
								int num = *ptr;
								byte b = (byte)num;
								byte b2 = (byte)(num >> 8);
								*ptr2 = (byte)(((byte)((uint)(b << 4) & 0xF0u) | ((uint)b >> 4)) ^ 0xA5);
								ptr2 = (byte*)((ulong)(nint)ptr2 + 1uL);
								*ptr2 = (byte)(((byte)((uint)(b2 << 4) & 0xF0u) | ((uint)b2 >> 4)) ^ 0xA5);
								ptr2 = (byte*)((ulong)(nint)ptr2 + 1uL);
								ptr = (ushort*)((ulong)(nint)ptr + 2uL);
							}
							flag = true;
							Marshal.Copy(intPtr, data, passwordOffsets[i], length2 * 2);
						}
						finally
						{
							if (intPtr != IntPtr.Zero)
							{
								Marshal.ZeroFreeCoTaskMemUnicode(intPtr);
							}
						}
					}
				}
				packet.DangerousAddRef(ref success);
				Debug.Assert(success, "AddRef Failed!");
				IntPtr intPtr2 = packet.DangerousGetHandle();
				SNIPacketSetDataPtr((SNI_Packet*)intPtr2.ToPointer(), ptr3, (uint)length);
			}
			finally
			{
				if (success)
				{
					packet.DangerousRelease();
				}
				if (flag)
				{
					for (int k = 0; k < (nint)data.LongLength; k++)
					{
						data[k] = 0;
					}
				}
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static int SNIQueryInfo(QTypes qType, ref IntPtr qInfo)
	{
		byte condition = ((qType == QTypes.SNI_QUERY_LOCALDB_HMODULE) ? ((byte)1) : ((byte)0));
		Debug.Assert(condition != 0, "qType is unsupported or unknown");
		fixed (IntPtr* ptr = &qInfo)
		{
			return (int)global::<Module>.SNIQueryInfo((uint)qType, ptr);
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static int SNIQueryInfo(QTypes qType, ref uint qInfo)
	{
		uint num = qInfo;
		byte condition = (byte)((qType == QTypes.SNI_QUERY_CLIENT_ENCRYPT_POSSIBLE || qType == QTypes.SNI_QUERY_SERVER_ENCRYPT_POSSIBLE || qType == QTypes.SNI_QUERY_TCP_SKIP_IO_COMPLETION_ON_SUCCESS) ? 1 : 0);
		Debug.Assert(condition != 0, "qType is unsupported or unknown");
		uint result = global::<Module>.SNIQueryInfo((uint)qType, &num);
		qInfo = num;
		return (int)result;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNISetInfo(SafeHandle pConn, QTypes qtype, ref uint qInfo)
	{
		//IL_0034: Expected I, but got I8
		uint num = qInfo;
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		uint result;
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			result = global::<Module>.SNISetInfo((SNI_Conn*)(*(ulong*)pConn.DangerousGetHandle().ToPointer()), (uint)qtype, &num);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
		qInfo = num;
		return result;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SniGetConnectionId(SafeHandle pConn, ref Guid connId)
	{
		//IL_0033: Expected I, but got I8
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		uint num;
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			System.Runtime.CompilerServices.Unsafe.SkipInit(out _GUID gUID);
			num = global::<Module>.SNIGetInfo((SNI_Conn*)(*(ulong*)pConn.DangerousGetHandle().ToPointer()), 9u, &gUID);
			if (0 == num)
			{
				Guid guid = global::<Module>.?A0x9ea9c69e.FromGUID(&gUID);
				connId = guid;
			}
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
		return num;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIReadAsync(SafeHandle pConn, ref IntPtr packet)
	{
		//IL_0003: Expected I, but got I8
		SNI_Packet* ptr = null;
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		uint result;
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			IntPtr intPtr = pConn.DangerousGetHandle();
			result = SNIReadAsyncWrapperPtr((SNI_ConnWrapper*)intPtr.ToPointer(), &ptr);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
		IntPtr intPtr2 = (IntPtr)ptr;
		packet = intPtr2;
		return result;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIReadSyncOverAsync(SafeHandle pConn, ref IntPtr packet, int timeout)
	{
		//IL_0003: Expected I, but got I8
		SNI_Packet* ptr = null;
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		uint result;
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			result = global::<Module>.SNIReadSyncOverAsync((SNI_ConnWrapper*)pConn.DangerousGetHandle().ToPointer(), &ptr, timeout);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
		IntPtr intPtr = (IntPtr)ptr;
		packet = intPtr;
		return result;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNICheckConnection(SafeHandle pConn)
	{
		//IL_0033: Expected I, but got I8
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			IntPtr intPtr = pConn.DangerousGetHandle();
			return SNICheckConnectionPtr((SNI_Conn*)(*(ulong*)intPtr.ToPointer()));
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	internal unsafe static uint SNITerminate()
	{
		return ((delegate* unmanaged[Cdecl, Cdecl]<uint>)global::<Module>.__unep@?SNITerminate@@$$J0YAKXZ)();
	}

	[ResourceExposure(ResourceScope.None)]
	[HandleProcessCorruptedStateExceptions]
	internal unsafe static uint SNIWritePacket(SafeHandle pConn, SafeHandle packet, [MarshalAs(UnmanagedType.U1)] bool sync)
	{
		bool success = false;
		bool success2 = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			packet.DangerousAddRef(ref success2);
			Debug.Assert(success2, "AddRef Failed!");
			SNI_ConnWrapper* ptr = (SNI_ConnWrapper*)pConn.DangerousGetHandle().ToPointer();
			SNI_Packet* ptr2 = (SNI_Packet*)packet.DangerousGetHandle().ToPointer();
			if (sync)
			{
				return global::<Module>.SNIWriteSyncOverAsync(ptr, ptr2);
			}
			return SNIWriteAsyncWrapperPtr(ptr, ptr2);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
			if (success2)
			{
				packet.DangerousRelease();
			}
		}
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIAddProvider(SafeHandle pConn, ProviderEnum providerEnum, ref uint info)
	{
		//IL_0038: Expected I, but got I8
		//IL_0047: Expected I, but got I8
		uint num = info;
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		uint num2;
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			SNI_ConnWrapper* ptr = (SNI_ConnWrapper*)pConn.DangerousGetHandle().ToPointer();
			num2 = global::<Module>.SNIAddProvider((SNI_Conn*)(*(ulong*)ptr), (ProviderNum)providerEnum, &num);
			if (num2 == 0)
			{
				System.Runtime.CompilerServices.Unsafe.SkipInit(out int num3);
				num2 = global::<Module>.SNIGetInfo((SNI_Conn*)(*(ulong*)ptr), 34u, &num3);
				byte condition = ((num2 == 0) ? ((byte)1) : ((byte)0));
				Debug.Assert(condition != 0, "SNIGetInfo cannot fail with this QType");
				int num4 = ((num3 != 0) ? 1 : 0);
				*(sbyte*)((ulong)(nint)ptr + 1226uL) = (sbyte)num4;
			}
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
		info = num;
		return num2;
	}

	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static uint SNIRemoveProvider(SafeHandle pConn, ProviderEnum providerEnum)
	{
		//IL_002f: Expected I, but got I8
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			return global::<Module>.SNIRemoveProvider((SNI_Conn*)(*(ulong*)pConn.DangerousGetHandle().ToPointer()), (ProviderNum)providerEnum);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	internal unsafe static void SNIGetLastError(SNI_Error error)
	{
		//IL_0073: Expected I, but got I8
		//IL_008e: Expected I, but got I8
		System.Runtime.CompilerServices.Unsafe.SkipInit(out SNI_ERROR sNI_ERROR);
		global::<Module>.SNIGetLastError(&sNI_ERROR);
		error.provider = *(ProviderEnum*)(&sNI_ERROR);
		error.errorMessage = new char[261];
		int num = 0;
		long num2 = (nint)System.Runtime.CompilerServices.Unsafe.AsPointer(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 4));
		do
		{
			ref char reference = ref error.errorMessage[num];
			reference = *(char*)num2;
			num++;
			num2 += 2;
		}
		while (num < 261);
		error.nativeError = System.Runtime.CompilerServices.Unsafe.As<SNI_ERROR, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 528));
		error.sniError = System.Runtime.CompilerServices.Unsafe.As<SNI_ERROR, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 532));
		IntPtr ptr = (IntPtr)(void*)System.Runtime.CompilerServices.Unsafe.As<SNI_ERROR, ulong>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 536));
		error.fileName = Marshal.PtrToStringUni(ptr);
		IntPtr ptr2 = (IntPtr)(void*)System.Runtime.CompilerServices.Unsafe.As<SNI_ERROR, ulong>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 544));
		error.function = Marshal.PtrToStringUni(ptr2);
		error.lineNumber = System.Runtime.CompilerServices.Unsafe.As<SNI_ERROR, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref sNI_ERROR, 552));
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static uint SNISecInitPackage(ref uint maxLength)
	{
		uint num = maxLength;
		uint result = global::<Module>.SNISecInitPackage(&num);
		maxLength = num;
		return result;
	}

	[ResourceExposure(ResourceScope.None)]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	[HandleProcessCorruptedStateExceptions]
	internal unsafe static uint SNISecGenClientContext(SafeHandle pConnectionObject, byte[] inBuff, uint receivedLength, byte[] OutBuff, ref uint sendLength, byte[] serverUserName)
	{
		//IL_0071: Expected I, but got I8
		//IL_0071: Expected I, but got I8
		//IL_0071: Expected I, but got I8
		//IL_000c->IL0013: Incompatible stack types: I8 vs Ref
		uint num = sendLength;
		fixed (byte* ptr = &(inBuff != null ? ref inBuff[0] : ref *(byte*)null))
		{
			fixed (byte* ptr2 = &OutBuff[0])
			{
				fixed (byte* ptr3 = &serverUserName[0])
				{
					bool success = false;
					RuntimeHelpers.PrepareConstrainedRegions();
					uint result;
					try
					{
						pConnectionObject.DangerousAddRef(ref success);
						Debug.Assert(success, "AddRef Failed!");
						void* intPtr = pConnectionObject.DangerousGetHandle().ToPointer();
						int num2 = ((serverUserName != null) ? serverUserName.Length : 0);
						System.Runtime.CompilerServices.Unsafe.SkipInit(out int num3);
						result = global::<Module>.SNISecGenClientContext((SNI_Conn*)(*(ulong*)intPtr), ptr, receivedLength, ptr2, &num, &num3, (ushort*)ptr3, (uint)num2, null, null);
					}
					finally
					{
						if (success)
						{
							pConnectionObject.DangerousRelease();
						}
					}
					sendLength = num;
					return result;
				}
			}
		}
	}

	[ResourceExposure(ResourceScope.None)]
	[HandleProcessCorruptedStateExceptions]
	[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
	internal unsafe static uint SNIWaitForSSLHandshakeToComplete(SafeHandle pConn, int timeoutMilliseconds)
	{
		//IL_002f: Expected I, but got I8
		bool success = false;
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
			pConn.DangerousAddRef(ref success);
			Debug.Assert(success, "AddRef Failed!");
			return global::<Module>.SNIWaitForSSLHandshakeToComplete((SNI_Conn*)(*(ulong*)pConn.DangerousGetHandle().ToPointer()), (uint)timeoutMilliseconds);
		}
		finally
		{
			if (success)
			{
				pConn.DangerousRelease();
			}
		}
	}
}
[CLSCompliant(false)]
internal class Win32NativeMethods
{
	[ResourceExposure(ResourceScope.None)]
	[return: MarshalAs(UnmanagedType.U1)]
	internal unsafe static bool IsTokenRestrictedWrapper(IntPtr token)
	{
		int num = 0;
		uint num2 = global::<Module>.UnmanagedIsTokenRestricted(token.ToPointer(), &num);
		if (0 != num2)
		{
			Marshal.ThrowExceptionForHR(((int)num2 > 0) ? ((int)(num2 & 0xFFFF) | -2147024896) : ((int)num2));
		}
		return (byte)((num != 0) ? 1u : 0u) != 0;
	}
}
[CLSCompliant(false)]
internal class NativeOledbWrapper
{
	internal static int SizeOfPROPVARIANT = 24;

	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static int IChapteredRowsetReleaseChapter(IntPtr ptr, IntPtr chapter)
	{
		//IL_0011: Expected I8, but got I
		//IL_0014: Expected I, but got I8
		//IL_0033: Expected I, but got I8
		//IL_0049: Expected I, but got I8
		//IL_0057: Expected I, but got I8
		int num = -2147418113;
		uint num2 = 0u;
		ulong num3 = (ulong)(nint)chapter.ToPointer();
		IChapteredRowset* ptr2 = null;
		IUnknown* ptr3 = (IUnknown*)ptr.ToPointer();
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
		}
		finally
		{
			num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, _GUID*, void**, int>)(*(ulong*)(*(ulong*)ptr3)))((nint)ptr3, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::<Module>.IID_IChapteredRowset), (void**)(&ptr2));
			if (0L != (nint)ptr2)
			{
				num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, ulong, uint*, int>)(*(ulong*)(*(long*)ptr2 + 32)))((nint)ptr2, num3, &num2);
				IChapteredRowset* intPtr = ptr2;
				((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)intPtr + 16)))((nint)intPtr);
			}
		}
		return num;
	}

	[ResourceExposure(ResourceScope.None)]
	[HandleProcessCorruptedStateExceptions]
	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	internal unsafe static int ITransactionAbort(IntPtr ptr)
	{
		//IL_0009: Expected I, but got I8
		//IL_0028: Expected I, but got I8
		//IL_003f: Expected I, but got I8
		//IL_003f: Expected I, but got I8
		//IL_004d: Expected I, but got I8
		int num = -2147418113;
		ITransactionLocal* ptr2 = null;
		IUnknown* ptr3 = (IUnknown*)ptr.ToPointer();
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
		}
		finally
		{
			num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, _GUID*, void**, int>)(*(ulong*)(*(ulong*)ptr3)))((nint)ptr3, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::<Module>.IID_ITransactionLocal), (void**)(&ptr2));
			if (0L != (nint)ptr2)
			{
				num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, BOID*, int, int, int>)(*(ulong*)(*(long*)ptr2 + 32)))((nint)ptr2, null, 0, 0);
				ITransactionLocal* intPtr = ptr2;
				((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)intPtr + 16)))((nint)intPtr);
			}
		}
		return num;
	}

	[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
	[HandleProcessCorruptedStateExceptions]
	[ResourceExposure(ResourceScope.None)]
	internal unsafe static int ITransactionCommit(IntPtr ptr)
	{
		//IL_0009: Expected I, but got I8
		//IL_0028: Expected I, but got I8
		//IL_003e: Expected I, but got I8
		//IL_004c: Expected I, but got I8
		int num = -2147418113;
		ITransactionLocal* ptr2 = null;
		IUnknown* ptr3 = (IUnknown*)ptr.ToPointer();
		RuntimeHelpers.PrepareConstrainedRegions();
		try
		{
		}
		finally
		{
			num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, _GUID*, void**, int>)(*(ulong*)(*(ulong*)ptr3)))((nint)ptr3, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::<Module>.IID_ITransactionLocal), (void**)(&ptr2));
			if (0L != (nint)ptr2)
			{
				num = ((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, int, uint, uint, int>)(*(ulong*)(*(long*)ptr2 + 24)))((nint)ptr2, 0, 2u, 0u);
				ITransactionLocal* intPtr = ptr2;
				((delegate* unmanaged[Cdecl, Cdecl]<IntPtr, uint>)(*(ulong*)(*(long*)intPtr + 16)))((nint)intPtr);
			}
		}
		return num;
	}

	[ResourceExposure(ResourceScope.None)]
	[return: MarshalAs(UnmanagedType.U1)]
	internal unsafe static bool MemoryCompare(IntPtr buf1, IntPtr buf2, int count)
	{
		//IL_00bd: Expected I8, but got I
		//IL_00d0: Expected I, but got I8
		Debug.Assert(buf1 != buf2, "buf1 and buf2 are the same");
		byte condition = (byte)((buf1.ToInt64() < buf2.ToInt64() || buf2.ToInt64() + count <= buf1.ToInt64()) ? 1 : 0);
		Debug.Assert(condition != 0, "overlapping region buf1");
		byte condition2 = (byte)((buf2.ToInt64() < buf1.ToInt64() || buf1.ToInt64() + count <= buf2.ToInt64()) ? 1 : 0);
		Debug.Assert(condition2 != 0, "overlapping region buf2");
		byte condition3 = (byte)((0 <= count) ? 1 : 0);
		Debug.Assert(condition3 != 0, "negative count");
		ulong num = (ulong)count;
		void* ptr = buf2.ToPointer();
		void* ptr2 = buf1.ToPointer();
		if (num == 0L)
		{
			goto IL_00e2;
		}
		byte b = *(byte*)ptr2;
		byte b2 = *(byte*)ptr;
		if ((uint)b >= (uint)b2)
		{
			long num2 = (nint)((byte*)ptr2 - (nuint)ptr);
			while ((uint)b <= (uint)b2)
			{
				if (num != 1)
				{
					num--;
					ptr = (void*)((ulong)(nint)ptr + 1uL);
					b = *(byte*)(num2 + (nint)ptr);
					b2 = *(byte*)ptr;
					if ((uint)b < (uint)b2)
					{
						break;
					}
					continue;
				}
				goto IL_00e2;
			}
		}
		int num3 = 1;
		goto IL_00e5;
		IL_00e5:
		return (byte)num3 != 0;
		IL_00e2:
		num3 = 0;
		goto IL_00e5;
	}

	[ResourceExposure(ResourceScope.None)]
	internal unsafe static void MemoryCopy(IntPtr dst, IntPtr src, int count)
	{
		//IL_00a2: Expected I4, but got I8
		Debug.Assert(dst != src, "dst and src are the same");
		byte condition = (byte)((dst.ToInt64() < src.ToInt64() || src.ToInt64() + count <= dst.ToInt64()) ? 1 : 0);
		Debug.Assert(condition != 0, "overlapping region dst");
		byte condition2 = (byte)((src.ToInt64() < dst.ToInt64() || dst.ToInt64() + count <= src.ToInt64()) ? 1 : 0);
		Debug.Assert(condition2 != 0, "overlapping region src");
		byte condition3 = (byte)((0 <= count) ? 1 : 0);
		Debug.Assert(condition3 != 0, "negative count");
		// IL cpblk instruction
		System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(dst.ToPointer(), src.ToPointer(), count);
	}
}
internal class AdalException : Exception
{
	private readonly uint _category;

	private readonly uint _status;

	private readonly uint _state;

	internal AdalException(string message, uint category, uint status, uint state)
		: base(message)
	{
		_category = category;
		_status = status;
		_state = state;
	}

	internal uint GetCategory()
	{
		return _category;
	}

	internal uint GetStatus()
	{
		return _status;
	}

	internal uint GetState()
	{
		return _state;
	}
}
internal class ADALNativeWrapper
{
	private unsafe static _GUID ToGUID(System.ValueType guid)
	{
		fixed (byte* ptr = &((Guid)guid).ToByteArray()[0])
		{
			System.Runtime.CompilerServices.Unsafe.SkipInit(out _GUID result);
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(ref result, ptr, 16);
			return result;
		}
	}

	internal static int ADALInitialize()
	{
		return (int)global::<Module>.SNISecADALInitialize();
	}

	private unsafe static byte[] ADALGetAccessToken(string username, IntPtr password, string stsURL, string servicePrincipalName, System.ValueType correlationId, string clientId, bool* fWindowsIntegrated, ref long fileTime)
	{
		//IL_00a3: Expected I, but got I8
		//IL_0108: Expected I, but got I8
		//IL_010b: Expected I, but got I8
		//IL_0120: Expected I4, but got I8
		//The blocks IL_00c7, IL_00ce, IL_00d9, IL_00de, IL_00e4, IL_00ef, IL_00f5, IL_00f9, IL_0102, IL_0107 are reachable both inside and outside the pinned region starting at IL_00bc. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
		byte condition = (byte)((username != null || *fWindowsIntegrated) ? 1 : 0);
		Debug.Assert(condition != 0, "User name is null and its not windows integrated authentication.");
		byte condition2 = (byte)((password != IntPtr.Zero || *fWindowsIntegrated) ? 1 : 0);
		Debug.Assert(condition2 != 0, "Password is null and its not windows integrated authentication.");
		Debug.Assert(stsURL != null, "stsURL is null.");
		Debug.Assert(servicePrincipalName != null, "ServicePrincipalName is null.");
		Debug.Assert(clientId != null, "Ado ClientId is null.");
		byte condition3 = (byte)((correlationId != (object)Guid.Empty) ? 1 : 0);
		Debug.Assert(condition3 != 0, "CorrelationId is Guid::Empty.");
		/*pinned*/ref ushort reference = ref *(ushort*)null;
		ushort* ptr = null;
		ushort* ptr2;
		ushort* ptr3;
		uint num;
		uint num2;
		uint status;
		uint state;
		System.Runtime.CompilerServices.Unsafe.SkipInit(out _FILETIME fILETIME);
		_GUID gUID;
		string message;
		byte num4;
		ref byte reference3;
		if (!(*fWindowsIntegrated))
		{
			ref byte reference2 = ref *(byte*)username;
			if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference2) != null)
			{
				reference2 = ref *(byte*)((ref *(?*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, ?>(ref reference2)));
			}
			fixed (ushort* ptr4 = &System.Runtime.CompilerServices.Unsafe.As<byte, ushort>(ref reference2))
			{
				ptr = (ushort*)password.ToPointer();
				reference3 = ref *(byte*)stsURL;
				if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference3) != null)
				{
					reference3 = ref *(byte*)((ref *(?*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, ?>(ref reference3)));
				}
				fixed (ushort* ptr5 = &System.Runtime.CompilerServices.Unsafe.As<byte, ushort>(ref reference3))
				{
					ref byte reference4 = ref *(byte*)servicePrincipalName;
					if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference4) != null)
					{
						reference4 = ref *(byte*)((ref *(?*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, ?>(ref reference4)));
					}
					fixed (ushort* ptr6 = &System.Runtime.CompilerServices.Unsafe.As<byte, ushort>(ref reference4))
					{
						ref byte reference5 = ref *(byte*)clientId;
						if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference5) != null)
						{
							reference5 = ref *(byte*)((ref *(?*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, ?>(ref reference5)));
						}
						fixed (ushort* ptr7 = &System.Runtime.CompilerServices.Unsafe.As<byte, ushort>(ref reference5))
						{
							ptr2 = null;
							ptr3 = null;
							num = 0u;
							num2 = 0u;
							status = 0u;
							state = 0u;
							// IL initblk instruction
							System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(ref fILETIME, 0, 8);
							gUID = ToGUID(correlationId);
							try
							{
								uint num3 = global::<Module>.SNISecADALGetAccessToken(ptr4, ptr, ptr5, ptr6, &gUID, ptr7, fWindowsIntegrated, &ptr2, &num, &ptr3, &num2, &status, &state, &fILETIME);
								if (num3 != 0)
								{
									by

FuriousButtplug/System.Numerics.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level2, SkipVerificationInFullTrust = true)]
[assembly: AssemblyTitle("System.Numerics.dll")]
[assembly: AssemblyDescription("System.Numerics.dll")]
[assembly: AssemblyDefaultAlias("System.Numerics.dll")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.8.9037.0")]
[assembly: AssemblyInformationalVersion("4.8.9037.0")]
[assembly: SatelliteContractVersion("4.0.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("f:\\dd\\tools\\devdiv\\EcmaPublicKey.snk")]
[assembly: AssemblySignatureKey("002400000c800000140100000602000000240000525341310008000001000100613399aff18ef1a2c2514a273a42d9042b72321f1757102df9ebada69923e2738406c21e5b801552ab8d200a65a235e001ac9adc25f2d811eb09496a4c6a59d4619589c69f5baf0c4179a47311d92555cd006acc8b5959f2bd6e10e360c34537a1d266da8085856583c85d81da7f3ec01ed9564c58d93d713cd0172c8e23a10f0239b80c96b07736f5d8b022542a4e74251a5f432824318b3539a5a087f8e53d2f135f9ca47f3bb2e10aff0af0849504fb7cea3ff192dc8de0edad64c68efde34c56d302ad55fd6e80f302d5efcdeae953658d3452561b5f36c542efdbdd9f888538d374cef106acf7d93a4445c3c73cd911f0571aaf3d54da12b11ddec375b3", "a5a866e1ee186f807668209f3b11236ace5e21f117803a3143abb126dd035d7d2f876b6938aaf2ee3414d5420d753621400db44a49c486ce134300a2106adb6bdb433590fef8ad5c43cba82290dc49530effd86523d9483c00f458af46890036b0e2c61d077d7fbac467a506eba29e467a87198b053c749aa2a4d2840c784e6d")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.0.0")]
[module: UnverifiableCode]
internal static class FXAssembly
{
	internal const string Version = "4.0.0.0";
}
internal static class ThisAssembly
{
	internal const string Title = "System.Numerics.dll";

	internal const string Description = "System.Numerics.dll";

	internal const string DefaultAlias = "System.Numerics.dll";

	internal const string Copyright = "© Microsoft Corporation.  All rights reserved.";

	internal const string Version = "4.0.0.0";

	internal const string InformationalVersion = "4.8.9037.0";

	internal const string DailyBuildNumberStr = "30319";

	internal const string BuildRevisionStr = "0";

	internal const int DailyBuildNumber = 30319;
}
internal static class AssemblyRef
{
	internal const string EcmaPublicKey = "b77a5c561934e089";

	internal const string EcmaPublicKeyToken = "b77a5c561934e089";

	internal const string EcmaPublicKeyFull = "00000000000000000400000000000000";

	internal const string SilverlightPublicKey = "31bf3856ad364e35";

	internal const string SilverlightPublicKeyToken = "31bf3856ad364e35";

	internal const string SilverlightPublicKeyFull = "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9";

	internal const string SilverlightPlatformPublicKey = "7cec85d7bea7798e";

	internal const string SilverlightPlatformPublicKeyToken = "7cec85d7bea7798e";

	internal const string SilverlightPlatformPublicKeyFull = "00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB";

	internal const string PlatformPublicKey = "b77a5c561934e089";

	internal const string PlatformPublicKeyToken = "b77a5c561934e089";

	internal const string PlatformPublicKeyFull = "00000000000000000400000000000000";

	internal const string Mscorlib = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemData = "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemDataOracleClient = "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string System = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemCore = "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemNumerics = "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemRuntimeRemoting = "System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemThreadingTasksDataflow = "System.Threading.Tasks.Dataflow, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemWindowsForms = "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemXml = "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string MicrosoftPublicKey = "b03f5f7f11d50a3a";

	internal const string MicrosoftPublicKeyToken = "b03f5f7f11d50a3a";

	internal const string MicrosoftPublicKeyFull = "002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293";

	internal const string SharedLibPublicKey = "31bf3856ad364e35";

	internal const string SharedLibPublicKeyToken = "31bf3856ad364e35";

	internal const string SharedLibPublicKeyFull = "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9";

	internal const string SystemComponentModelDataAnnotations = "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemConfiguration = "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemConfigurationInstall = "System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDeployment = "System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDesign = "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDirectoryServices = "System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDrawingDesign = "System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDrawing = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemEnterpriseServices = "System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemManagement = "System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemMessaging = "System.Messaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemNetHttp = "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemNetHttpWebRequest = "System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemRuntimeSerializationFormattersSoap = "System.Runtime.Serialization.Formatters.Soap, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemRuntimeWindowsRuntime = "System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemRuntimeWindowsRuntimeUIXaml = "System.Runtime.WindowsRuntimeUIXaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemSecurity = "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemServiceModelWeb = "System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemServiceProcess = "System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWeb = "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebAbstractions = "System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebDynamicData = "System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebDynamicDataDesign = "System.Web.DynamicData.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebEntityDesign = "System.Web.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemWebExtensions = "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebExtensionsDesign = "System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebMobile = "System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebRegularExpressions = "System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebRouting = "System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebServices = "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string WindowsBase = "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string MicrosoftVisualStudio = "Microsoft.VisualStudio, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVisualStudioWindowsForms = "Microsoft.VisualStudio.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string VJSharpCodeProvider = "VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string ASPBrowserCapsPublicKey = "b7bd7678b977bd8f";

	internal const string ASPBrowserCapsFactory = "ASP.BrowserCapsFactory, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7bd7678b977bd8f";

	internal const string MicrosoftVSDesigner = "Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVisualStudioWeb = "Microsoft.VisualStudio.Web, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftWebDesign = "Microsoft.Web.Design.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVSDesignerMobile = "Microsoft.VSDesigner.Mobile, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftJScript = "Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
}
namespace System
{
	internal sealed class SR
	{
		internal const string Argument_InvalidNumberStyles = "Argument_InvalidNumberStyles";

		internal const string Argument_InvalidHexStyle = "Argument_InvalidHexStyle";

		internal const string Argument_MustBeBigInt = "Argument_MustBeBigInt";

		internal const string Format_InvalidFormatSpecifier = "Format_InvalidFormatSpecifier";

		internal const string Format_TooLarge = "Format_TooLarge";

		internal const string ArgumentOutOfRange_MustBeNonNeg = "ArgumentOutOfRange_MustBeNonNeg";

		internal const string Overflow_BigIntInfinity = "Overflow_BigIntInfinity";

		internal const string Overflow_NotANumber = "Overflow_NotANumber";

		internal const string Overflow_ParseBigInteger = "Overflow_ParseBigInteger";

		internal const string Overflow_Int32 = "Overflow_Int32";

		internal const string Overflow_Int64 = "Overflow_Int64";

		internal const string Overflow_UInt32 = "Overflow_UInt32";

		internal const string Overflow_UInt64 = "Overflow_UInt64";

		internal const string Overflow_Decimal = "Overflow_Decimal";

		internal const string Arg_ArgumentOutOfRangeException = "Arg_ArgumentOutOfRangeException";

		internal const string Arg_ElementsInSourceIsGreaterThanDestination = "Arg_ElementsInSourceIsGreaterThanDestination";

		internal const string Arg_MultiDimArrayNotSupported = "Arg_MultiDimArrayNotSupported";

		internal const string Arg_RegisterLengthOfRangeException = "Arg_RegisterLengthOfRangeException";

		internal const string Arg_NullArgumentNullRef = "Arg_NullArgumentNullRef";

		private static System.SR loader;

		private ResourceManager resources;

		private static CultureInfo Culture => null;

		public static ResourceManager Resources => GetLoader().resources;

		internal SR()
		{
			resources = new ResourceManager("System.Numerics", GetType().Assembly);
		}

		private static System.SR GetLoader()
		{
			if (loader == null)
			{
				System.SR value = new System.SR();
				Interlocked.CompareExchange(ref loader, value, null);
			}
			return loader;
		}

		public static string GetString(string name, params object[] args)
		{
			System.SR sR = GetLoader();
			if (sR == null)
			{
				return null;
			}
			string @string = sR.resources.GetString(name, Culture);
			if (args != null && args.Length != 0)
			{
				for (int i = 0; i < args.Length; i++)
				{
					if (args[i] is string text && text.Length > 1024)
					{
						args[i] = text.Substring(0, 1021) + "...";
					}
				}
				return string.Format(CultureInfo.CurrentCulture, @string, args);
			}
			return @string;
		}

		public static string GetString(string name)
		{
			return GetLoader()?.resources.GetString(name, Culture);
		}

		public static string GetString(string name, out bool usedFallback)
		{
			usedFallback = false;
			return GetString(name);
		}

		public static object GetObject(string name)
		{
			return GetLoader()?.resources.GetObject(name, Culture);
		}
	}
}
namespace System.Numerics
{
	[Serializable]
	[__DynamicallyInvokable]
	public struct BigInteger : IFormattable, IComparable, IComparable<BigInteger>, IEquatable<BigInteger>
	{
		private const int knMaskHighBit = int.MinValue;

		private const uint kuMaskHighBit = 2147483648u;

		private const int kcbitUint = 32;

		private const int kcbitUlong = 64;

		private const int DecimalScaleFactorMask = 16711680;

		private const int DecimalSignMask = int.MinValue;

		internal int _sign;

		internal uint[] _bits;

		private static readonly BigInteger s_bnMinInt = new BigInteger(-1, new uint[1] { 2147483648u });

		private static readonly BigInteger s_bnOneInt = new BigInteger(1);

		private static readonly BigInteger s_bnZeroInt = new BigInteger(0);

		private static readonly BigInteger s_bnMinusOneInt = new BigInteger(-1);

		[__DynamicallyInvokable]
		public static BigInteger Zero
		{
			[__DynamicallyInvokable]
			get
			{
				return s_bnZeroInt;
			}
		}

		[__DynamicallyInvokable]
		public static BigInteger One
		{
			[__DynamicallyInvokable]
			get
			{
				return s_bnOneInt;
			}
		}

		[__DynamicallyInvokable]
		public static BigInteger MinusOne
		{
			[__DynamicallyInvokable]
			get
			{
				return s_bnMinusOneInt;
			}
		}

		[__DynamicallyInvokable]
		public bool IsPowerOfTwo
		{
			[__DynamicallyInvokable]
			get
			{
				if (_bits == null)
				{
					if ((_sign & (_sign - 1)) == 0)
					{
						return _sign != 0;
					}
					return false;
				}
				if (_sign != 1)
				{
					return false;
				}
				int num = Length(_bits) - 1;
				if ((_bits[num] & (_bits[num] - 1)) != 0)
				{
					return false;
				}
				while (--num >= 0)
				{
					if (_bits[num] != 0)
					{
						return false;
					}
				}
				return true;
			}
		}

		[__DynamicallyInvokable]
		public bool IsZero
		{
			[__DynamicallyInvokable]
			get
			{
				return _sign == 0;
			}
		}

		[__DynamicallyInvokable]
		public bool IsOne
		{
			[__DynamicallyInvokable]
			get
			{
				if (_sign == 1)
				{
					return _bits == null;
				}
				return false;
			}
		}

		[__DynamicallyInvokable]
		public bool IsEven
		{
			[__DynamicallyInvokable]
			get
			{
				if (_bits != null)
				{
					return (_bits[0] & 1) == 0;
				}
				return (_sign & 1) == 0;
			}
		}

		[__DynamicallyInvokable]
		public int Sign
		{
			[__DynamicallyInvokable]
			get
			{
				return (_sign >> 31) - (-_sign >> 31);
			}
		}

		internal int _Sign => _sign;

		internal uint[] _Bits => _bits;

		[Conditional("DEBUG")]
		private void AssertValid()
		{
			if (_bits != null)
			{
				Length(_bits);
				_ = 1;
			}
		}

		[__DynamicallyInvokable]
		public override bool Equals(object obj)
		{
			if (!(obj is BigInteger))
			{
				return false;
			}
			return Equals((BigInteger)obj);
		}

		[__DynamicallyInvokable]
		public override int GetHashCode()
		{
			if (_bits == null)
			{
				return _sign;
			}
			int num = _sign;
			int num2 = Length(_bits);
			while (--num2 >= 0)
			{
				num = NumericsHelpers.CombineHash(num, (int)_bits[num2]);
			}
			return num;
		}

		[__DynamicallyInvokable]
		public bool Equals(long other)
		{
			if (_bits == null)
			{
				return _sign == other;
			}
			int num;
			if ((_sign ^ other) < 0 || (num = Length(_bits)) > 2)
			{
				return false;
			}
			ulong num2 = (ulong)((other < 0) ? (-other) : other);
			if (num == 1)
			{
				return _bits[0] == num2;
			}
			return NumericsHelpers.MakeUlong(_bits[1], _bits[0]) == num2;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public bool Equals(ulong other)
		{
			if (_sign < 0)
			{
				return false;
			}
			if (_bits == null)
			{
				return (ulong)_sign == other;
			}
			int num = Length(_bits);
			if (num > 2)
			{
				return false;
			}
			if (num == 1)
			{
				return _bits[0] == other;
			}
			return NumericsHelpers.MakeUlong(_bits[1], _bits[0]) == other;
		}

		[__DynamicallyInvokable]
		public bool Equals(BigInteger other)
		{
			if (_sign != other._sign)
			{
				return false;
			}
			if (_bits == other._bits)
			{
				return true;
			}
			if (_bits == null || other._bits == null)
			{
				return false;
			}
			int num = Length(_bits);
			if (num != Length(other._bits))
			{
				return false;
			}
			int diffLength = GetDiffLength(_bits, other._bits, num);
			return diffLength == 0;
		}

		[__DynamicallyInvokable]
		public int CompareTo(long other)
		{
			if (_bits == null)
			{
				return ((long)_sign).CompareTo(other);
			}
			int num;
			if ((_sign ^ other) < 0 || (num = Length(_bits)) > 2)
			{
				return _sign;
			}
			ulong value = (ulong)((other < 0) ? (-other) : other);
			ulong num2 = ((num == 2) ? NumericsHelpers.MakeUlong(_bits[1], _bits[0]) : _bits[0]);
			return _sign * num2.CompareTo(value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public int CompareTo(ulong other)
		{
			if (_sign < 0)
			{
				return -1;
			}
			if (_bits == null)
			{
				return ((ulong)_sign).CompareTo(other);
			}
			int num = Length(_bits);
			if (num > 2)
			{
				return 1;
			}
			return ((num == 2) ? NumericsHelpers.MakeUlong(_bits[1], _bits[0]) : _bits[0]).CompareTo(other);
		}

		[__DynamicallyInvokable]
		public int CompareTo(BigInteger other)
		{
			if ((_sign ^ other._sign) < 0)
			{
				if (_sign >= 0)
				{
					return 1;
				}
				return -1;
			}
			if (_bits == null)
			{
				if (other._bits == null)
				{
					if (_sign >= other._sign)
					{
						if (_sign <= other._sign)
						{
							return 0;
						}
						return 1;
					}
					return -1;
				}
				return -other._sign;
			}
			int num;
			int num2;
			if (other._bits == null || (num = Length(_bits)) > (num2 = Length(other._bits)))
			{
				return _sign;
			}
			if (num < num2)
			{
				return -_sign;
			}
			int diffLength = GetDiffLength(_bits, other._bits, num);
			if (diffLength == 0)
			{
				return 0;
			}
			if (_bits[diffLength - 1] >= other._bits[diffLength - 1])
			{
				return _sign;
			}
			return -_sign;
		}

		public int CompareTo(object obj)
		{
			if (obj == null)
			{
				return 1;
			}
			if (!(obj is BigInteger))
			{
				throw new ArgumentException(System.SR.GetString("Argument_MustBeBigInt"));
			}
			return CompareTo((BigInteger)obj);
		}

		[__DynamicallyInvokable]
		public byte[] ToByteArray()
		{
			if (_bits == null && _sign == 0)
			{
				return new byte[1];
			}
			uint[] array;
			byte b;
			if (_bits == null)
			{
				array = new uint[1] { (uint)_sign };
				b = (byte)((_sign < 0) ? 255u : 0u);
			}
			else if (_sign == -1)
			{
				array = (uint[])_bits.Clone();
				NumericsHelpers.DangerousMakeTwosComplement(array);
				b = byte.MaxValue;
			}
			else
			{
				array = _bits;
				b = 0;
			}
			byte[] array2 = new byte[checked(4 * array.Length)];
			int num = 0;
			for (int i = 0; i < array.Length; i++)
			{
				uint num2 = array[i];
				for (int j = 0; j < 4; j++)
				{
					array2[num++] = (byte)(num2 & 0xFFu);
					num2 >>= 8;
				}
			}
			int num3 = array2.Length - 1;
			while (num3 > 0 && array2[num3] == b)
			{
				num3--;
			}
			bool flag = (array2[num3] & 0x80) != (b & 0x80);
			byte[] array3 = new byte[num3 + 1 + (flag ? 1 : 0)];
			Array.Copy(array2, array3, num3 + 1);
			if (flag)
			{
				array3[^1] = b;
			}
			return array3;
		}

		private uint[] ToUInt32Array()
		{
			if (_bits == null && _sign == 0)
			{
				return new uint[1];
			}
			uint[] array;
			uint num;
			if (_bits == null)
			{
				array = new uint[1] { (uint)_sign };
				num = ((_sign < 0) ? uint.MaxValue : 0u);
			}
			else if (_sign == -1)
			{
				array = (uint[])_bits.Clone();
				NumericsHelpers.DangerousMakeTwosComplement(array);
				num = uint.MaxValue;
			}
			else
			{
				array = _bits;
				num = 0u;
			}
			int num2 = array.Length - 1;
			while (num2 > 0 && array[num2] == num)
			{
				num2--;
			}
			bool flag = (array[num2] & 0x80000000u) != (num & 0x80000000u);
			uint[] array2 = new uint[num2 + 1 + (flag ? 1 : 0)];
			Array.Copy(array, array2, num2 + 1);
			if (flag)
			{
				array2[^1] = num;
			}
			return array2;
		}

		[__DynamicallyInvokable]
		public override string ToString()
		{
			return BigNumber.FormatBigInteger(this, null, NumberFormatInfo.CurrentInfo);
		}

		[__DynamicallyInvokable]
		public string ToString(IFormatProvider provider)
		{
			return BigNumber.FormatBigInteger(this, null, NumberFormatInfo.GetInstance(provider));
		}

		[__DynamicallyInvokable]
		public string ToString(string format)
		{
			return BigNumber.FormatBigInteger(this, format, NumberFormatInfo.CurrentInfo);
		}

		[__DynamicallyInvokable]
		public string ToString(string format, IFormatProvider provider)
		{
			return BigNumber.FormatBigInteger(this, format, NumberFormatInfo.GetInstance(provider));
		}

		[__DynamicallyInvokable]
		public BigInteger(int value)
		{
			if (value == int.MinValue)
			{
				this = s_bnMinInt;
				return;
			}
			_sign = value;
			_bits = null;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public BigInteger(uint value)
		{
			if (value <= int.MaxValue)
			{
				_sign = (int)value;
				_bits = null;
			}
			else
			{
				_sign = 1;
				_bits = new uint[1];
				_bits[0] = value;
			}
		}

		[__DynamicallyInvokable]
		public BigInteger(long value)
		{
			if (int.MinValue <= value && value <= int.MaxValue)
			{
				if (value == int.MinValue)
				{
					this = s_bnMinInt;
					return;
				}
				_sign = (int)value;
				_bits = null;
				return;
			}
			ulong num = 0uL;
			if (value < 0)
			{
				num = (ulong)(-value);
				_sign = -1;
			}
			else
			{
				num = (ulong)value;
				_sign = 1;
			}
			_bits = new uint[2];
			_bits[0] = (uint)num;
			_bits[1] = (uint)(num >> 32);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public BigInteger(ulong value)
		{
			if (value <= int.MaxValue)
			{
				_sign = (int)value;
				_bits = null;
				return;
			}
			_sign = 1;
			_bits = new uint[2];
			_bits[0] = (uint)value;
			_bits[1] = (uint)(value >> 32);
		}

		[__DynamicallyInvokable]
		public BigInteger(float value)
		{
			if (float.IsInfinity(value))
			{
				throw new OverflowException(System.SR.GetString("Overflow_BigIntInfinity"));
			}
			if (float.IsNaN(value))
			{
				throw new OverflowException(System.SR.GetString("Overflow_NotANumber"));
			}
			_sign = 0;
			_bits = null;
			SetBitsFromDouble(value);
		}

		[__DynamicallyInvokable]
		public BigInteger(double value)
		{
			if (double.IsInfinity(value))
			{
				throw new OverflowException(System.SR.GetString("Overflow_BigIntInfinity"));
			}
			if (double.IsNaN(value))
			{
				throw new OverflowException(System.SR.GetString("Overflow_NotANumber"));
			}
			_sign = 0;
			_bits = null;
			SetBitsFromDouble(value);
		}

		[__DynamicallyInvokable]
		public BigInteger(decimal value)
		{
			int[] bits = decimal.GetBits(decimal.Truncate(value));
			int num = 3;
			while (num > 0 && bits[num - 1] == 0)
			{
				num--;
			}
			switch (num)
			{
			case 0:
				this = s_bnZeroInt;
				return;
			case 1:
				if (bits[0] > 0)
				{
					_sign = bits[0];
					_sign *= (((bits[3] & int.MinValue) == 0) ? 1 : (-1));
					_bits = null;
					return;
				}
				break;
			}
			_bits = new uint[num];
			_bits[0] = (uint)bits[0];
			if (num > 1)
			{
				_bits[1] = (uint)bits[1];
			}
			if (num > 2)
			{
				_bits[2] = (uint)bits[2];
			}
			_sign = (((bits[3] & int.MinValue) == 0) ? 1 : (-1));
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public BigInteger(byte[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int num = value.Length;
			bool flag = num > 0 && (value[num - 1] & 0x80) == 128;
			while (num > 0 && value[num - 1] == 0)
			{
				num--;
			}
			if (num == 0)
			{
				_sign = 0;
				_bits = null;
				return;
			}
			if (num <= 4)
			{
				if (flag)
				{
					_sign = -1;
				}
				else
				{
					_sign = 0;
				}
				for (int num2 = num - 1; num2 >= 0; num2--)
				{
					_sign <<= 8;
					_sign |= value[num2];
				}
				_bits = null;
				if (_sign < 0 && !flag)
				{
					_bits = new uint[1];
					_bits[0] = (uint)_sign;
					_sign = 1;
				}
				if (_sign == int.MinValue)
				{
					this = s_bnMinInt;
				}
				return;
			}
			int num3 = num % 4;
			int num4 = num / 4 + ((num3 != 0) ? 1 : 0);
			bool flag2 = true;
			uint[] array = new uint[num4];
			int num5 = 3;
			int i;
			for (i = 0; i < num4 - ((num3 != 0) ? 1 : 0); i++)
			{
				for (int j = 0; j < 4; j++)
				{
					if (value[num5] != 0)
					{
						flag2 = false;
					}
					array[i] <<= 8;
					array[i] |= value[num5];
					num5--;
				}
				num5 += 8;
			}
			if (num3 != 0)
			{
				if (flag)
				{
					array[num4 - 1] = uint.MaxValue;
				}
				for (num5 = num - 1; num5 >= num - num3; num5--)
				{
					if (value[num5] != 0)
					{
						flag2 = false;
					}
					array[i] <<= 8;
					array[i] |= value[num5];
				}
			}
			if (flag2)
			{
				this = s_bnZeroInt;
			}
			else if (flag)
			{
				NumericsHelpers.DangerousMakeTwosComplement(array);
				int num6 = array.Length;
				while (num6 > 0 && array[num6 - 1] == 0)
				{
					num6--;
				}
				if (num6 == 1 && (int)array[0] > 0)
				{
					if (array[0] == 1)
					{
						this = s_bnMinusOneInt;
						return;
					}
					if (array[0] == 2147483648u)
					{
						this = s_bnMinInt;
						return;
					}
					_sign = -1 * (int)array[0];
					_bits = null;
				}
				else if (num6 != array.Length)
				{
					_sign = -1;
					_bits = new uint[num6];
					Array.Copy(array, _bits, num6);
				}
				else
				{
					_sign = -1;
					_bits = array;
				}
			}
			else
			{
				_sign = 1;
				_bits = array;
			}
		}

		internal BigInteger(int n, uint[] rgu)
		{
			_sign = n;
			_bits = rgu;
		}

		internal BigInteger(uint[] value, bool negative)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int num = value.Length;
			while (num > 0 && value[num - 1] == 0)
			{
				num--;
			}
			switch (num)
			{
			case 0:
				this = s_bnZeroInt;
				break;
			case 1:
				if (value[0] < 2147483648u)
				{
					_sign = (int)(negative ? (0 - value[0]) : value[0]);
					_bits = null;
					if (_sign == int.MinValue)
					{
						this = s_bnMinInt;
					}
					break;
				}
				goto default;
			default:
				_sign = ((!negative) ? 1 : (-1));
				_bits = new uint[num];
				Array.Copy(value, _bits, num);
				break;
			}
		}

		private BigInteger(uint[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			int num = value.Length;
			bool flag = num > 0 && (value[num - 1] & 0x80000000u) == 2147483648u;
			while (num > 0 && value[num - 1] == 0)
			{
				num--;
			}
			switch (num)
			{
			case 0:
				this = s_bnZeroInt;
				return;
			case 1:
				if ((int)value[0] < 0 && !flag)
				{
					_bits = new uint[1];
					_bits[0] = value[0];
					_sign = 1;
				}
				else if (int.MinValue == (int)value[0])
				{
					this = s_bnMinInt;
				}
				else
				{
					_sign = (int)value[0];
					_bits = null;
				}
				return;
			}
			if (!flag)
			{
				if (num != value.Length)
				{
					_sign = 1;
					_bits = new uint[num];
					Array.Copy(value, _bits, num);
				}
				else
				{
					_sign = 1;
					_bits = value;
				}
				return;
			}
			NumericsHelpers.DangerousMakeTwosComplement(value);
			int num2 = value.Length;
			while (num2 > 0 && value[num2 - 1] == 0)
			{
				num2--;
			}
			if (num2 == 1 && (int)value[0] > 0)
			{
				if (value[0] == 1)
				{
					this = s_bnMinusOneInt;
					return;
				}
				if (value[0] == 2147483648u)
				{
					this = s_bnMinInt;
					return;
				}
				_sign = -1 * (int)value[0];
				_bits = null;
			}
			else if (num2 != value.Length)
			{
				_sign = -1;
				_bits = new uint[num2];
				Array.Copy(value, _bits, num2);
			}
			else
			{
				_sign = -1;
				_bits = value;
			}
		}

		[__DynamicallyInvokable]
		public static BigInteger Parse(string value)
		{
			return BigNumber.ParseBigInteger(value, NumberStyles.Integer, NumberFormatInfo.CurrentInfo);
		}

		[__DynamicallyInvokable]
		public static BigInteger Parse(string value, NumberStyles style)
		{
			return BigNumber.ParseBigInteger(value, style, NumberFormatInfo.CurrentInfo);
		}

		[__DynamicallyInvokable]
		public static BigInteger Parse(string value, IFormatProvider provider)
		{
			return BigNumber.ParseBigInteger(value, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider));
		}

		[__DynamicallyInvokable]
		public static BigInteger Parse(string value, NumberStyles style, IFormatProvider provider)
		{
			return BigNumber.ParseBigInteger(value, style, NumberFormatInfo.GetInstance(provider));
		}

		[__DynamicallyInvokable]
		public static bool TryParse(string value, out BigInteger result)
		{
			return BigNumber.TryParseBigInteger(value, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
		}

		[__DynamicallyInvokable]
		public static bool TryParse(string value, NumberStyles style, IFormatProvider provider, out BigInteger result)
		{
			return BigNumber.TryParseBigInteger(value, style, NumberFormatInfo.GetInstance(provider), out result);
		}

		[__DynamicallyInvokable]
		public static int Compare(BigInteger left, BigInteger right)
		{
			return left.CompareTo(right);
		}

		[__DynamicallyInvokable]
		public static BigInteger Abs(BigInteger value)
		{
			if (!(value >= Zero))
			{
				return -value;
			}
			return value;
		}

		[__DynamicallyInvokable]
		public static BigInteger Add(BigInteger left, BigInteger right)
		{
			return left + right;
		}

		[__DynamicallyInvokable]
		public static BigInteger Subtract(BigInteger left, BigInteger right)
		{
			return left - right;
		}

		[__DynamicallyInvokable]
		public static BigInteger Multiply(BigInteger left, BigInteger right)
		{
			return left * right;
		}

		[__DynamicallyInvokable]
		public static BigInteger Divide(BigInteger dividend, BigInteger divisor)
		{
			return dividend / divisor;
		}

		[__DynamicallyInvokable]
		public static BigInteger Remainder(BigInteger dividend, BigInteger divisor)
		{
			return dividend % divisor;
		}

		[__DynamicallyInvokable]
		public static BigInteger DivRem(BigInteger dividend, BigInteger divisor, out BigInteger remainder)
		{
			int sign = 1;
			int sign2 = 1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(dividend, ref sign);
			BigIntegerBuilder regDen = new BigIntegerBuilder(divisor, ref sign2);
			BigIntegerBuilder regQuo = default(BigIntegerBuilder);
			bigIntegerBuilder.ModDiv(ref regDen, ref regQuo);
			remainder = bigIntegerBuilder.GetInteger(sign);
			return regQuo.GetInteger(sign * sign2);
		}

		[__DynamicallyInvokable]
		public static BigInteger Negate(BigInteger value)
		{
			return -value;
		}

		[__DynamicallyInvokable]
		public static double Log(BigInteger value)
		{
			return Log(value, Math.E);
		}

		[__DynamicallyInvokable]
		public static double Log(BigInteger value, double baseValue)
		{
			if (value._sign < 0 || baseValue == 1.0)
			{
				return double.NaN;
			}
			if (baseValue == double.PositiveInfinity)
			{
				if (!value.IsOne)
				{
					return double.NaN;
				}
				return 0.0;
			}
			if (baseValue == 0.0 && !value.IsOne)
			{
				return double.NaN;
			}
			if (value._bits == null)
			{
				return Math.Log(value._sign, baseValue);
			}
			double num = 0.0;
			double num2 = 0.5;
			int num3 = Length(value._bits);
			int num4 = BitLengthOfUInt(value._bits[num3 - 1]);
			int num5 = (num3 - 1) * 32 + num4;
			uint num6 = (uint)(1 << num4 - 1);
			for (int num7 = num3 - 1; num7 >= 0; num7--)
			{
				while (num6 != 0)
				{
					if ((value._bits[num7] & num6) != 0)
					{
						num += num2;
					}
					num2 *= 0.5;
					num6 >>= 1;
				}
				num6 = 2147483648u;
			}
			return (Math.Log(num) + 0.6931471805599453 * (double)num5) / Math.Log(baseValue);
		}

		[__DynamicallyInvokable]
		public static double Log10(BigInteger value)
		{
			return Log(value, 10.0);
		}

		[__DynamicallyInvokable]
		public static BigInteger GreatestCommonDivisor(BigInteger left, BigInteger right)
		{
			if (left._sign == 0)
			{
				return Abs(right);
			}
			if (right._sign == 0)
			{
				return Abs(left);
			}
			BigIntegerBuilder reg = new BigIntegerBuilder(left);
			BigIntegerBuilder reg2 = new BigIntegerBuilder(right);
			BigIntegerBuilder.GCD(ref reg, ref reg2);
			return reg.GetInteger(1);
		}

		[__DynamicallyInvokable]
		public static BigInteger Max(BigInteger left, BigInteger right)
		{
			if (left.CompareTo(right) < 0)
			{
				return right;
			}
			return left;
		}

		[__DynamicallyInvokable]
		public static BigInteger Min(BigInteger left, BigInteger right)
		{
			if (left.CompareTo(right) <= 0)
			{
				return left;
			}
			return right;
		}

		private static void ModPowUpdateResult(ref BigIntegerBuilder regRes, ref BigIntegerBuilder regVal, ref BigIntegerBuilder regMod, ref BigIntegerBuilder regTmp)
		{
			NumericsHelpers.Swap(ref regRes, ref regTmp);
			regRes.Mul(ref regTmp, ref regVal);
			regRes.Mod(ref regMod);
		}

		private static void ModPowSquareModValue(ref BigIntegerBuilder regVal, ref BigIntegerBuilder regMod, ref BigIntegerBuilder regTmp)
		{
			NumericsHelpers.Swap(ref regVal, ref regTmp);
			regVal.Mul(ref regTmp, ref regTmp);
			regVal.Mod(ref regMod);
		}

		private static void ModPowInner(uint exp, ref BigIntegerBuilder regRes, ref BigIntegerBuilder regVal, ref BigIntegerBuilder regMod, ref BigIntegerBuilder regTmp)
		{
			while (exp != 0)
			{
				if ((exp & 1) == 1)
				{
					ModPowUpdateResult(ref regRes, ref regVal, ref regMod, ref regTmp);
				}
				if (exp != 1)
				{
					ModPowSquareModValue(ref regVal, ref regMod, ref regTmp);
					exp >>= 1;
					continue;
				}
				break;
			}
		}

		private static void ModPowInner32(uint exp, ref BigIntegerBuilder regRes, ref BigIntegerBuilder regVal, ref BigIntegerBuilder regMod, ref BigIntegerBuilder regTmp)
		{
			for (int i = 0; i < 32; i++)
			{
				if ((exp & 1) == 1)
				{
					ModPowUpdateResult(ref regRes, ref regVal, ref regMod, ref regTmp);
				}
				ModPowSquareModValue(ref regVal, ref regMod, ref regTmp);
				exp >>= 1;
			}
		}

		[__DynamicallyInvokable]
		public static BigInteger ModPow(BigInteger value, BigInteger exponent, BigInteger modulus)
		{
			if (exponent.Sign < 0)
			{
				throw new ArgumentOutOfRangeException("exponent", System.SR.GetString("ArgumentOutOfRange_MustBeNonNeg"));
			}
			int sign = 1;
			int sign2 = 1;
			int sign3 = 1;
			bool isEven = exponent.IsEven;
			BigIntegerBuilder regRes = new BigIntegerBuilder(One, ref sign);
			BigIntegerBuilder regVal = new BigIntegerBuilder(value, ref sign2);
			BigIntegerBuilder regDen = new BigIntegerBuilder(modulus, ref sign3);
			BigIntegerBuilder regTmp = new BigIntegerBuilder(regVal.Size);
			regRes.Mod(ref regDen);
			if (exponent._bits == null)
			{
				ModPowInner((uint)exponent._sign, ref regRes, ref regVal, ref regDen, ref regTmp);
			}
			else
			{
				int num = Length(exponent._bits);
				for (int i = 0; i < num - 1; i++)
				{
					uint exp = exponent._bits[i];
					ModPowInner32(exp, ref regRes, ref regVal, ref regDen, ref regTmp);
				}
				ModPowInner(exponent._bits[num - 1], ref regRes, ref regVal, ref regDen, ref regTmp);
			}
			return regRes.GetInteger((value._sign > 0) ? 1 : (isEven ? 1 : (-1)));
		}

		[__DynamicallyInvokable]
		public static BigInteger Pow(BigInteger value, int exponent)
		{
			if (exponent < 0)
			{
				throw new ArgumentOutOfRangeException("exponent", System.SR.GetString("ArgumentOutOfRange_MustBeNonNeg"));
			}
			switch (exponent)
			{
			case 0:
				return One;
			case 1:
				return value;
			default:
			{
				if (value._bits == null)
				{
					if (value._sign == 1)
					{
						return value;
					}
					if (value._sign == -1)
					{
						if ((exponent & 1) == 0)
						{
							return 1;
						}
						return value;
					}
					if (value._sign == 0)
					{
						return value;
					}
				}
				int sign = 1;
				BigIntegerBuilder reg = new BigIntegerBuilder(value, ref sign);
				int cuRes = reg.Size;
				int cuRes2 = cuRes;
				uint uHiRes = reg.High;
				uint uHiRes2 = uHiRes + 1;
				if (uHiRes2 == 0)
				{
					cuRes2++;
					uHiRes2 = 1u;
				}
				int cuRes3 = 1;
				int cuRes4 = 1;
				uint uHiRes3 = 1u;
				uint uHiRes4 = 1u;
				int num = exponent;
				while (true)
				{
					if (((uint)num & (true ? 1u : 0u)) != 0)
					{
						MulUpper(ref uHiRes4, ref cuRes4, uHiRes2, cuRes2);
						MulLower(ref uHiRes3, ref cuRes3, uHiRes, cuRes);
					}
					if ((num >>= 1) == 0)
					{
						break;
					}
					MulUpper(ref uHiRes2, ref cuRes2, uHiRes2, cuRes2);
					MulLower(ref uHiRes, ref cuRes, uHiRes, cuRes);
				}
				if (cuRes4 > 1)
				{
					reg.EnsureWritable(cuRes4, 0);
				}
				BigIntegerBuilder b = new BigIntegerBuilder(cuRes4);
				BigIntegerBuilder a = new BigIntegerBuilder(cuRes4);
				a.Set(1u);
				if ((exponent & 1) == 0)
				{
					sign = 1;
				}
				int num2 = exponent;
				while (true)
				{
					if (((uint)num2 & (true ? 1u : 0u)) != 0)
					{
						NumericsHelpers.Swap(ref a, ref b);
						a.Mul(ref reg, ref b);
					}
					if ((num2 >>= 1) == 0)
					{
						break;
					}
					NumericsHelpers.Swap(ref reg, ref b);
					reg.Mul(ref b, ref b);
				}
				return a.GetInteger(sign);
			}
			}
		}

		[__DynamicallyInvokable]
		public static implicit operator BigInteger(byte value)
		{
			return new BigInteger(value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static implicit operator BigInteger(sbyte value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static implicit operator BigInteger(short value)
		{
			return new BigInteger(value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static implicit operator BigInteger(ushort value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static implicit operator BigInteger(int value)
		{
			return new BigInteger(value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static implicit operator BigInteger(uint value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static implicit operator BigInteger(long value)
		{
			return new BigInteger(value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static implicit operator BigInteger(ulong value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static explicit operator BigInteger(float value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static explicit operator BigInteger(double value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static explicit operator BigInteger(decimal value)
		{
			return new BigInteger(value);
		}

		[__DynamicallyInvokable]
		public static explicit operator byte(BigInteger value)
		{
			return checked((byte)(int)value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static explicit operator sbyte(BigInteger value)
		{
			return checked((sbyte)(int)value);
		}

		[__DynamicallyInvokable]
		public static explicit operator short(BigInteger value)
		{
			return checked((short)(int)value);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static explicit operator ushort(BigInteger value)
		{
			return checked((ushort)(int)value);
		}

		[__DynamicallyInvokable]
		public static explicit operator int(BigInteger value)
		{
			if (value._bits == null)
			{
				return value._sign;
			}
			if (Length(value._bits) > 1)
			{
				throw new OverflowException(System.SR.GetString("Overflow_Int32"));
			}
			if (value._sign > 0)
			{
				return checked((int)value._bits[0]);
			}
			if (value._bits[0] > 2147483648u)
			{
				throw new OverflowException(System.SR.GetString("Overflow_Int32"));
			}
			return (int)(0 - value._bits[0]);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static explicit operator uint(BigInteger value)
		{
			if (value._bits == null)
			{
				return checked((uint)value._sign);
			}
			if (Length(value._bits) > 1 || value._sign < 0)
			{
				throw new OverflowException(System.SR.GetString("Overflow_UInt32"));
			}
			return value._bits[0];
		}

		[__DynamicallyInvokable]
		public static explicit operator long(BigInteger value)
		{
			if (value._bits == null)
			{
				return value._sign;
			}
			int num = Length(value._bits);
			if (num > 2)
			{
				throw new OverflowException(System.SR.GetString("Overflow_Int64"));
			}
			ulong num2 = ((num <= 1) ? value._bits[0] : NumericsHelpers.MakeUlong(value._bits[1], value._bits[0]));
			long num3 = (long)((value._sign > 0) ? num2 : (0L - num2));
			if ((num3 > 0 && value._sign > 0) || (num3 < 0 && value._sign < 0))
			{
				return num3;
			}
			throw new OverflowException(System.SR.GetString("Overflow_Int64"));
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static explicit operator ulong(BigInteger value)
		{
			if (value._bits == null)
			{
				return checked((ulong)value._sign);
			}
			int num = Length(value._bits);
			if (num > 2 || value._sign < 0)
			{
				throw new OverflowException(System.SR.GetString("Overflow_UInt64"));
			}
			if (num > 1)
			{
				return NumericsHelpers.MakeUlong(value._bits[1], value._bits[0]);
			}
			return value._bits[0];
		}

		[__DynamicallyInvokable]
		public static explicit operator float(BigInteger value)
		{
			return (float)(double)value;
		}

		[__DynamicallyInvokable]
		public static explicit operator double(BigInteger value)
		{
			if (value._bits == null)
			{
				return value._sign;
			}
			int sign = 1;
			new BigIntegerBuilder(value, ref sign).GetApproxParts(out var exp, out var man);
			return NumericsHelpers.GetDoubleFromParts(sign, exp, man);
		}

		[__DynamicallyInvokable]
		public static explicit operator decimal(BigInteger value)
		{
			if (value._bits == null)
			{
				return value._sign;
			}
			int num = Length(value._bits);
			if (num > 3)
			{
				throw new OverflowException(System.SR.GetString("Overflow_Decimal"));
			}
			int lo = 0;
			int mid = 0;
			int hi = 0;
			if (num > 2)
			{
				hi = (int)value._bits[2];
			}
			if (num > 1)
			{
				mid = (int)value._bits[1];
			}
			if (num > 0)
			{
				lo = (int)value._bits[0];
			}
			return new decimal(lo, mid, hi, value._sign < 0, 0);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator &(BigInteger left, BigInteger right)
		{
			if (left.IsZero || right.IsZero)
			{
				return Zero;
			}
			uint[] array = left.ToUInt32Array();
			uint[] array2 = right.ToUInt32Array();
			uint[] array3 = new uint[Math.Max(array.Length, array2.Length)];
			uint num = ((left._sign < 0) ? uint.MaxValue : 0u);
			uint num2 = ((right._sign < 0) ? uint.MaxValue : 0u);
			for (int i = 0; i < array3.Length; i++)
			{
				uint num3 = ((i < array.Length) ? array[i] : num);
				uint num4 = ((i < array2.Length) ? array2[i] : num2);
				array3[i] = num3 & num4;
			}
			return new BigInteger(array3);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator |(BigInteger left, BigInteger right)
		{
			if (left.IsZero)
			{
				return right;
			}
			if (right.IsZero)
			{
				return left;
			}
			uint[] array = left.ToUInt32Array();
			uint[] array2 = right.ToUInt32Array();
			uint[] array3 = new uint[Math.Max(array.Length, array2.Length)];
			uint num = ((left._sign < 0) ? uint.MaxValue : 0u);
			uint num2 = ((right._sign < 0) ? uint.MaxValue : 0u);
			for (int i = 0; i < array3.Length; i++)
			{
				uint num3 = ((i < array.Length) ? array[i] : num);
				uint num4 = ((i < array2.Length) ? array2[i] : num2);
				array3[i] = num3 | num4;
			}
			return new BigInteger(array3);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator ^(BigInteger left, BigInteger right)
		{
			uint[] array = left.ToUInt32Array();
			uint[] array2 = right.ToUInt32Array();
			uint[] array3 = new uint[Math.Max(array.Length, array2.Length)];
			uint num = ((left._sign < 0) ? uint.MaxValue : 0u);
			uint num2 = ((right._sign < 0) ? uint.MaxValue : 0u);
			for (int i = 0; i < array3.Length; i++)
			{
				uint num3 = ((i < array.Length) ? array[i] : num);
				uint num4 = ((i < array2.Length) ? array2[i] : num2);
				array3[i] = num3 ^ num4;
			}
			return new BigInteger(array3);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator <<(BigInteger value, int shift)
		{
			if (shift == 0)
			{
				return value;
			}
			if (shift == int.MinValue)
			{
				return value >> int.MaxValue >> 1;
			}
			if (shift < 0)
			{
				return value >> -shift;
			}
			int num = shift / 32;
			int num2 = shift - num * 32;
			uint[] xd;
			int xl;
			bool partsForBitManipulation = GetPartsForBitManipulation(ref value, out xd, out xl);
			int num3 = xl + num + 1;
			uint[] array = new uint[num3];
			if (num2 == 0)
			{
				for (int i = 0; i < xl; i++)
				{
					array[i + num] = xd[i];
				}
			}
			else
			{
				int num4 = 32 - num2;
				uint num5 = 0u;
				int j;
				for (j = 0; j < xl; j++)
				{
					uint num6 = xd[j];
					array[j + num] = (num6 << num2) | num5;
					num5 = num6 >> num4;
				}
				array[j + num] = num5;
			}
			return new BigInteger(array, partsForBitManipulation);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator >>(BigInteger value, int shift)
		{
			if (shift == 0)
			{
				return value;
			}
			if (shift == int.MinValue)
			{
				return value << int.MaxValue << 1;
			}
			if (shift < 0)
			{
				return value << -shift;
			}
			int num = shift / 32;
			int num2 = shift - num * 32;
			uint[] xd;
			int xl;
			bool partsForBitManipulation = GetPartsForBitManipulation(ref value, out xd, out xl);
			if (partsForBitManipulation)
			{
				if (shift >= 32 * xl)
				{
					return MinusOne;
				}
				uint[] array = new uint[xl];
				Array.Copy(xd, array, xl);
				xd = array;
				NumericsHelpers.DangerousMakeTwosComplement(xd);
			}
			int num3 = xl - num;
			if (num3 < 0)
			{
				num3 = 0;
			}
			uint[] array2 = new uint[num3];
			if (num2 == 0)
			{
				for (int num4 = xl - 1; num4 >= num; num4--)
				{
					array2[num4 - num] = xd[num4];
				}
			}
			else
			{
				int num5 = 32 - num2;
				uint num6 = 0u;
				for (int num7 = xl - 1; num7 >= num; num7--)
				{
					uint num8 = xd[num7];
					if (partsForBitManipulation && num7 == xl - 1)
					{
						array2[num7 - num] = (num8 >> num2) | (uint)(-1 << num5);
					}
					else
					{
						array2[num7 - num] = (num8 >> num2) | num6;
					}
					num6 = num8 << num5;
				}
			}
			if (partsForBitManipulation)
			{
				NumericsHelpers.DangerousMakeTwosComplement(array2);
			}
			return new BigInteger(array2, partsForBitManipulation);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator ~(BigInteger value)
		{
			return -(value + One);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator -(BigInteger value)
		{
			value._sign = -value._sign;
			return value;
		}

		[__DynamicallyInvokable]
		public static BigInteger operator +(BigInteger value)
		{
			return value;
		}

		[__DynamicallyInvokable]
		public static BigInteger operator ++(BigInteger value)
		{
			return value + One;
		}

		[__DynamicallyInvokable]
		public static BigInteger operator --(BigInteger value)
		{
			return value - One;
		}

		[__DynamicallyInvokable]
		public static BigInteger operator +(BigInteger left, BigInteger right)
		{
			if (right.IsZero)
			{
				return left;
			}
			if (left.IsZero)
			{
				return right;
			}
			int sign = 1;
			int sign2 = 1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(left, ref sign);
			BigIntegerBuilder reg = new BigIntegerBuilder(right, ref sign2);
			if (sign == sign2)
			{
				bigIntegerBuilder.Add(ref reg);
			}
			else
			{
				bigIntegerBuilder.Sub(ref sign, ref reg);
			}
			return bigIntegerBuilder.GetInteger(sign);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator -(BigInteger left, BigInteger right)
		{
			if (right.IsZero)
			{
				return left;
			}
			if (left.IsZero)
			{
				return -right;
			}
			int sign = 1;
			int sign2 = -1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(left, ref sign);
			BigIntegerBuilder reg = new BigIntegerBuilder(right, ref sign2);
			if (sign == sign2)
			{
				bigIntegerBuilder.Add(ref reg);
			}
			else
			{
				bigIntegerBuilder.Sub(ref sign, ref reg);
			}
			return bigIntegerBuilder.GetInteger(sign);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator *(BigInteger left, BigInteger right)
		{
			int sign = 1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(left, ref sign);
			BigIntegerBuilder regMul = new BigIntegerBuilder(right, ref sign);
			bigIntegerBuilder.Mul(ref regMul);
			return bigIntegerBuilder.GetInteger(sign);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator /(BigInteger dividend, BigInteger divisor)
		{
			int sign = 1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(dividend, ref sign);
			BigIntegerBuilder regDen = new BigIntegerBuilder(divisor, ref sign);
			bigIntegerBuilder.Div(ref regDen);
			return bigIntegerBuilder.GetInteger(sign);
		}

		[__DynamicallyInvokable]
		public static BigInteger operator %(BigInteger dividend, BigInteger divisor)
		{
			int sign = 1;
			int sign2 = 1;
			BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(dividend, ref sign);
			BigIntegerBuilder regDen = new BigIntegerBuilder(divisor, ref sign2);
			bigIntegerBuilder.Mod(ref regDen);
			return bigIntegerBuilder.GetInteger(sign);
		}

		[__DynamicallyInvokable]
		public static bool operator <(BigInteger left, BigInteger right)
		{
			return left.CompareTo(right) < 0;
		}

		[__DynamicallyInvokable]
		public static bool operator <=(BigInteger left, BigInteger right)
		{
			return left.CompareTo(right) <= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >(BigInteger left, BigInteger right)
		{
			return left.CompareTo(right) > 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >=(BigInteger left, BigInteger right)
		{
			return left.CompareTo(right) >= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator ==(BigInteger left, BigInteger right)
		{
			return left.Equals(right);
		}

		[__DynamicallyInvokable]
		public static bool operator !=(BigInteger left, BigInteger right)
		{
			return !left.Equals(right);
		}

		[__DynamicallyInvokable]
		public static bool operator <(BigInteger left, long right)
		{
			return left.CompareTo(right) < 0;
		}

		[__DynamicallyInvokable]
		public static bool operator <=(BigInteger left, long right)
		{
			return left.CompareTo(right) <= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >(BigInteger left, long right)
		{
			return left.CompareTo(right) > 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >=(BigInteger left, long right)
		{
			return left.CompareTo(right) >= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator ==(BigInteger left, long right)
		{
			return left.Equals(right);
		}

		[__DynamicallyInvokable]
		public static bool operator !=(BigInteger left, long right)
		{
			return !left.Equals(right);
		}

		[__DynamicallyInvokable]
		public static bool operator <(long left, BigInteger right)
		{
			return right.CompareTo(left) > 0;
		}

		[__DynamicallyInvokable]
		public static bool operator <=(long left, BigInteger right)
		{
			return right.CompareTo(left) >= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >(long left, BigInteger right)
		{
			return right.CompareTo(left) < 0;
		}

		[__DynamicallyInvokable]
		public static bool operator >=(long left, BigInteger right)
		{
			return right.CompareTo(left) <= 0;
		}

		[__DynamicallyInvokable]
		public static bool operator ==(long left, BigInteger right)
		{
			return right.Equals(left);
		}

		[__DynamicallyInvokable]
		public static bool operator !=(long left, BigInteger right)
		{
			return !right.Equals(left);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator <(BigInteger left, ulong right)
		{
			return left.CompareTo(right) < 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator <=(BigInteger left, ulong right)
		{
			return left.CompareTo(right) <= 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator >(BigInteger left, ulong right)
		{
			return left.CompareTo(right) > 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator >=(BigInteger left, ulong right)
		{
			return left.CompareTo(right) >= 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator ==(BigInteger left, ulong right)
		{
			return left.Equals(right);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator !=(BigInteger left, ulong right)
		{
			return !left.Equals(right);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator <(ulong left, BigInteger right)
		{
			return right.CompareTo(left) > 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator <=(ulong left, BigInteger right)
		{
			return right.CompareTo(left) >= 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator >(ulong left, BigInteger right)
		{
			return right.CompareTo(left) < 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator >=(ulong left, BigInteger right)
		{
			return right.CompareTo(left) <= 0;
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator ==(ulong left, BigInteger right)
		{
			return right.Equals(left);
		}

		[CLSCompliant(false)]
		[__DynamicallyInvokable]
		public static bool operator !=(ulong left, BigInteger right)
		{
			return !right.Equals(left);
		}

		private void SetBitsFromDouble(double value)
		{
			NumericsHelpers.GetDoubleParts(value, out var sign, out var exp, out var man, out var _);
			if (man == 0L)
			{
				this = Zero;
				return;
			}
			if (exp <= 0)
			{
				if (exp <= -64)
				{
					this = Zero;
					return;
				}
				this = man >> -exp;
				if (sign < 0)
				{
					_sign = -_sign;
				}
				return;
			}
			if (exp <= 11)
			{
				this = man << exp;
				if (sign < 0)
				{
					_sign = -_sign;
				}
				return;
			}
			man <<= 11;
			exp -= 11;
			int num = (exp - 1) / 32 + 1;
			int num2 = num * 32 - exp;
			_bits = new uint[num + 2];
			_bits[num + 1] = (uint)(man >> num2 + 32);
			_bits[num] = (uint)(man >> num2);
			if (num2 > 0)
			{
				_bits[num - 1] = (uint)((int)man << 32 - num2);
			}
			_sign = sign;
		}

		internal static int Length(uint[] rgu)
		{
			int num = rgu.Length;
			if (rgu[num - 1] != 0)
			{
				return num;
			}
			return num - 1;
		}

		internal static int BitLengthOfUInt(uint x)
		{
			int num = 0;
			while (x != 0)
			{
				x >>= 1;
				num++;
			}
			return num;
		}

		private static bool GetPartsForBitManipulation(ref BigInteger x, out uint[] xd, out int xl)
		{
			if (x._bits == null)
			{
				if (x._sign < 0)
				{
					xd = new uint[1] { (uint)(-x._sign) };
				}
				else
				{
					xd = new uint[1] { (uint)x._sign };
				}
			}
			else
			{
				xd = x._bits;
			}
			xl = ((x._bits == null) ? 1 : x._bits.Length);
			return x._sign < 0;
		}

		private static void MulUpper(ref uint uHiRes, ref int cuRes, uint uHiMul, int cuMul)
		{
			ulong uu = (ulong)uHiRes * (ulong)uHiMul;
			uint num = NumericsHelpers.GetHi(uu);
			if (num != 0)
			{
				if (NumericsHelpers.GetLo(uu) != 0 && ++num == 0)
				{
					num = 1u;
					cuRes++;
				}
				uHiRes = num;
				cuRes += cuMul;
			}
			else
			{
				uHiRes = NumericsHelpers.GetLo(uu);
				cuRes += cuMul - 1;
			}
		}

		private static void MulLower(ref uint uHiRes, ref int cuRes, uint uHiMul, int cuMul)
		{
			ulong uu = (ulong)uHiRes * (ulong)uHiMul;
			uint hi = NumericsHelpers.GetHi(uu);
			if (hi != 0)
			{
				uHiRes = hi;
				cuRes += cuMul;
			}
			else
			{
				uHiRes = NumericsHelpers.GetLo(uu);
				cuRes += cuMul - 1;
			}
		}

		internal static int GetDiffLength(uint[] rgu1, uint[] rgu2, int cu)
		{
			int num = cu;
			while (--num >= 0)
			{
				if (rgu1[num] != rgu2[num])
				{
					return num + 1;
				}
			}
			return 0;
		}
	}
	internal struct BigIntegerBuilder
	{
		private const int kcbitUint = 32;

		private int _iuLast;

		private uint _uSmall;

		private uint[] _rgu;

		private bool _fWritable;

		private static readonly double kdblLn2To32 = 32.0 * Math.Log(2.0);

		private static readonly byte[] _rgbInv = new byte[128]
		{
			1, 171, 205, 183, 57, 163, 197, 239, 241, 27,
			61, 167, 41, 19, 53, 223, 225, 139, 173, 151,
			25, 131, 165, 207, 209, 251, 29, 135, 9, 243,
			21, 191, 193, 107, 141, 119, 249, 99, 133, 175,
			177, 219, 253, 103, 233, 211, 245, 159, 161, 75,
			109, 87, 217, 67, 101, 143, 145, 187, 221, 71,
			201, 179, 213, 127, 129, 43, 77, 55, 185, 35,
			69, 111, 113, 155, 189, 39, 169, 147, 181, 95,
			97, 11, 45, 23, 153, 3, 37, 79, 81, 123,
			157, 7, 137, 115, 149, 63, 65, 235, 13, 247,
			121, 227, 5, 47, 49, 91, 125, 231, 105, 83,
			117, 31, 33, 203, 237, 215, 89, 195, 229, 15,
			17, 59, 93, 199, 73, 51, 85, 255
		};

		public int Size => _iuLast + 1;

		public uint High
		{
			get
			{
				if (_iuLast != 0)
				{
					return _rgu[_iuLast];
				}
				return _uSmall;
			}
		}

		private int CuNonZero
		{
			get
			{
				int num = 0;
				for (int num2 = _iuLast; num2 >= 0; num2--)
				{
					if (_rgu[num2] != 0)
					{
						num++;
					}
				}
				return num;
			}
		}

		[Conditional("DEBUG")]
		private void AssertValid(bool fTrimmed)
		{
			_ = _iuLast;
			_ = 0;
		}

		public BigIntegerBuilder(ref BigIntegerBuilder reg)
		{
			this = reg;
			if (_fWritable)
			{
				_fWritable = false;
				if (_iuLast == 0)
				{
					_rgu = null;
				}
				else
				{
					reg._fWritable = false;
				}
			}
		}

		public BigIntegerBuilder(int cuAlloc)
		{
			_iuLast = 0;
			_uSmall = 0u;
			if (cuAlloc > 1)
			{
				_rgu = new uint[cuAlloc];
				_fWritable = true;
			}
			else
			{
				_rgu = null;
				_fWritable = false;
			}
		}

		public BigIntegerBuilder(BigInteger bn)
		{
			_fWritable = false;
			_rgu = bn._Bits;
			if (_rgu == null)
			{
				_iuLast = 0;
				_uSmall = NumericsHelpers.Abs(bn._Sign);
				return;
			}
			_iuLast = _rgu.Length - 1;
			_uSmall = _rgu[0];
			while (_iuLast > 0 && _rgu[_iuLast] == 0)
			{
				_iuLast--;
			}
		}

		public BigIntegerBuilder(BigInteger bn, ref int sign)
		{
			_fWritable = false;
			_rgu = bn._Bits;
			int sign2 = bn._Sign;
			int num = sign2 >> 31;
			sign = (sign ^ num) - num;
			if (_rgu == null)
			{
				_iuLast = 0;
				_uSmall = (uint)((sign2 ^ num) - num);
				return;
			}
			_iuLast = _rgu.Length - 1;
			_uSmall = _rgu[0];
			while (_iuLast > 0 && _rgu[_iuLast] == 0)
			{
				_iuLast--;
			}
		}

		public BigInteger GetInteger(int sign)
		{
			GetIntegerParts(sign, out sign, out var bits);
			return new BigInteger(sign, bits);
		}

		internal void GetIntegerParts(int signSrc, out int sign, out uint[] bits)
		{
			if (_iuLast == 0)
			{
				if (_uSmall <= int.MaxValue)
				{
					sign = signSrc * (int)_uSmall;
					bits = null;
					return;
				}
				if (_rgu == null)
				{
					_rgu = new uint[1] { _uSmall };
				}
				else if (_fWritable)
				{
					_rgu[0] = _uSmall;
				}
				else if (_rgu[0] != _uSmall)
				{
					_rgu = new uint[1] { _uSmall };
				}
			}
			sign = signSrc;
			int num = _rgu.Length - _iuLast - 1;
			if (num <= 1)
			{
				if (num == 0 || _rgu[_iuLast + 1] == 0)
				{
					_fWritable = false;
					bits = _rgu;
					return;
				}
				if (_fWritable)
				{
					_rgu[_iuLast + 1] = 0u;
					_fWritable = false;
					bits = _rgu;
					return;
				}
			}
			bits = _rgu;
			Array.Resize(ref bits, _iuLast + 1);
			if (!_fWritable)
			{
				_rgu = bits;
			}
		}

		public void Set(uint u)
		{
			_uSmall = u;
			_iuLast = 0;
		}

		public void Set(ulong uu)
		{
			uint hi = NumericsHelpers.GetHi(uu);
			if (hi == 0)
			{
				_uSmall = NumericsHelpers.GetLo(uu);
				_iuLast = 0;
			}
			else
			{
				SetSizeLazy(2);
				_rgu[0] = (uint)uu;
				_rgu[1] = hi;
			}
		}

		public void GetApproxParts(out int exp, out ulong man)
		{
			if (_iuLast == 0)
			{
				man = _uSmall;
				exp = 0;
				return;
			}
			int num = _iuLast - 1;
			man = NumericsHelpers.MakeUlong(_rgu[num + 1], _rgu[num]);
			exp = num * 32;
			int num2;
			if (num > 0 && (num2 = NumericsHelpers.CbitHighZero(_rgu[num + 1])) > 0)
			{
				man = (man << num2) | (_rgu[num - 1] >> 32 - num2);
				exp -= num2;
			}
		}

		private void Trim()
		{
			if (_iuLast > 0 && _rgu[_iuLast] == 0)
			{
				_uSmall = _rgu[0];
				while (--_iuLast > 0 && _rgu[_iuLast] == 0)
				{
				}
			}
		}

		private void SetSizeLazy(int cu)
		{
			if (cu <= 1)
			{
				_iuLast = 0;
				return;
			}
			if (!_fWritable || _rgu.Length < cu)
			{
				_rgu = new uint[cu];
				_fWritable = true;
			}
			_iuLast = cu - 1;
		}

		private void SetSizeClear(int cu)
		{
			if (cu <= 1)
			{
				_iuLast = 0;
				_uSmall = 0u;
				return;
			}
			if (!_fWritable || _rgu.Length < cu)
			{
				_rgu = new uint[cu];
				_fWritable = true;
			}
			else
			{
				Array.Clear(_rgu, 0, cu);
			}
			_iuLast = cu - 1;
		}

		private void SetSizeKeep(int cu, int cuExtra)
		{
			if (cu <= 1)
			{
				if (_iuLast > 0)
				{
					_uSmall = _rgu[0];
				}
				_iuLast = 0;
				return;
			}
			if (!_fWritable || _rgu.Length < cu)
			{
				uint[] array = new uint[cu + cuExtra];
				if (_iuLast == 0)
				{
					array[0] = _uSmall;
				}
				else
				{
					Array.Copy(_rgu, array, Math.Min(cu, _iuLast + 1));
				}
				_rgu = array;
				_fWritable = true;
			}
			else if (_iuLast + 1 < cu)
			{
				Array.Clear(_rgu, _iuLast + 1, cu - _iuLast - 1);
				if (_iuLast == 0)
				{
					_rgu[0] = _uSmall;
				}
			}
			_iuLast = cu - 1;
		}

		public void EnsureWritable(int cu, int cuExtra)
		{
			if (_fWritable && _rgu.Length >= cu)
			{
				return;
			}
			uint[] array = new uint[cu + cuExtra];
			if (_iuLast > 0)
			{
				if (_iuLast >= cu)
				{
					_iuLast = cu - 1;
				}
				Array.Copy(_rgu, array, _iuLast + 1);
			}
			_rgu = array;
			_fWritable = true;
		}

		public void EnsureWritable(int cuExtra)
		{
			if (!_fWritable)
			{
				uint[] array = new uint[_iuLast + 1 + cuExtra];
				Array.Copy(_rgu, array, _iuLast + 1);
				_rgu = array;
				_fWritable = true;
			}
		}

		public void EnsureWritable()
		{
			EnsureWritable(0);
		}

		public void Load(ref BigIntegerBuilder reg)
		{
			Load(ref reg, 0);
		}

		public void Load(ref BigIntegerBuilder reg, int cuExtra)
		{
			if (reg._iuLast == 0)
			{
				_uSmall = reg._uSmall;
				_iuLast = 0;
				return;
			}
			if (!_fWritable || _rgu.Length <= reg._iuLast)
			{
				_rgu = new uint[reg._iuLast + 1 + cuExtra];
				_fWritable = true;
			}
			_iuLast = reg._iuLast;
			Array.Copy(reg._rgu, _rgu, _iuLast + 1);
		}

		public void Add(uint u)
		{
			if (_iuLast == 0)
			{
				if ((_uSmall += u) < u)
				{
					SetSizeLazy(2);
					_rgu[0] = _uSmall;
					_rgu[1] = 1u;
				}
			}
			else if (u != 0)
			{
				uint num = _rgu[0] + u;
				if (num < u)
				{
					EnsureWritable(1);
					ApplyCarry(1);
				}
				else if (!_fWritable)
				{
					EnsureWritable();
				}
				_rgu[0] = num;
			}
		}

		public void Add(ref BigIntegerBuilder reg)
		{
			if (reg._iuLast == 0)
			{
				Add(reg._uSmall);
				return;
			}
			if (_iuLast == 0)
			{
				uint uSmall = _uSmall;
				if (uSmall == 0)
				{
					this = new BigIntegerBuilder(ref reg);
					return;
				}
				Load(ref reg, 1);
				Add(uSmall);
				return;
			}
			EnsureWritable(Math.Max(_iuLast, reg._iuLast) + 1, 1);
			int num = reg._iuLast + 1;
			if (_iuLast < reg._iuLast)
			{
				num = _iuLast + 1;
				Array.Copy(reg._rgu, _iuLast + 1, _rgu, _iuLast + 1, reg._iuLast - _iuLast);
				_iuLast = reg._iuLast;
			}
			uint num2 = 0u;
			for (int i = 0; i < num; i++)
			{
				num2 = AddCarry(ref _rgu[i], reg._rgu[i], num2);
			}
			if (num2 != 0)
			{
				ApplyCarry(num);
			}
		}

		public void Sub(ref int sign, uint u)
		{
			if (_iuLast == 0)
			{
				if (u <= _uSmall)
				{
					_uSmall -= u;
					return;
				}
				_uSmall = u - _uSmall;
				sign = -sign;
			}
			else if (u != 0)
			{
				EnsureWritable();
				uint num = _rgu[0];
				_rgu[0] = num - u;
				if (num < u)
				{
					ApplyBorrow(1);
					Trim();
				}
			}
		}

		public void Sub(ref int sign, ref BigIntegerBuilder reg)
		{
			if (reg._iuLast == 0)
			{
				Sub(ref sign, reg._uSmall);
				return;
			}
			if (_iuLast == 0)
			{
				uint uSmall = _uSmall;
				if (uSmall == 0)
				{
					this = new BigIntegerBuilder(ref reg);
				}
				else
				{
					Load(ref reg);
					Sub(ref sign, uSmall);
				}
				sign = -sign;
				return;
			}
			if (_iuLast < reg._iuLast)
			{
				SubRev(ref reg);
				sign = -sign;
				return;
			}
			int num = reg._iuLast + 1;
			if (_iuLast == reg._iuLast)
			{
				_iuLast = BigInteger.GetDiffLength(_rgu, reg._rgu, _iuLast + 1) - 1;
				if (_iuLast < 0)
				{
					_iuLast = 0;
					_uSmall = 0u;
					return;
				}
				uint num2 = _rgu[_iuLast];
				uint num3 = reg._rgu[_iuLast];
				if (_iuLast == 0)
				{
					if (num2 < num3)
					{
						_uSmall = num3 - num2;
						sign = -sign;
					}
					else
					{
						_uSmall = num2 - num3;
					}
					return;
				}
				if (num2 < num3)
				{
					reg._iuLast = _iuLast;
					SubRev(ref reg);
					reg._iuLast = num - 1;
					sign = -sign;
					return;
				}
				num = _iuLast + 1;
			}
			EnsureWritable();
			uint num4 = 0u;
			for (int i = 0; i < num; i++)
			{
				num4 = SubBorrow(ref _rgu[i], reg._rgu[i], num4);
			}
			if (num4 != 0)
			{
				ApplyBorrow(num);
			}
			Trim();
		}

		private void SubRev(ref BigIntegerBuilder reg)
		{
			EnsureWritable(reg._iuLast + 1, 0);
			int num = _iuLast + 1;
			if (_iuLast < reg._iuLast)
			{
				Array.Copy(reg._rgu, _iuLast + 1, _rgu, _iuLast + 1, reg._iuLast - _iuLast);
				_iuLast = reg._iuLast;
			}
			uint num2 = 0u;
			for (int i = 0; i < num; i++)
			{
				num2 = SubRevBorrow(ref _rgu[i], reg._rgu[i], num2);
			}
			if (num2 != 0)
			{
				ApplyBorrow(num);
			}
			Trim();
		}

		public void Mul(uint u)
		{
			switch (u)
			{
			case 0u:
				Set(0u);
				return;
			case 1u:
				return;
			}
			if (_iuLast == 0)
			{
				Set((ulong)_uSmall * (ulong)u);
				return;
			}
			EnsureWritable(1);
			uint num = 0u;
			for (int i = 0; i <= _iuLast; i++)
			{
				num = MulCarry(ref _rgu[i], u, num);
			}
			if (num != 0)
			{
				SetSizeKeep(_iuLast + 2, 0);
				_rgu[_iuLast] = num;
			}
		}

		public void Mul(ref BigIntegerBuilder regMul)
		{
			if (regMul._iuLast == 0)
			{
				Mul(regMul._uSmall);
				return;
			}
			if (_iuLast == 0)
			{
				uint uSmall = _uSmall;
				switch (uSmall)
				{
				case 1u:
					this = new BigIntegerBuilder(ref regMul);
					break;
				default:
					Load(ref regMul, 1);
					Mul(uSmall);
					break;
				case 0u:
					break;
				}
				return;
			}
			int num = _iuLast + 1;
			SetSizeKeep(num + regMul._iuLast, 1);
			int num2 = num;
			while (--num2 >= 0)
			{
				uint uMul = _rgu[num2];
				_rgu[num2] = 0u;
				uint num3 = 0u;
				for (int i = 0; i <= regMul._iuLast; i++)
				{
					num3 = AddMulCarry(ref _rgu[num2 + i], regMul._rgu[i], uMul, num3);
				}
				if (num3 != 0)
				{
					int num4 = num2 + regMul._iuLast + 1;
					while (num3 != 0 && num4 <= _iuLast)
					{
						num3 = AddCarry(ref _rgu[num4], 0u, num3);
						num4++;
					}
					if (num3 != 0)
					{
						SetSizeKeep(_iuLast + 2, 0);
						_rgu[_iuLast] = num3;
					}
				}
			}
		}

		public void Mul(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
		{
			if (reg1._iuLast == 0)
			{
				if (reg2._iuLast == 0)
				{
					Set((ulong)reg1._uSmall * (ulong)reg2._uSmall);
					return;
				}
				Load(ref reg2, 1);
				Mul(reg1._uSmall);
				return;
			}
			if (reg2._iuLast == 0)
			{
				Load(ref reg1, 1);
				Mul(reg2._uSmall);
				return;
			}
			SetSizeClear(reg1._iuLast + reg2._iuLast + 2);
			uint[] rgu;
			int num;
			uint[] rgu2;
			int num2;
			if (reg1.CuNonZero <= reg2.CuNonZero)
			{
				rgu = reg1._rgu;
				num = reg1._iuLast + 1;
				rgu2 = reg2._rgu;
				num2 = reg2._iuLast + 1;
			}
			else
			{
				rgu = reg2._rgu;
				num = reg2._iuLast + 1;
				rgu2 = reg1._rgu;
				num2 = reg1._iuLast + 1;
			}
			for (int i = 0; i < num; i++)
			{
				uint num3 = rgu[i];
				if (num3 != 0)
				{
					uint num4 = 0u;
					int num5 = i;
					int num6 = 0;
					while (num6 < num2)
					{
						num4 = AddMulCarry(ref _rgu[num5], num3, rgu2[num6], num4);
						num6++;
						num5++;
					}
					while (num4 != 0)
					{
						num4 = AddCarry(ref _rgu[num5++], 0u, num4);
					}
				}
			}
			Trim();
		}

		public uint DivMod(uint uDen)
		{
			if (uDen == 1)
			{
				return 0u;
			}
			if (_iuLast == 0)
			{
				uint uSmall = _uSmall;
				_uSmall = uSmall / uDen;
				return uSmall % uDen;
			}
			EnsureWritable();
			ulong num = 0uL;
			for (int num2 = _iuLast; num2 >= 0; num2--)
			{
				num = NumericsHelpers.MakeUlong((uint)num, _rgu[num2]);
				_rgu[num2] = (uint)(num / uDen);
				num %= uDen;
			}
			Trim();
			return (uint)num;
		}

		public static uint Mod(ref BigIntegerBuilder regNum, uint uDen)
		{
			if (uDen == 1)
			{
				return 0u;
			}
			if (regNum._iuLast == 0)
			{
				return regNum._uSmall % uDen;
			}
			ulong num = 0uL;
			for (int num2 = regNum._iuLast; num2 >= 0; num2--)
			{
				num = NumericsHelpers.MakeUlong((uint)num, regNum._rgu[num2]);
				num %= uDen;
			}
			return (uint)num;
		}

		public void Mod(ref BigIntegerBuilder regDen)
		{
			if (regDen._iuLast == 0)
			{
				Set(Mod(ref this, regDen._uSmall));
			}
			else if (_iuLast != 0)
			{
				BigIntegerBuilder regQuo = default(BigIntegerBuilder);
				ModDivCore(ref this, ref regDen, fQuo: false, ref regQuo);
			}
		}

		public void Div(ref BigIntegerBuilder regDen)
		{
			if (regDen._iuLast == 0)
			{
				DivMod(regDen._uSmall);
				return;
			}
			if (_iuLast == 0)
			{
				_uSmall = 0u;
				return;
			}
			BigIntegerBuilder regQuo = default(BigIntegerBuilder);
			ModDivCore(ref this, ref regDen, fQuo: true, ref regQuo);
			NumericsHelpers.Swap(ref this, ref regQuo);
		}

		public void ModDiv(ref BigIntegerBuilder regDen, ref BigIntegerBuilder regQuo)
		{
			if (regDen._iuLast == 0)
			{
				regQuo.Set(DivMod(regDen._uSmall));
				NumericsHelpers.Swap(ref this, ref regQuo);
			}
			else if (_iuLast != 0)
			{
				ModDivCore(ref this, ref regDen, fQuo: true, ref regQuo);
			}
		}

		private static void ModDivCore(ref BigIntegerBuilder regNum, ref BigIntegerBuilder regDen, bool fQuo, ref BigIntegerBuilder regQuo)
		{
			regQuo.Set(0u);
			if (regNum._iuLast < regDen._iuLast)
			{
				return;
			}
			int num = regDen._iuLast + 1;
			int num2 = regNum._iuLast - regDen._iuLast;
			int num3 = num2;
			int num4 = regNum._iuLast;
			while (true)
			{
				if (num4 < num2)
				{
					num3++;
					break;
				}
				if (regDen._rgu[num4 - num2] != regNum._rgu[num4])
				{
					if (regDen._rgu[num4 - num2] < regNum._rgu[num4])
					{
						num3++;
					}
					break;
				}
				num4--;
			}
			if (num3 == 0)
			{
				return;
			}
			if (fQuo)
			{
				regQuo.SetSizeLazy(num3);
			}
			uint num5 = regDen._rgu[num - 1];
			uint num6 = regDen._rgu[num - 2];
			int num7 = NumericsHelpers.CbitHighZero(num5);
			int num8 = 32 - num7;
			if (num7 > 0)
			{
				num5 = (num5 << num7) | (num6 >> num8);
				num6 <<= num7;
				if (num > 2)
				{
					num6 |= regDen._rgu[num - 3] >> num8;
				}
			}
			regNum.EnsureWritable();
			int num9 = num3;
			while (--num9 >= 0)
			{
				uint num10 = ((num9 + num <= regNum._iuLast) ? regNum._rgu[num9 + num] : 0u);
				ulong num11 = NumericsHelpers.MakeUlong(num10, regNum._rgu[num9 + num - 1]);
				uint num12 = regNum._rgu[num9 + num - 2];
				if (num7 > 0)
				{
					num11 = (num11 << num7) | (num12 >> num8);
					num12 <<= num7;
					if (num9 + num >= 3)
					{
						num12 |= regNum._rgu[num9 + num - 3] >> num8;
					}
				}
				ulong num13 = num11 / num5;
				ulong num14 = (uint)(num11 % num5);
				if (num13 > uint.MaxValue)
				{
					num14 += num5 * (num13 - uint.MaxValue);
					num13 = 4294967295uL;
				}
				for (; num14 <= uint.MaxValue && num13 * num6 > NumericsHelpers.MakeUlong((uint)num14, num12); num14 += num5)
				{
					num13--;
				}
				if (num13 != 0)
				{
					ulong num15 = 0uL;
					for (int i = 0; i < num; i++)
					{
						num15 += regDen._rgu[i] * num13;
						uint num16 = (uint)num15;
						num15 >>= 32;
						if (regNum._rgu[num9 + i] < num16)
						{
							num15++;
						}
						regNum._rgu[num9 + i] -= num16;
					}
					if (num10 < num15)
					{
						uint uCarry = 0u;
						for (int j = 0; j < num; j++)
						{
							uCarry = AddCarry(ref regNum._rgu[num9 + j], regDen._rgu[j], uCarry);
						}
						num13--;
					}
					regNum._iuLast = num9 + num - 1;
				}
				if (fQuo)
				{
					if (num3 == 1)
					{
						regQuo._uSmall = (uint)num13;
					}
					else
					{
						regQuo._rgu[num9] = (uint)num13;
					}
				}
			}
			regNum._iuLast = num - 1;
			regNum.Trim();
		}

		public void ShiftRight(int cbit)
		{
			if (cbit <= 0)
			{
				if (cbit < 0)
				{
					ShiftLeft(-cbit);
				}
			}
			else
			{
				ShiftRight(cbit / 32, cbit % 32);
			}
		}

		public void ShiftRight(int cuShift, int cbitShift)
		{
			if ((cuShift | cbitShift) == 0)
			{
				return;
			}
			if (cuShift > _iuLast)
			{
				Set(0u);
				return;
			}
			if (_iuLast == 0)
			{
				_uSmall >>= cbitShift;
				return;
			}
			uint[] rgu = _rgu;
			int num = _iuLast + 1;
			_iuLast -= cuShift;
			if (_iuLast == 0)
			{
				_uSmall = rgu[cuShift] >> cbitShift;
				return;
			}
			if (!_fWritable)
			{
				_rgu = new uint[_iuLast + 1];
				_fWritable = true;
			}
			if (cbitShift > 0)
			{
				int num2 = cuShift + 1;
				int num3 = 0;
				while (num2 < num)
				{
					_rgu[num3] = (rgu[num2 - 1] >> cbitShift) | (rgu[num2] << 32 - cbitShift);
					num2++;
					num3++;
				}
				_rgu[_iuLast] = rgu[num - 1] >> cbitShift;
				Trim();
			}
			else
			{
				Array.Copy(rgu, cuShift, _rgu, 0, _iuLast + 1);
			}
		}

		public void ShiftLeft(int cbit)
		{
			if (cbit <= 0)
			{
				if (cbit < 0)
				{
					ShiftRight(-cbit);
				}
			}
			else
			{
				ShiftLeft(cbit / 32, cbit % 32);
			}
		}

		public void ShiftLeft(int cuShift, int cbitShift)
		{
			int num = _iuLast + cuShift;
			uint num2 = 0u;
			if (cbitShift > 0)
			{
				num2 = High >> 32 - cbitShift;
				if (num2 != 0)
				{
					num++;
				}
			}
			if (num == 0)
			{
				_uSmall <<= cbitShift;
				return;
			}
			uint[] rgu = _rgu;
			bool flag = cuShift > 0;
			if (!_fWritable || _rgu.Length <= num)
			{
				_rgu = new uint[num + 1];
				_fWritable = true;
				flag = false;
			}
			if (_iuLast == 0)
			{
				if (num2 != 0)
				{
					_rgu[cuShift + 1] = num2;
				}
				_rgu[cuShift] = _uSmall << cbitShift;
			}
			else if (cbitShift == 0)
			{
				Array.Copy(rgu, 0, _rgu, cuShift, _iuLast + 1);
			}
			else
			{
				int num3 = _iuLast;
				int num4 = _iuLast + cuShift;
				if (num4 < num)
				{
					_rgu[num] = num2;
				}
				while (num3 > 0)
				{
					_rgu[num4] = (rgu[num3] << cbitShift) | (rgu[num3 - 1] >> 32 - cbitShift);
					num3--;
					num4--;
				}
				_rgu[cuShift] = rgu[0] << cbitShift;
			}
			_iuLast = num;
			if (flag)
			{
				Array.Clear(_rgu, 0, cuShift);
			}
		}

		private ulong GetHigh2(int cu)
		{
			if (cu - 1 <= _iuLast)
			{
				return NumericsHelpers.MakeUlong(_rgu[cu - 1], _rgu[cu - 2]);
			}
			if (cu - 2 == _iuLast)
			{
				return _rgu[cu - 2];
			}
			return 0uL;
		}

		private void ApplyCarry(int iu)
		{
			while (true)
			{
				if (iu > _iuLast)
				{
					if (_iuLast + 1 == _rgu.Length)
					{
						Array.Resize(ref _rgu, _iuLast + 2);
					}
					_rgu[++_iuLast] = 1u;
					break;
				}
				if (++_rgu[iu] == 0)
				{
					iu++;
					continue;
				}
				break;
			}
		}

		private void ApplyBorrow(int iuMin)
		{
			for (int i = iuMin; i <= _iuLast; i++)
			{
				if (_rgu[i]-- != 0)
				{
					break;
				}
			}
		}

		private static uint AddCarry(ref uint u1, uint u2, uint uCarry)
		{
			ulong num = (ulong)((long)u1 + (long)u2 + uCarry);
			u1 = (uint)num;
			return (uint)(num >> 32);
		}

		private static uint SubBorrow(ref uint u1, uint u2, uint uBorrow)
		{
			ulong num = (ulong)((long)u1 - (long)u2 - uBorrow);
			u1 = (uint)num;
			return (uint)(-(int)(num >> 32));
		}

		private static uint SubRevBorrow(ref uint u1, uint u2, uint uBorrow)
		{
			ulong num = (ulong)((long)u2 - (long)u1 - uBorrow);
			u1 = (uint)num;
			return (uint)(-(int)(num >> 32));
		}

		private static uint MulCarry(ref uint u1, uint u2, uint uCarry)
		{
			ulong num = (ulong)((long)u1 * (long)u2 + uCarry);
			u1 = (uint)num;
			return (uint)(num >> 32);
		}

		private static uint AddMulCarry(ref uint uAdd, uint uMul1, uint uMul2, uint uCarry)
		{
			ulong num = (ulong)((long)uMul1 * (long)uMul2 + uAdd + uCarry);
			uAdd = (uint)num;
			return (uint)(num >> 32);
		}

		public static void GCD(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
		{
			if ((reg1._iuLast > 0 && reg1._rgu[0] == 0) || (reg2._iuLast > 0 && reg2._rgu[0] == 0))
			{
				int val = reg1.MakeOdd();
				int val2 = reg2.MakeOdd();
				LehmerGcd(ref reg1, ref reg2);
				int num = Math.Min(val, val2);
				if (num > 0)
				{
					reg1.ShiftLeft(num);
				}
			}
			else
			{
				LehmerGcd(ref reg1, ref reg2);
			}
		}

		private static void LehmerGcd(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
		{
			int sign = 1;
			while (true)
			{
				int a = reg1._iuLast + 1;
				int b = reg2._iuLast + 1;
				if (a < b)
				{
					NumericsHelpers.Swap(ref reg1, ref reg2);
					NumericsHelpers.Swap(ref a, ref b);
				}
				if (b == 1)
				{
					if (a == 1)
					{
						reg1._uSmall = NumericsHelpers.GCD(reg1._uSmall, reg2._uSmall);
					}
					else if (reg2._uSmall != 0)
					{
						reg1.Set(NumericsHelpers.GCD(Mod(ref reg1, reg2._uSmall), reg2._uSmall));
					}
					return;
				}
				if (a == 2)
				{
					break;
				}
				if (b <= a - 2)
				{
					reg1.Mod(ref reg2);
					continue;
				}
				ulong a2 = reg1.GetHigh2(a);
				ulong b2 = reg2.GetHigh2(a);
				int num = NumericsHelpers.CbitHighZero(a2 | b2);
				if (num > 0)
				{
					a2 = (a2 << num) | (reg1._rgu[a - 3] >> 32 - num);
					b2 = (b2 << num) | (reg2._rgu[a - 3] >> 32 - num);
				}
				if (a2 < b2)
				{
					NumericsHelpers.Swap(ref a2, ref b2);
					NumericsHelpers.Swap(ref reg1, ref reg2);
				}
				if (a2 == ulong.MaxValue || b2 == ulong.MaxValue)
				{
					a2 >>= 1;
					b2 >>= 1;
				}
				if (a2 == b2)
				{
					reg1.Sub(ref sign, ref reg2);
					continue;
				}
				if (NumericsHelpers.GetHi(b2) == 0)
				{
					reg1.Mod(ref reg2);
					continue;
				}
				uint num2 = 1u;
				uint num3 = 0u;
				uint num4 = 0u;
				uint num5 = 1u;
				do
				{
					uint num6 = 1u;
					ulong num7 = a2 - b2;
					while (num7 >= b2 && num6 < 32)
					{
						num7 -= b2;
						num6++;
					}
					if (num7 >= b2)
					{
						ulong num8 = a2 / b2;
						if (num8 > uint.MaxValue)
						{
							break;
						}
						num6 = (uint)num8;
						num7 = a2 - num6 * b2;
					}
					ulong num9 = (ulong)(num2 + (long)num6 * (long)num4);
					ulong num10 = (ulong)(num3 + (long)num6 * (long)num5);
					if (num9 > int.MaxValue || num10 > int.MaxValue || num7 < num10 || num7 + num9 > b2 - num4)
					{
						break;
					}
					num2 = (uint)num9;
					num3 = (uint)num10;
					a2 = num7;
					if (a2 <= num3)
					{
						break;
					}
					num6 = 1u;
					num7 = b2 - a2;
					while (num7 >= a2 && num6 < 32)
					{
						num7 -= a2;
						num6++;
					}
					if (num7 >= a2)
					{
						ulong num11 = b2 / a2;
						if (num11 > uint.MaxValue)
						{
							break;
						}
						num6 = (uint)num11;
						num7 = b2 - num6 * a2;
					}
					num9 = (ulong)(num5 + (long)num6 * (long)num3);
					num10 = (ulong)(num4 + (long)num6 * (long)num2);
					if (num9 > int.MaxValue || num10 > int.MaxValue || num7 < num10 || num7 + num9 > a2 - num3)
					{
						break;
					}
					num5 = (uint)num9;
					num4 = (uint)num10;
					b2 = num7;
				}
				while (b2 > num4);
				if (num3 == 0)
				{
					if (a2 / 2 >= b2)
					{
						reg1.Mod(ref reg2);
					}
					else
					{
						reg1.Sub(ref sign, ref reg2);
					}
					continue;
				}
				reg1.SetSizeKeep(b, 0);
				reg2.SetSizeKeep(b, 0);
				int num12 = 0;
				int num13 = 0;
				for (int i = 0; i < b; i++)
				{
					uint num14 = reg1._rgu[i];
					uint num15 = reg2._rgu[i];
					long num16 = (long)num14 * (long)num2 - (long)num15 * (long)num3 + num12;
					long num17 = (long)num15 * (long)num5 - (long)num14 * (long)num4 + num13;
					num12 = (int)(num16 >> 32);
					num13 = (int)(num17 >> 32);
					reg1._rgu[i] = (uint)num16;
					reg2._rgu[i] = (uint)num17;
				}
				reg1.Trim();
				reg2.Trim();
			}
			reg1.Set(NumericsHelpers.GCD(reg1.GetHigh2(2), reg2.GetHigh2(2)));
		}

		public int CbitLowZero()
		{
			if (_iuLast == 0)
			{
				if ((_uSmall & (true ? 1u : 0u)) != 0 || _uSmall == 0)
				{
					return 0;
				}
				return NumericsHelpers.CbitLowZero(_uSmall);
			}
			int i;
			for (i = 0; _rgu[i] == 0; i++)
			{
			}
			int num = NumericsHelpers.CbitLowZero(_rgu[i]);
			return num + i * 32;
		}

		public int MakeOdd()
		{
			int num = CbitLowZero();
			if (num > 0)
			{
				ShiftRight(num);
			}
			return num;
		}
	}
	internal static class BigNumber
	{
		internal struct BigNumberBuffer
		{
			public StringBuilder digits;

			public int precision;

			public int scale;

			public bool sign;

			public static BigNumberBuffer Create()
			{
				BigNumberBuffer result = default(BigNumberBuffer);
				result.digits = new StringBuilder();
				return result;
			}
		}

		private const NumberStyles InvalidNumberStyles = ~(NumberStyles.Any | NumberStyles.AllowHexSpecifier);

		internal static bool TryValidateParseStyleInteger(NumberStyles style, out ArgumentException e)
		{
			if (((uint)style & 0xFFFFFC00u) != 0)
			{
				e = new ArgumentException(System.SR.GetString("Argument_InvalidNumberStyles", "style"));
				return false;
			}
			if ((style & NumberStyles.AllowHexSpecifier) != 0 && ((uint)style & 0xFFFFFDFCu) != 0)
			{
				e = new ArgumentException(System.SR.GetString("Argument_InvalidHexStyle"));
				return false;
			}
			e = null;
			return true;
		}

		[SecuritySafeCritical]
		internal unsafe static bool TryParseBigInteger(string value, NumberStyles style, NumberFormatInfo info, out BigInteger result)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			result = BigInteger.Zero;
			if (!TryValidateParseStyleInteger(style, out var e))
			{
				throw e;
			}
			BigNumberBuffer number = BigNumberBuffer.Create();
			byte* ptr = stackalloc byte[(int)(uint)NumberBuffer.NumberBufferBytes];
			NumberBuffer val = default(NumberBuffer);
			((NumberBuffer)(ref val))..ctor(ptr);
			result = 0;
			if (!Number.TryStringToNumber(value, style, ref val, number.digits, info, false))
			{
				return false;
			}
			number.precision = val.precision;
			number.scale = val.scale;
			number.sign = val.sign;
			if ((style & NumberStyles.AllowHexSpecifier) != 0)
			{
				if (!HexNumberToBigInteger(ref number, ref result))
				{
					return false;
				}
			}
			else if (!NumberToBigInteger(ref number, ref result))
			{
				return false;
			}
			return true;
		}

		internal static BigInteger ParseBigInteger(string value, NumberStyles style, NumberFormatInfo info)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			if (!TryValidateParseStyleInteger(style, out var e))
			{
				throw e;
			}
			BigInteger result = BigInteger.Zero;
			if (!TryParseBigInteger(value, style, info, out result))
			{
				throw new FormatException(System.SR.GetString("Overflow_ParseBigInteger"));
			}
			return result;
		}

		private static bool HexNumberToBigInteger(ref BigNumberBuffer number, ref BigInteger value)
		{
			if (number.digits == null || number.digits.Length == 0)
			{
				return false;
			}
			int num = number.digits.Length - 1;
			byte[] array = new byte[num / 2 + num % 2];
			bool flag = false;
			bool flag2 = false;
			int num2 = 0;
			for (int num3 = num - 1; num3 > -1; num3--)
			{
				char c = number.digits[num3];
				byte b = ((c >= '0' && c <= '9') ? ((byte)(c - 48)) : ((c < 'A' || c > 'F') ? ((byte)(c - 97 + 10)) : ((byte)(c - 65 + 10))));
				if (num3 == 0 && (b & 8) == 8)
				{
					flag2 = true;
				}
				if (flag)
				{
					array[num2] = (byte)(array[num2] | (b << 4));
					num2++;
				}
				else
				{
					array[num2] = (flag2 ? ((byte)(b | 0xF0u)) : b);
				}
				flag = !flag;
			}
			value = new BigInteger(array);
			return true;
		}

		private static bool NumberToBigInteger(ref BigNumberBuffer number, ref BigInteger value)
		{
			int num = number.scale;
			int index = 0;
			value = 0;
			while (--num >= 0)
			{
				value *= (BigInteger)10;
				if (number.digits[index] != 0)
				{
					value += (BigInteger)(number.digits[index++] - 48);
				}
			}
			while (number.digits[index] != 0)
			{
				if (number.digits[index++] != '0')
				{
					return false;
				}
			}
			if (number.sign)
			{
				value = -value;
			}
			return true;
		}

		internal static char ParseFormatSpecifier(string format, out int digits)
		{
			digits = -1;
			if (string.IsNullOrEmpty(format))
			{
				return 'R';
			}
			int num = 0;
			char c = format[num];
			if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
			{
				num++;
				int num2 = -1;
				if (num < format.Length && format[num] >= '0' && format[num] <= '9')
				{
					num2 = format[num++] - 48;
					while (num < format.Length && format[num] >= '0' && format[num] <= '9')
					{
						num2 = num2 * 10 + (format[num++] - 48);
						if (num2 >= 10)
						{
							break;
						}
					}
				}
				if (num >= format.Length || format[num] == '\0')
				{
					digits = num2;
					return c;
				}
			}
			return '\0';
		}

		private static string FormatBigIntegerToHexString(BigInteger value, char format, int digits, NumberFormatInfo info)
		{
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array = value.ToByteArray();
			string text = null;
			int num = array.Length - 1;
			if (num > -1)
			{
				bool flag = false;
				byte b = array[num];
				if (b > 247)
				{
					b -= 240;
					flag = true;
				}
				if (b < 8 || flag)
				{
					text = string.Format(CultureInfo.InvariantCulture, "{0}1", new object[1] { format });
					stringBuilder.Append(b.ToString(text, info));
					num--;
				}
			}
			if (num > -1)
			{
				text = string.Format(CultureInfo.InvariantCulture, "{0}2", new object[1] { format });
				while (num > -1)
				{
					stringBuilder.Append(array[num--].ToString(text, info));
				}
			}
			if (digits > 0 && digits > stringBuilder.Length)
			{
				stringBuilder.Insert(0, (value._sign >= 0) ? "0" : ((format == 'x') ? "f" : "F"), digits - stringBuilder.Length);
			}
			return stringBuilder.ToString();
		}

		[SecuritySafeCritical]
		internal unsafe static string FormatBigInteger(BigInteger value, string format, NumberFormatInfo info)
		{
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			int digits = 0;
			char c = ParseFormatSpecifier(format, out digits);
			int num;
			switch (c)
			{
			case 'X':
			case 'x':
				return FormatBigIntegerToHexString(value, c, digits, info);
			default:
				num = ((c == 'R') ? 1 : 0);
				break;
			case 'D':
			case 'G':
			case 'd':
			case 'g':
			case 'r':
				num = 1;
				break;
			}
			bool flag = (byte)num != 0;
			if (value._bits == null)
			{
				if (c == 'g' || c == 'G' || c == 'r' || c == 'R')
				{
					format = ((digits <= 0) ? "D" : string.Format(CultureInfo.InvariantCulture, "D{0}", new object[1] { digits.ToString(CultureInfo.InvariantCulture) }));
				}
				return value._sign.ToString(format, info);
			}
			int num2 = BigInteger.Length(value._bits);
			uint[] array;
			int num4;
			int num5;
			checked
			{
				int num3;
				try
				{
					num3 = unchecked(checked(num2 * 10) / 9) + 2;
				}
				catch (OverflowException innerException)
				{
					throw new FormatException(System.SR.GetString("Format_TooLarge"), innerException);
				}
				array = new uint[num3];
				num4 = 0;
				num5 = num2;
			}
			while (--num5 >= 0)
			{
				uint num6 = value._bits[num5];
				for (int i = 0; i < num4; i++)
				{
					ulong num7 = NumericsHelpers.MakeUlong(array[i], num6);
					array[i] = (uint)(num7 % 1000000000);
					num6 = (uint)(num7 / 1000000000);
				}
				if (num6 != 0)
				{
					array[num4++] = num6 % 1000000000;
					num6 /= 1000000000;
					if (num6 != 0)
					{
						array[num4++] = num6;
					}
				}
			}
			int num8;
			char[] array2;
			int num10;
			checked
			{
				try
				{
					num8 = num4 * 9;
				}
				catch (OverflowException innerException2)
				{
					throw new FormatException(System.SR.GetString("Format_TooLarge"), innerException2);
				}
				if (flag)
				{
					if (digits > 0 && digits > num8)
					{
						num8 = digits;
					}
					if (value._sign < 0)
					{
						try
						{
							num8 += info.NegativeSign.Length;
						}
						catch (OverflowException innerException3)
						{
							throw new FormatException(System.SR.GetString("Format_TooLarge"), innerException3);
						}
					}
				}
				int num9;
				try
				{
					num9 = num8 + 1;
				}
				catch (OverflowException innerException4)
				{
					throw new FormatException(System.SR.GetString("Format_TooLarge"), innerException4);
				}
				array2 = new char[num9];
				num10 = num8;
			}
			for (int j = 0; j < num4 - 1; j++)
			{
				uint num11 = array[j];
				int num12 = 9;
				while (--num12 >= 0)
				{
					array2[--num10] = (char)(48 + num11 % 10);
					num11 /= 10;
				}
			}
			for (uint num13 = array[num4 - 1]; num13 != 0; num13 /= 10)
			{
				array2[--num10] = (char)(48 + num13 % 10);
			}
			if (!flag)
			{
				byte* ptr = stackalloc byte[(int)(uint)NumberBuffer.NumberBufferBytes];
				NumberBuffer val = default(NumberBuffer);
				((NumberBuffer)(ref val))..ctor(ptr);
				val.sign = value._sign < 0;
				val.precision = 29;
				*val.digits = '\0';
				val.scale = num8 - num10;
				int num14 = Math.Min(num10 + 50, num8);
				for (int k = num10; k < num14; k++)
				{
					val.digits[k - num10] = array2[k];
				}
				fixed (char* ptr2 = array2)
				{
					return Number.FormatNumberBuffer(((NumberBuffer)(ref val)).PackForNative(), format, info, ptr2 + num10);
				}
			}
			int num15 = num8 - num10;
			while (digits > 0 && digits > num15)
			{
				array2[--num10] = '0';
				digits--;
			}
			if (value._sign < 0)
			{
				string negativeSign = info.NegativeSign;
				for (int num16 = info.NegativeSign.Length - 1; num16 > -1; num16--)
				{
					array2[--num10] = info.NegativeSign[num16];
				}
			}
			return new string(array2, num10, num8 - num10);
		}
	}
	[StructLayout(LayoutKind.Explicit)]
	internal struct DoubleUlong
	{
		[FieldOffset(0)]
		public double dbl;

		[FieldOffset(0)]
		public ulong uu;
	}
	internal static class NumericsHelpers
	{
		private const int kcbitUint = 32;

		public static void GetDoubleParts(double dbl, out int sign, out int exp, out ulong man, out bool fFinite)
		{
			DoubleUlong doubleUlong = default(DoubleUlong);
			doubleUlong.uu = 0uL;
			doubleUlong.dbl = dbl;
			sign = 1 - ((int)(doubleUlong.uu >> 62) & 2);
			man = doubleUlong.uu & 0xFFFFFFFFFFFFFuL;
			exp = (int)(doubleUlong.uu >> 52) & 0x7FF;
			if (exp == 0)
			{
				fFinite = true;
				if (man != 0L)
				{
					exp = -1074;
				}
			}
			else if (exp == 2047)
			{
				fFinite = false;
				exp = int.MaxValue;
			}
			else
			{
				fFinite = true;
				man |= 4503599627370496uL;
				exp -= 1075;
			}
		}

		public static double GetDoubleFromParts(int sign, int exp, ulong man)
		{
			DoubleUlong doubleUlong = default(DoubleUlong);
			doubleUlong.dbl = 0.0;
			if (man == 0L)
			{
				doubleUlong.uu = 0uL;
			}
			else
			{
				int num = CbitHighZero(man) - 11;
				man = ((num >= 0) ? (man << num) : (man >> -num));
				exp -= num;
				exp += 1075;
				if (exp >= 2047)
				{
					doubleUlong.uu = 9218868437227405312uL;
				}
				else if (exp <= 0)
				{
					exp--;
					if (exp < -52)
					{
						doubleUlong.uu = 0uL;
					}
					else
					{
						doubleUlong.uu = man >> -exp;
					}
				}
				else
				{
					doubleUlong.uu = (man & 0xFFFFFFFFFFFFFuL) | (ulong)((long)exp << 52);
				}
			}
			if (sign < 0)
			{
				doubleUlong.uu |= 9223372036854775808uL;
			}
			return doubleUlong.dbl;
		}

		public static uint[] DangerousMakeTwosComplement(uint[] d)
		{
			int i = 0;
			uint num = 0u;
			for (; i < d.Length; i++)
			{
				num = (d[i] = ~d[i] + 1);
				if (num != 0)
				{
					i++;
					break;
				}
			}
			if (num != 0)
			{
				for (; i < d.Length; i++)
				{
					d[i] = ~d[i];
				}
			}
			else
			{
				d = resize(d, d.Length + 1);
				d[^1] = 1u;
			}
			return d;
		}

		public static uint[] resize(uint[] v, int len)
		{
			if (v.Length == len)
			{
				return v;
			}
			uint[] array = new uint[len];
			int num = Math.Min(v.Length, len);
			for (int i = 0; i < num; i++)
			{
				array[i] = v[i];
			}
			return array;
		}

		public static void Swap<T>(ref T a, ref T b)
		{
			T val = a;
			a = b;
			b = val;
		}

		public static uint GCD(uint u1, uint u2)
		{
			if (u1 >= u2)
			{
				goto IL_0004;
			}
			goto IL_0021;
			IL_0021:
			if (u1 == 0)
			{
				return u2;
			}
			int num = 32;
			while (true)
			{
				u2 -= u1;
				if (u2 < u1)
				{
					break;
				}
				if (--num == 0)
				{
					u2 %= u1;
					break;
				}
			}
			goto IL_0004;
			IL_0004:
			if (u2 == 0)
			{
				return u1;
			}
			int num2 = 32;
			while (true)
			{
				u1 -= u2;
				if (u1 < u2)
				{
					break;
				}
				if (--num2 == 0)
				{
					u1 %= u2;
					break;
				}
			}
			goto IL_0021;
		}

		public static ulong GCD(ulong uu1, ulong uu2)
		{
			if (uu1 >= uu2)
			{
				goto IL_0004;
			}
			goto IL_0026;
			IL_0026:
			if (uu2 > uint.MaxValue)
			{
				if (uu1 == 0L)
				{
					return uu2;
				}
				int num = 32;
				while (true)
				{
					uu2 -= uu1;
					if (uu2 < uu1)
					{
						break;
					}
					if (--num == 0)
					{
						uu2 %= uu1;
						break;
					}
				}
				goto IL_0004;
			}
			goto IL_004a;
			IL_004a:
			uint num2 = (uint)uu1;
			uint num3 = (uint)uu2;
			if (num2 >= num3)
			{
				goto IL_0054;
			}
			goto IL_0073;
			IL_0073:
			if (num2 == 0)
			{
				return num3;
			}
			int num4 = 32;
			while (true)
			{
				num3 -= num2;
				if (num3 < num2)
				{
					break;
				}
				if (--num4 == 0)
				{
					num3 %= num2;
					break;
				}
			}
			goto IL_0054;
			IL_0004:
			if (uu1 > uint.MaxValue)
			{
				if (uu2 == 0L)
				{
					return uu1;
				}
				int num5 = 32;
				while (true)
				{
					uu1 -= uu2;
					if (uu1 < uu2)
					{
						break;
					}
					if (--num5 == 0)
					{
						uu1 %= uu2;
						break;
					}
				}
				goto IL_0026;
			}
			goto IL_004a;
			IL_0054:
			if (num3 == 0)
			{
				return num2;
			}
			int num6 = 32;
			while (true)
			{
				num2 -= num3;
				if (num2 < num3)
				{
					break;
				}
				if (--num6 == 0)
				{
					num2 %= num3;
					break;
				}
			}
			goto IL_0073;
		}

		public static ulong MakeUlong(uint uHi, uint uLo)
		{
			return ((ulong)uHi << 32) | uLo;
		}

		public static uint GetLo(ulong uu)
		{
			return (uint)uu;
		}

		public static uint GetHi(ulong uu)
		{
			return (uint)(uu >> 32);
		}

		public static uint Abs(int a)
		{
			uint num = (uint)(a >> 31);
			return ((uint)a ^ num) - num;
		}

		public static uint CombineHash(uint u1, uint u2)
		{
			return ((u1 << 7) | (u1 >> 25)) ^ u2;
		}

		public static int CombineHash(int n1, int n2)
		{
			return (int)CombineHash((uint)n1, (uint)n2);
		}

		public static int CbitHighZero(uint u)
		{
			if (u == 0)
			{
				return 32;
			}
			int num = 0;
			if ((u & 0xFFFF0000u) == 0)
			{
				num += 16;
				u <<= 16;
			}
			if ((u & 0xFF000000u) == 0)
			{
				num += 8;
				u <<= 8;
			}
			if ((u & 0xF0000000u) == 0)
			{
				num += 4;
				u <<= 4;
			}
			if ((u & 0xC0000000u) == 0)
			{
				num += 2;
				u <<= 2;
			}
			if ((u & 0x80000000u) == 0)
			{
				num++;
			}
			return num;
		}

		public static int CbitLowZero(uint u)
		{
			if (u == 0)
			{
				return 32;
			}
			int num = 0;
			if ((u & 0xFFFF) == 0)
			{
				num += 16;
				u >>= 16;
			}
			if ((u & 0xFF) == 0)
			{
				num += 8;
				u >>= 8;
			}
			if ((u & 0xF) == 0)
			{
				num += 4;
				u >>= 4;
			}
			if ((u & 3) == 0)
			{
				num += 2;
				u >>= 2;
			}
			if ((u & 1) == 0)
			{
				num++;
			}
			return num;
		}

		public static int CbitHighZero(ulong uu)
		{
			if ((uu & 0xFFFFFFFF00000000uL) == 0L)
			{
				return 32 + CbitHighZero((uint)uu);
			}
			return CbitHighZero((uint)(uu >> 32));
		}
	}
	[Serializable]
	[__DynamicallyInvokable]
	public struct Complex : IEquatable<Complex>, IFormattable
	{
		private double m_real;

		private double m_imaginary;

		private const double LOG_10_INV = 0.43429448190325;

		[__DynamicallyInvokable]
		public static readonly Complex Zero = new Complex(0.0, 0.0);

		[__DynamicallyInvokable]
		public static readonly Complex One = new Complex(1.0, 0.0);

		[__DynamicallyInvokable]
		public static readonly Complex ImaginaryOne = new Complex(0.0, 1.0);

		[__DynamicallyInvokable]
		public double Real
		{
			[__DynamicallyInvokable]
			get
			{
				return m_real;
			}
		}

		[__DynamicallyInvokable]
		public double Imaginary
		{
			[__DynamicallyInvokable]
			get
			{
				return m_imaginary;
			}
		}

		[__DynamicallyInvokable]
		public double Magnitude
		{
			[__DynamicallyInvokable]
			get
			{
				return Abs(this);
			}
		}

		[__DynamicallyInvokable]
		public double Phase
		{
			[__DynamicallyInvokable]
			get
			{
				return Math.Atan2(m_imaginary, m_real);
			}
		}

		[__DynamicallyInvokable]
		public Complex(double real, double imaginary)
		{
			m_real = real;
			m_imaginary = imaginary;
		}

		[__DynamicallyInvokable]
		public static Complex FromPolarCoordinates(double magnitude, double phase)
		{
			return new Complex(magnitude * Math.Cos(phase), magnitude * Math.Sin(phase));
		}

		[__DynamicallyInvokable]
		public static Complex Negate(Complex value)
		{
			return -value;
		}

		[__DynamicallyInvokable]
		public static Complex Add(Complex left, Complex right)
		{
			return left + right;
		}

		[__DynamicallyInvokable]
		public static Complex Subtract(Complex left, Complex right)
		{
			return left - right;
		}

		[__DynamicallyInvokable]
		public static Complex Multiply(Complex left, Complex right)
		{
			return left * right;
		}

		[__DynamicallyInvokable]
		public static Complex Divide(Complex dividend, Complex divisor)
		{
			return dividend / divisor;
		}

		[__DynamicallyInvokable]
		public static Complex operator -(Complex value)
		{
			return new Complex

FuriousButtplug/System.Runtime.Serialization.dll

Decompiled 6 months ago
#define TRACE
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Configuration;
using System.Runtime.Serialization.Diagnostics;
using System.Runtime.Serialization.Diagnostics.Application;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Json;
using System.Security;
using System.Security.Permissions;
using System.ServiceModel.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.XPath;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("System.ServiceModel.Web, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("Microsoft.ServiceModel.Web.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityCritical]
[assembly: SecurityRules(SecurityRuleSet.Level1)]
[assembly: AssemblyTitle("System.Runtime.Serialization.dll")]
[assembly: AssemblyDescription("System.Runtime.Serialization.dll")]
[assembly: AssemblyDefaultAlias("System.Runtime.Serialization.dll")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.8.9241.0")]
[assembly: AssemblyInformationalVersion("4.8.9241.0")]
[assembly: SatelliteContractVersion("4.0.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("F:\\dd\\tools\\devdiv\\EcmaPublicKey.snk")]
[assembly: AssemblySignatureKey("002400000c800000140100000602000000240000525341310008000001000100613399aff18ef1a2c2514a273a42d9042b72321f1757102df9ebada69923e2738406c21e5b801552ab8d200a65a235e001ac9adc25f2d811eb09496a4c6a59d4619589c69f5baf0c4179a47311d92555cd006acc8b5959f2bd6e10e360c34537a1d266da8085856583c85d81da7f3ec01ed9564c58d93d713cd0172c8e23a10f0239b80c96b07736f5d8b022542a4e74251a5f432824318b3539a5a087f8e53d2f135f9ca47f3bb2e10aff0af0849504fb7cea3ff192dc8de0edad64c68efde34c56d302ad55fd6e80f302d5efcdeae953658d3452561b5f36c542efdbdd9f888538d374cef106acf7d93a4445c3c73cd911f0571aaf3d54da12b11ddec375b3", "a5a866e1ee186f807668209f3b11236ace5e21f117803a3143abb126dd035d7d2f876b6938aaf2ee3414d5420d753621400db44a49c486ce134300a2106adb6bdb433590fef8ad5c43cba82290dc49530effd86523d9483c00f458af46890036b0e2c61d077d7fbac467a506eba29e467a87198b053c749aa2a4d2840c784e6d")]
[assembly: ComCompatibleVersion(1, 0, 3300, 0)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.0.0")]
[module: UnverifiableCode]
internal static class FXAssembly
{
	internal const string Version = "4.0.0.0";
}
internal static class ThisAssembly
{
	internal const string Title = "System.Runtime.Serialization.dll";

	internal const string Description = "System.Runtime.Serialization.dll";

	internal const string DefaultAlias = "System.Runtime.Serialization.dll";

	internal const string Copyright = "© Microsoft Corporation.  All rights reserved.";

	internal const string Version = "4.0.0.0";

	internal const string InformationalVersion = "4.8.9241.0";

	internal const string DailyBuildNumberStr = "30319";

	internal const string BuildRevisionStr = "0";

	internal const int DailyBuildNumber = 30319;
}
internal static class AssemblyRef
{
	internal const string EcmaPublicKey = "b77a5c561934e089";

	internal const string EcmaPublicKeyToken = "b77a5c561934e089";

	internal const string EcmaPublicKeyFull = "00000000000000000400000000000000";

	internal const string SilverlightPublicKey = "31bf3856ad364e35";

	internal const string SilverlightPublicKeyToken = "31bf3856ad364e35";

	internal const string SilverlightPublicKeyFull = "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9";

	internal const string SilverlightPlatformPublicKey = "7cec85d7bea7798e";

	internal const string SilverlightPlatformPublicKeyToken = "7cec85d7bea7798e";

	internal const string SilverlightPlatformPublicKeyFull = "00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB";

	internal const string PlatformPublicKey = "b77a5c561934e089";

	internal const string PlatformPublicKeyToken = "b77a5c561934e089";

	internal const string PlatformPublicKeyFull = "00000000000000000400000000000000";

	internal const string Mscorlib = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemData = "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemDataOracleClient = "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string System = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemCore = "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemNumerics = "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemRuntimeRemoting = "System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemThreadingTasksDataflow = "System.Threading.Tasks.Dataflow, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemWindowsForms = "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemXml = "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string MicrosoftPublicKey = "b03f5f7f11d50a3a";

	internal const string MicrosoftPublicKeyToken = "b03f5f7f11d50a3a";

	internal const string MicrosoftPublicKeyFull = "002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293";

	internal const string SharedLibPublicKey = "31bf3856ad364e35";

	internal const string SharedLibPublicKeyToken = "31bf3856ad364e35";

	internal const string SharedLibPublicKeyFull = "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9";

	internal const string SystemComponentModelDataAnnotations = "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemConfiguration = "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemConfigurationInstall = "System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDeployment = "System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDesign = "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDirectoryServices = "System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDrawingDesign = "System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemDrawing = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemEnterpriseServices = "System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemManagement = "System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemMessaging = "System.Messaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemNetHttp = "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemNetHttpWebRequest = "System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemRuntimeSerializationFormattersSoap = "System.Runtime.Serialization.Formatters.Soap, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemRuntimeWindowsRuntime = "System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemRuntimeWindowsRuntimeUIXaml = "System.Runtime.WindowsRuntimeUIXaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemSecurity = "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemServiceModelWeb = "System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemServiceProcess = "System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWeb = "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebAbstractions = "System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebDynamicData = "System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebDynamicDataDesign = "System.Web.DynamicData.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebEntityDesign = "System.Web.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	internal const string SystemWebExtensions = "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebExtensionsDesign = "System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebMobile = "System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebRegularExpressions = "System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string SystemWebRouting = "System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string SystemWebServices = "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string WindowsBase = "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

	internal const string MicrosoftVisualStudio = "Microsoft.VisualStudio, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVisualStudioWindowsForms = "Microsoft.VisualStudio.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string VJSharpCodeProvider = "VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string ASPBrowserCapsPublicKey = "b7bd7678b977bd8f";

	internal const string ASPBrowserCapsFactory = "ASP.BrowserCapsFactory, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7bd7678b977bd8f";

	internal const string MicrosoftVSDesigner = "Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVisualStudioWeb = "Microsoft.VisualStudio.Web, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftWebDesign = "Microsoft.Web.Design.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftVSDesignerMobile = "Microsoft.VSDesigner.Mobile, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	internal const string MicrosoftJScript = "Microsoft.JScript, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
}
namespace System
{
	internal static class AppContextDefaultValues
	{
		public static void PopulateDefaultValues()
		{
			ParseTargetFrameworkName(out var identifier, out var profile, out var version);
			PopulateDefaultValuesPartial(identifier, profile, version);
		}

		private static void ParseTargetFrameworkName(out string identifier, out string profile, out int version)
		{
			string targetFrameworkName = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
			if (!TryParseFrameworkName(targetFrameworkName, out identifier, out version, out profile))
			{
				identifier = ".NETFramework";
				version = 40000;
				profile = string.Empty;
			}
		}

		private static bool TryParseFrameworkName(string frameworkName, out string identifier, out int version, out string profile)
		{
			identifier = (profile = string.Empty);
			version = 0;
			if (frameworkName == null || frameworkName.Length == 0)
			{
				return false;
			}
			string[] array = frameworkName.Split(new char[1] { ',' });
			version = 0;
			if (array.Length < 2 || array.Length > 3)
			{
				return false;
			}
			identifier = array[0].Trim();
			if (identifier.Length == 0)
			{
				return false;
			}
			bool flag = false;
			profile = null;
			for (int i = 1; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { '=' });
				if (array2.Length != 2)
				{
					return false;
				}
				string text = array2[0].Trim();
				string text2 = array2[1].Trim();
				if (text.Equals("Version", StringComparison.OrdinalIgnoreCase))
				{
					flag = true;
					if (text2.Length > 0 && (text2[0] == 'v' || text2[0] == 'V'))
					{
						text2 = text2.Substring(1);
					}
					Version version2 = new Version(text2);
					version = version2.Major * 10000;
					if (version2.Minor > 0)
					{
						version += version2.Minor * 100;
					}
					if (version2.Build > 0)
					{
						version += version2.Build;
					}
				}
				else
				{
					if (!text.Equals("Profile", StringComparison.OrdinalIgnoreCase))
					{
						return false;
					}
					if (!string.IsNullOrEmpty(text2))
					{
						profile = text2;
					}
				}
			}
			if (!flag)
			{
				return false;
			}
			return true;
		}

		private static void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int version)
		{
			if (platformIdentifier == ".NETCore" || platformIdentifier == ".NETFramework")
			{
				if (version <= 40601)
				{
					LocalAppContext.DefineSwitchDefault("Switch.System.Runtime.Serialization.DoNotUseTimeZoneInfo", initialValue: true);
				}
				if (version <= 40602)
				{
					LocalAppContext.DefineSwitchDefault(LocalAppContextSwitches.DoNotUseEcmaScriptV6EscapeControlCharacterKeyString, initialValue: true);
				}
			}
		}
	}
	internal static class LocalAppContext
	{
		private delegate bool TryGetSwitchDelegate(string switchName, out bool value);

		private static TryGetSwitchDelegate TryGetSwitchFromCentralAppContext;

		private static bool s_canForwardCalls;

		private static Dictionary<string, bool> s_switchMap;

		private static readonly object s_syncLock;

		private static bool DisableCaching { get; set; }

		static LocalAppContext()
		{
			s_switchMap = new Dictionary<string, bool>();
			s_syncLock = new object();
			s_canForwardCalls = SetupDelegate();
			AppContextDefaultValues.PopulateDefaultValues();
			DisableCaching = IsSwitchEnabled("TestSwitch.LocalAppContext.DisableCaching");
		}

		public static bool IsSwitchEnabled(string switchName)
		{
			if (s_canForwardCalls && TryGetSwitchFromCentralAppContext(switchName, out var value))
			{
				return value;
			}
			return IsSwitchEnabledLocal(switchName);
		}

		private static bool IsSwitchEnabledLocal(string switchName)
		{
			bool flag;
			bool value;
			lock (s_switchMap)
			{
				flag = s_switchMap.TryGetValue(switchName, out value);
			}
			if (flag)
			{
				return value;
			}
			return false;
		}

		private static bool SetupDelegate()
		{
			Type type = typeof(object).Assembly.GetType("System.AppContext");
			if (type == null)
			{
				return false;
			}
			MethodInfo method = type.GetMethod("TryGetSwitch", BindingFlags.Static | BindingFlags.Public, null, new Type[2]
			{
				typeof(string),
				typeof(bool).MakeByRefType()
			}, null);
			if (method == null)
			{
				return false;
			}
			TryGetSwitchFromCentralAppContext = (TryGetSwitchDelegate)Delegate.CreateDelegate(typeof(TryGetSwitchDelegate), method);
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool GetCachedSwitchValue(string switchName, ref int switchValue)
		{
			if (switchValue < 0)
			{
				return false;
			}
			if (switchValue > 0)
			{
				return true;
			}
			return GetCachedSwitchValueInternal(switchName, ref switchValue);
		}

		private static bool GetCachedSwitchValueInternal(string switchName, ref int switchValue)
		{
			if (DisableCaching)
			{
				return IsSwitchEnabled(switchName);
			}
			bool flag = IsSwitchEnabled(switchName);
			switchValue = (flag ? 1 : (-1));
			return flag;
		}

		internal static void DefineSwitchDefault(string switchName, bool initialValue)
		{
			s_switchMap[switchName] = initialValue;
		}
	}
}
namespace System.Xml
{
	internal abstract class ArrayHelper<TArgument, TArray>
	{
		public TArray[] ReadArray(XmlDictionaryReader reader, TArgument localName, TArgument namespaceUri, int maxArrayLength)
		{
			TArray[][] array = null;
			TArray[] array2 = null;
			int num = 0;
			int num2 = 0;
			if (reader.TryGetArrayLength(out var count))
			{
				if (count > maxArrayLength)
				{
					XmlExceptionHelper.ThrowMaxArrayLengthOrMaxItemsQuotaExceeded(reader, maxArrayLength);
				}
				if (count > 65535)
				{
					count = 65535;
				}
			}
			else
			{
				count = 32;
			}
			while (true)
			{
				array2 = new TArray[count];
				int i;
				int num3;
				for (i = 0; i < array2.Length; i += num3)
				{
					num3 = ReadArray(reader, localName, namespaceUri, array2, i, array2.Length - i);
					if (num3 == 0)
					{
						break;
					}
				}
				if (num2 > maxArrayLength - i)
				{
					XmlExceptionHelper.ThrowMaxArrayLengthOrMaxItemsQuotaExceeded(reader, maxArrayLength);
				}
				num2 += i;
				if (i < array2.Length || reader.NodeType == XmlNodeType.EndElement)
				{
					break;
				}
				if (array == null)
				{
					array = new TArray[32][];
				}
				array[num++] = array2;
				count *= 2;
			}
			if (num2 != array2.Length || num > 0)
			{
				TArray[] array3 = new TArray[num2];
				int num4 = 0;
				for (int j = 0; j < num; j++)
				{
					Array.Copy(array[j], 0, array3, num4, array[j].Length);
					num4 += array[j].Length;
				}
				Array.Copy(array2, 0, array3, num4, num2 - num4);
				array2 = array3;
			}
			return array2;
		}

		public void WriteArray(XmlDictionaryWriter writer, string prefix, TArgument localName, TArgument namespaceUri, XmlDictionaryReader reader)
		{
			int count = ((!reader.TryGetArrayLength(out count)) ? 256 : Math.Min(count, 256));
			TArray[] array = new TArray[count];
			while (true)
			{
				int num = ReadArray(reader, localName, namespaceUri, array, 0, array.Length);
				if (num != 0)
				{
					WriteArray(writer, prefix, localName, namespaceUri, array, 0, num);
					continue;
				}
				break;
			}
		}

		protected abstract int ReadArray(XmlDictionaryReader reader, TArgument localName, TArgument namespaceUri, TArray[] array, int offset, int count);

		protected abstract void WriteArray(XmlDictionaryWriter writer, string prefix, TArgument localName, TArgument namespaceUri, TArray[] array, int offset, int count);
	}
	internal class BooleanArrayHelperWithString : ArrayHelper<string, bool>
	{
		public static readonly BooleanArrayHelperWithString Instance = new BooleanArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, bool[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, bool[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class BooleanArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, bool>
	{
		public static readonly BooleanArrayHelperWithDictionaryString Instance = new BooleanArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int16ArrayHelperWithString : ArrayHelper<string, short>
	{
		public static readonly Int16ArrayHelperWithString Instance = new Int16ArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, short[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, short[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int16ArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, short>
	{
		public static readonly Int16ArrayHelperWithDictionaryString Instance = new Int16ArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, short[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, short[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int32ArrayHelperWithString : ArrayHelper<string, int>
	{
		public static readonly Int32ArrayHelperWithString Instance = new Int32ArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, int[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, int[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int32ArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, int>
	{
		public static readonly Int32ArrayHelperWithDictionaryString Instance = new Int32ArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int64ArrayHelperWithString : ArrayHelper<string, long>
	{
		public static readonly Int64ArrayHelperWithString Instance = new Int64ArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, long[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, long[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class Int64ArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, long>
	{
		public static readonly Int64ArrayHelperWithDictionaryString Instance = new Int64ArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, long[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, long[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class SingleArrayHelperWithString : ArrayHelper<string, float>
	{
		public static readonly SingleArrayHelperWithString Instance = new SingleArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, float[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, float[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class SingleArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, float>
	{
		public static readonly SingleArrayHelperWithDictionaryString Instance = new SingleArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DoubleArrayHelperWithString : ArrayHelper<string, double>
	{
		public static readonly DoubleArrayHelperWithString Instance = new DoubleArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, double[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, double[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DoubleArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, double>
	{
		public static readonly DoubleArrayHelperWithDictionaryString Instance = new DoubleArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DecimalArrayHelperWithString : ArrayHelper<string, decimal>
	{
		public static readonly DecimalArrayHelperWithString Instance = new DecimalArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, decimal[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, decimal[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DecimalArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, decimal>
	{
		public static readonly DecimalArrayHelperWithDictionaryString Instance = new DecimalArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DateTimeArrayHelperWithString : ArrayHelper<string, DateTime>
	{
		public static readonly DateTimeArrayHelperWithString Instance = new DateTimeArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, DateTime[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class DateTimeArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, DateTime>
	{
		public static readonly DateTimeArrayHelperWithDictionaryString Instance = new DateTimeArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class GuidArrayHelperWithString : ArrayHelper<string, Guid>
	{
		public static readonly GuidArrayHelperWithString Instance = new GuidArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, Guid[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, Guid[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class GuidArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, Guid>
	{
		public static readonly GuidArrayHelperWithDictionaryString Instance = new GuidArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class TimeSpanArrayHelperWithString : ArrayHelper<string, TimeSpan>
	{
		public static readonly TimeSpanArrayHelperWithString Instance = new TimeSpanArrayHelperWithString();

		protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, TimeSpan[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, TimeSpan[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	internal class TimeSpanArrayHelperWithDictionaryString : ArrayHelper<XmlDictionaryString, TimeSpan>
	{
		public static readonly TimeSpanArrayHelperWithDictionaryString Instance = new TimeSpanArrayHelperWithDictionaryString();

		protected override int ReadArray(XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count)
		{
			return reader.ReadArray(localName, namespaceUri, array, offset, count);
		}

		protected override void WriteArray(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count)
		{
			writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
		}
	}
	public interface IFragmentCapableXmlDictionaryWriter
	{
		bool CanFragment { get; }

		void StartFragment(Stream stream, bool generateSelfContainedTextFragment);

		void EndFragment();

		void WriteFragment(byte[] buffer, int offset, int count);
	}
	public interface IStreamProvider
	{
		Stream GetStream();

		void ReleaseStream(Stream stream);
	}
	[__DynamicallyInvokable]
	public interface IXmlDictionary
	{
		[__DynamicallyInvokable]
		bool TryLookup(string value, out XmlDictionaryString result);

		[__DynamicallyInvokable]
		bool TryLookup(int key, out XmlDictionaryString result);

		[__DynamicallyInvokable]
		bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result);
	}
	internal enum XmlBinaryNodeType
	{
		EndElement = 1,
		Comment = 2,
		Array = 3,
		MinAttribute = 4,
		ShortAttribute = 4,
		Attribute = 5,
		ShortDictionaryAttribute = 6,
		DictionaryAttribute = 7,
		ShortXmlnsAttribute = 8,
		XmlnsAttribute = 9,
		ShortDictionaryXmlnsAttribute = 10,
		DictionaryXmlnsAttribute = 11,
		PrefixDictionaryAttributeA = 12,
		PrefixDictionaryAttributeB = 13,
		PrefixDictionaryAttributeC = 14,
		PrefixDictionaryAttributeD = 15,
		PrefixDictionaryAttributeE = 16,
		PrefixDictionaryAttributeF = 17,
		PrefixDictionaryAttributeG = 18,
		PrefixDictionaryAttributeH = 19,
		PrefixDictionaryAttributeI = 20,
		PrefixDictionaryAttributeJ = 21,
		PrefixDictionaryAttributeK = 22,
		PrefixDictionaryAttributeL = 23,
		PrefixDictionaryAttributeM = 24,
		PrefixDictionaryAttributeN = 25,
		PrefixDictionaryAttributeO = 26,
		PrefixDictionaryAttributeP = 27,
		PrefixDictionaryAttributeQ = 28,
		PrefixDictionaryAttributeR = 29,
		PrefixDictionaryAttributeS = 30,
		PrefixDictionaryAttributeT = 31,
		PrefixDictionaryAttributeU = 32,
		PrefixDictionaryAttributeV = 33,
		PrefixDictionaryAttributeW = 34,
		PrefixDictionaryAttributeX = 35,
		PrefixDictionaryAttributeY = 36,
		PrefixDictionaryAttributeZ = 37,
		PrefixAttributeA = 38,
		PrefixAttributeB = 39,
		PrefixAttributeC = 40,
		PrefixAttributeD = 41,
		PrefixAttributeE = 42,
		PrefixAttributeF = 43,
		PrefixAttributeG = 44,
		PrefixAttributeH = 45,
		PrefixAttributeI = 46,
		PrefixAttributeJ = 47,
		PrefixAttributeK = 48,
		PrefixAttributeL = 49,
		PrefixAttributeM = 50,
		PrefixAttributeN = 51,
		PrefixAttributeO = 52,
		PrefixAttributeP = 53,
		PrefixAttributeQ = 54,
		PrefixAttributeR = 55,
		PrefixAttributeS = 56,
		PrefixAttributeT = 57,
		PrefixAttributeU = 58,
		PrefixAttributeV = 59,
		PrefixAttributeW = 60,
		PrefixAttributeX = 61,
		PrefixAttributeY = 62,
		PrefixAttributeZ = 63,
		MaxAttribute = 63,
		MinElement = 64,
		ShortElement = 64,
		Element = 65,
		ShortDictionaryElement = 66,
		DictionaryElement = 67,
		PrefixDictionaryElementA = 68,
		PrefixDictionaryElementB = 69,
		PrefixDictionaryElementC = 70,
		PrefixDictionaryElementD = 71,
		PrefixDictionaryElementE = 72,
		PrefixDictionaryElementF = 73,
		PrefixDictionaryElementG = 74,
		PrefixDictionaryElementH = 75,
		PrefixDictionaryElementI = 76,
		PrefixDictionaryElementJ = 77,
		PrefixDictionaryElementK = 78,
		PrefixDictionaryElementL = 79,
		PrefixDictionaryElementM = 80,
		PrefixDictionaryElementN = 81,
		PrefixDictionaryElementO = 82,
		PrefixDictionaryElementP = 83,
		PrefixDictionaryElementQ = 84,
		PrefixDictionaryElementR = 85,
		PrefixDictionaryElementS = 86,
		PrefixDictionaryElementT = 87,
		PrefixDictionaryElementU = 88,
		PrefixDictionaryElementV = 89,
		PrefixDictionaryElementW = 90,
		PrefixDictionaryElementX = 91,
		PrefixDictionaryElementY = 92,
		PrefixDictionaryElementZ = 93,
		PrefixElementA = 94,
		PrefixElementB = 95,
		PrefixElementC = 96,
		PrefixElementD = 97,
		PrefixElementE = 98,
		PrefixElementF = 99,
		PrefixElementG = 100,
		PrefixElementH = 101,
		PrefixElementI = 102,
		PrefixElementJ = 103,
		PrefixElementK = 104,
		PrefixElementL = 105,
		PrefixElementM = 106,
		PrefixElementN = 107,
		PrefixElementO = 108,
		PrefixElementP = 109,
		PrefixElementQ = 110,
		PrefixElementR = 111,
		PrefixElementS = 112,
		PrefixElementT = 113,
		PrefixElementU = 114,
		PrefixElementV = 115,
		PrefixElementW = 116,
		PrefixElementX = 117,
		PrefixElementY = 118,
		PrefixElementZ = 119,
		MaxElement = 119,
		MinText = 128,
		ZeroText = 128,
		OneText = 130,
		FalseText = 132,
		TrueText = 134,
		Int8Text = 136,
		Int16Text = 138,
		Int32Text = 140,
		Int64Text = 142,
		FloatText = 144,
		DoubleText = 146,
		DecimalText = 148,
		DateTimeText = 150,
		Chars8Text = 152,
		Chars16Text = 154,
		Chars32Text = 156,
		Bytes8Text = 158,
		Bytes16Text = 160,
		Bytes32Text = 162,
		StartListText = 164,
		EndListText = 166,
		EmptyText = 168,
		DictionaryText = 170,
		UniqueIdText = 172,
		TimeSpanText = 174,
		GuidText = 176,
		UInt64Text = 178,
		BoolText = 180,
		UnicodeChars8Text = 182,
		UnicodeChars16Text = 184,
		UnicodeChars32Text = 186,
		QNameDictionaryText = 188,
		ZeroTextWithEndElement = 129,
		OneTextWithEndElement = 131,
		FalseTextWithEndElement = 133,
		TrueTextWithEndElement = 135,
		Int8TextWithEndElement = 137,
		Int16TextWithEndElement = 139,
		Int32TextWithEndElement = 141,
		Int64TextWithEndElement = 143,
		FloatTextWithEndElement = 145,
		DoubleTextWithEndElement = 147,
		DecimalTextWithEndElement = 149,
		DateTimeTextWithEndElement = 151,
		Chars8TextWithEndElement = 153,
		Chars16TextWithEndElement = 155,
		Chars32TextWithEndElement = 157,
		Bytes8TextWithEndElement = 159,
		Bytes16TextWithEndElement = 161,
		Bytes32TextWithEndElement = 163,
		StartListTextWithEndElement = 165,
		EndListTextWithEndElement = 167,
		EmptyTextWithEndElement = 169,
		DictionaryTextWithEndElement = 171,
		UniqueIdTextWithEndElement = 173,
		TimeSpanTextWithEndElement = 175,
		GuidTextWithEndElement = 177,
		UInt64TextWithEndElement = 179,
		BoolTextWithEndElement = 181,
		UnicodeChars8TextWithEndElement = 183,
		UnicodeChars16TextWithEndElement = 185,
		UnicodeChars32TextWithEndElement = 187,
		QNameDictionaryTextWithEndElement = 189,
		MaxText = 189
	}
	[__DynamicallyInvokable]
	public class XmlBinaryReaderSession : IXmlDictionary
	{
		private const int MaxArrayEntries = 2048;

		private XmlDictionaryString[] strings;

		private Dictionary<int, XmlDictionaryString> stringDict;

		[__DynamicallyInvokable]
		public XmlBinaryReaderSession()
		{
		}

		[__DynamicallyInvokable]
		public XmlDictionaryString Add(int id, string value)
		{
			if (id < 0)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentOutOfRangeException(SR.GetString("XmlInvalidID")));
			}
			if (value == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
			}
			if (TryLookup(id, out var result))
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new InvalidOperationException(SR.GetString("XmlIDDefined")));
			}
			result = new XmlDictionaryString(this, value, id);
			if (id >= 2048)
			{
				if (stringDict == null)
				{
					stringDict = new Dictionary<int, XmlDictionaryString>();
				}
				stringDict.Add(id, result);
			}
			else
			{
				if (strings == null)
				{
					strings = new XmlDictionaryString[Math.Max(id + 1, 16)];
				}
				else if (id >= strings.Length)
				{
					XmlDictionaryString[] destinationArray = new XmlDictionaryString[Math.Min(Math.Max(id + 1, strings.Length * 2), 2048)];
					Array.Copy(strings, destinationArray, strings.Length);
					strings = destinationArray;
				}
				strings[id] = result;
			}
			return result;
		}

		[__DynamicallyInvokable]
		public bool TryLookup(int key, out XmlDictionaryString result)
		{
			if (strings != null && key >= 0 && key < strings.Length)
			{
				result = strings[key];
				return result != null;
			}
			if (key >= 2048 && stringDict != null)
			{
				return stringDict.TryGetValue(key, out result);
			}
			result = null;
			return false;
		}

		[__DynamicallyInvokable]
		public bool TryLookup(string value, out XmlDictionaryString result)
		{
			if (value == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
			}
			if (strings != null)
			{
				for (int i = 0; i < strings.Length; i++)
				{
					XmlDictionaryString xmlDictionaryString = strings[i];
					if (xmlDictionaryString != null && xmlDictionaryString.Value == value)
					{
						result = xmlDictionaryString;
						return true;
					}
				}
			}
			if (stringDict != null)
			{
				foreach (XmlDictionaryString value2 in stringDict.Values)
				{
					if (value2.Value == value)
					{
						result = value2;
						return true;
					}
				}
			}
			result = null;
			return false;
		}

		[__DynamicallyInvokable]
		public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result)
		{
			if (value == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentNullException("value"));
			}
			if (value.Dictionary != this)
			{
				result = null;
				return false;
			}
			result = value;
			return true;
		}

		[__DynamicallyInvokable]
		public void Clear()
		{
			if (strings != null)
			{
				Array.Clear(strings, 0, strings.Length);
			}
			if (stringDict != null)
			{
				stringDict.Clear();
			}
		}
	}
	public interface IXmlBinaryWriterInitializer
	{
		void SetOutput(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream);
	}
	internal class XmlBinaryNodeWriter : XmlStreamNodeWriter
	{
		private struct AttributeValue
		{
			private string captureText;

			private XmlDictionaryString captureXText;

			private MemoryStream captureStream;

			public void Clear()
			{
				captureText = null;
				captureXText = null;
				captureStream = null;
			}

			public void WriteText(string s)
			{
				if (captureStream != null)
				{
					captureText = XmlConverter.Base64Encoding.GetString(captureStream.GetBuffer(), 0, (int)captureStream.Length);
					captureStream = null;
				}
				if (captureXText != null)
				{
					captureText = captureXText.Value;
					captureXText = null;
				}
				if (captureText == null || captureText.Length == 0)
				{
					captureText = s;
				}
				else
				{
					captureText += s;
				}
			}

			public void WriteText(XmlDictionaryString s)
			{
				if (captureText != null || captureStream != null)
				{
					WriteText(s.Value);
				}
				else
				{
					captureXText = s;
				}
			}

			public void WriteBase64Text(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count)
			{
				if (captureText != null || captureXText != null)
				{
					if (trailByteCount > 0)
					{
						WriteText(XmlConverter.Base64Encoding.GetString(trailBytes, 0, trailByteCount));
					}
					WriteText(XmlConverter.Base64Encoding.GetString(buffer, offset, count));
					return;
				}
				if (captureStream == null)
				{
					captureStream = new MemoryStream();
				}
				if (trailByteCount > 0)
				{
					captureStream.Write(trailBytes, 0, trailByteCount);
				}
				captureStream.Write(buffer, offset, count);
			}

			public void WriteTo(XmlBinaryNodeWriter writer)
			{
				if (captureText != null)
				{
					writer.WriteText(captureText);
					captureText = null;
				}
				else if (captureXText != null)
				{
					writer.WriteText(captureXText);
					captureXText = null;
				}
				else if (captureStream != null)
				{
					writer.WriteBase64Text(null, 0, captureStream.GetBuffer(), 0, (int)captureStream.Length);
					captureStream = null;
				}
				else
				{
					writer.WriteEmptyText();
				}
			}
		}

		private IXmlDictionary dictionary;

		private XmlBinaryWriterSession session;

		private bool inAttribute;

		private bool inList;

		private bool wroteAttributeValue;

		private AttributeValue attributeValue;

		private const int maxBytesPerChar = 3;

		private int textNodeOffset;

		public void SetOutput(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream)
		{
			this.dictionary = dictionary;
			this.session = session;
			inAttribute = false;
			inList = false;
			attributeValue.Clear();
			textNodeOffset = -1;
			SetOutput(stream, ownsStream, null);
		}

		private void WriteNode(XmlBinaryNodeType nodeType)
		{
			WriteByte((byte)nodeType);
			textNodeOffset = -1;
		}

		private void WroteAttributeValue()
		{
			if (wroteAttributeValue && !inList)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new InvalidOperationException(SR.GetString("XmlOnlySingleValue")));
			}
			wroteAttributeValue = true;
		}

		private void WriteTextNode(XmlBinaryNodeType nodeType)
		{
			if (inAttribute)
			{
				WroteAttributeValue();
			}
			WriteByte((byte)nodeType);
			textNodeOffset = base.BufferOffset - 1;
		}

		private byte[] GetTextNodeBuffer(int size, out int offset)
		{
			if (inAttribute)
			{
				WroteAttributeValue();
			}
			byte[] result = GetBuffer(size, out offset);
			textNodeOffset = offset;
			return result;
		}

		private void WriteTextNodeWithLength(XmlBinaryNodeType nodeType, int length)
		{
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(5, out num);
			if (length < 256)
			{
				textNodeBuffer[num] = (byte)nodeType;
				textNodeBuffer[num + 1] = (byte)length;
				Advance(2);
			}
			else if (length < 65536)
			{
				textNodeBuffer[num] = (byte)(nodeType + 2);
				textNodeBuffer[num + 1] = (byte)length;
				length >>= 8;
				textNodeBuffer[num + 2] = (byte)length;
				Advance(3);
			}
			else
			{
				textNodeBuffer[num] = (byte)(nodeType + 4);
				textNodeBuffer[num + 1] = (byte)length;
				length >>= 8;
				textNodeBuffer[num + 2] = (byte)length;
				length >>= 8;
				textNodeBuffer[num + 3] = (byte)length;
				length >>= 8;
				textNodeBuffer[num + 4] = (byte)length;
				Advance(5);
			}
		}

		private void WriteTextNodeWithInt64(XmlBinaryNodeType nodeType, long value)
		{
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(9, out num);
			textNodeBuffer[num] = (byte)nodeType;
			textNodeBuffer[num + 1] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 2] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 3] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 4] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 5] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 6] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 7] = (byte)value;
			value >>= 8;
			textNodeBuffer[num + 8] = (byte)value;
			Advance(9);
		}

		public override void WriteDeclaration()
		{
		}

		public override void WriteStartElement(string prefix, string localName)
		{
			if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.MinElement);
				WriteName(localName);
				return;
			}
			char c = prefix[0];
			if (prefix.Length == 1 && c >= 'a' && c <= 'z')
			{
				WritePrefixNode(XmlBinaryNodeType.PrefixElementA, c - 97);
				WriteName(localName);
			}
			else
			{
				WriteNode(XmlBinaryNodeType.Element);
				WriteName(prefix);
				WriteName(localName);
			}
		}

		private void WritePrefixNode(XmlBinaryNodeType nodeType, int ch)
		{
			WriteNode(nodeType + ch);
		}

		public override void WriteStartElement(string prefix, XmlDictionaryString localName)
		{
			if (!TryGetKey(localName, out var key))
			{
				WriteStartElement(prefix, localName.Value);
				return;
			}
			if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.ShortDictionaryElement);
				WriteDictionaryString(localName, key);
				return;
			}
			char c = prefix[0];
			if (prefix.Length == 1 && c >= 'a' && c <= 'z')
			{
				WritePrefixNode(XmlBinaryNodeType.PrefixDictionaryElementA, c - 97);
				WriteDictionaryString(localName, key);
			}
			else
			{
				WriteNode(XmlBinaryNodeType.DictionaryElement);
				WriteName(prefix);
				WriteDictionaryString(localName, key);
			}
		}

		public override void WriteEndStartElement(bool isEmpty)
		{
			if (isEmpty)
			{
				WriteEndElement();
			}
		}

		public override void WriteEndElement(string prefix, string localName)
		{
			WriteEndElement();
		}

		private void WriteEndElement()
		{
			if (textNodeOffset != -1)
			{
				byte[] streamBuffer = base.StreamBuffer;
				XmlBinaryNodeType xmlBinaryNodeType = (XmlBinaryNodeType)streamBuffer[textNodeOffset];
				streamBuffer[textNodeOffset] = (byte)(xmlBinaryNodeType + 1);
				textNodeOffset = -1;
			}
			else
			{
				WriteNode(XmlBinaryNodeType.EndElement);
			}
		}

		public override void WriteStartAttribute(string prefix, string localName)
		{
			if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.MinAttribute);
				WriteName(localName);
			}
			else
			{
				char c = prefix[0];
				if (prefix.Length == 1 && c >= 'a' && c <= 'z')
				{
					WritePrefixNode(XmlBinaryNodeType.PrefixAttributeA, c - 97);
					WriteName(localName);
				}
				else
				{
					WriteNode(XmlBinaryNodeType.Attribute);
					WriteName(prefix);
					WriteName(localName);
				}
			}
			inAttribute = true;
			wroteAttributeValue = false;
		}

		public override void WriteStartAttribute(string prefix, XmlDictionaryString localName)
		{
			if (!TryGetKey(localName, out var key))
			{
				WriteStartAttribute(prefix, localName.Value);
				return;
			}
			if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.ShortDictionaryAttribute);
				WriteDictionaryString(localName, key);
			}
			else
			{
				char c = prefix[0];
				if (prefix.Length == 1 && c >= 'a' && c <= 'z')
				{
					WritePrefixNode(XmlBinaryNodeType.PrefixDictionaryAttributeA, c - 97);
					WriteDictionaryString(localName, key);
				}
				else
				{
					WriteNode(XmlBinaryNodeType.DictionaryAttribute);
					WriteName(prefix);
					WriteDictionaryString(localName, key);
				}
			}
			inAttribute = true;
			wroteAttributeValue = false;
		}

		public override void WriteEndAttribute()
		{
			inAttribute = false;
			if (!wroteAttributeValue)
			{
				attributeValue.WriteTo(this);
			}
			textNodeOffset = -1;
		}

		public override void WriteXmlnsAttribute(string prefix, string ns)
		{
			if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.ShortXmlnsAttribute);
				WriteName(ns);
			}
			else
			{
				WriteNode(XmlBinaryNodeType.XmlnsAttribute);
				WriteName(prefix);
				WriteName(ns);
			}
		}

		public override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns)
		{
			if (!TryGetKey(ns, out var key))
			{
				WriteXmlnsAttribute(prefix, ns.Value);
			}
			else if (prefix.Length == 0)
			{
				WriteNode(XmlBinaryNodeType.ShortDictionaryXmlnsAttribute);
				WriteDictionaryString(ns, key);
			}
			else
			{
				WriteNode(XmlBinaryNodeType.DictionaryXmlnsAttribute);
				WriteName(prefix);
				WriteDictionaryString(ns, key);
			}
		}

		private bool TryGetKey(XmlDictionaryString s, out int key)
		{
			key = -1;
			if (s.Dictionary == dictionary)
			{
				key = s.Key * 2;
				return true;
			}
			if (dictionary != null && dictionary.TryLookup(s, out var result))
			{
				key = result.Key * 2;
				return true;
			}
			if (session == null)
			{
				return false;
			}
			if (!session.TryLookup(s, out var key2) && !session.TryAdd(s, out key2))
			{
				return false;
			}
			key = key2 * 2 + 1;
			return true;
		}

		private void WriteDictionaryString(XmlDictionaryString s, int key)
		{
			WriteMultiByteInt32(key);
		}

		[SecuritySafeCritical]
		private unsafe void WriteName(string s)
		{
			int length = s.Length;
			if (length == 0)
			{
				WriteByte(0);
				return;
			}
			fixed (char* chars = s)
			{
				UnsafeWriteName(chars, length);
			}
		}

		[SecurityCritical]
		private unsafe void UnsafeWriteName(char* chars, int charCount)
		{
			if (charCount < 42)
			{
				int num;
				byte[] array = GetBuffer(1 + charCount * 3, out num);
				int num2 = UnsafeGetUTF8Chars(chars, charCount, array, num + 1);
				array[num] = (byte)num2;
				Advance(1 + num2);
			}
			else
			{
				int i = UnsafeGetUTF8Length(chars, charCount);
				WriteMultiByteInt32(i);
				UnsafeWriteUTF8Chars(chars, charCount);
			}
		}

		private void WriteMultiByteInt32(int i)
		{
			int num;
			byte[] array = GetBuffer(5, out num);
			int num2 = num;
			while ((i & 0xFFFFFF80u) != 0L)
			{
				array[num++] = (byte)(((uint)i & 0x7Fu) | 0x80u);
				i >>= 7;
			}
			array[num++] = (byte)i;
			Advance(num - num2);
		}

		public override void WriteComment(string value)
		{
			WriteNode(XmlBinaryNodeType.Comment);
			WriteName(value);
		}

		public override void WriteCData(string value)
		{
			WriteText(value);
		}

		private void WriteEmptyText()
		{
			WriteTextNode(XmlBinaryNodeType.EmptyText);
		}

		public override void WriteBoolText(bool value)
		{
			if (value)
			{
				WriteTextNode(XmlBinaryNodeType.TrueText);
			}
			else
			{
				WriteTextNode(XmlBinaryNodeType.FalseText);
			}
		}

		public override void WriteInt32Text(int value)
		{
			if (value >= -128 && value < 128)
			{
				switch (value)
				{
				case 0:
					WriteTextNode(XmlBinaryNodeType.MinText);
					return;
				case 1:
					WriteTextNode(XmlBinaryNodeType.OneText);
					return;
				}
				int num;
				byte[] textNodeBuffer = GetTextNodeBuffer(2, out num);
				textNodeBuffer[num] = 136;
				textNodeBuffer[num + 1] = (byte)value;
				Advance(2);
			}
			else if (value >= -32768 && value < 32768)
			{
				int num2;
				byte[] textNodeBuffer2 = GetTextNodeBuffer(3, out num2);
				textNodeBuffer2[num2] = 138;
				textNodeBuffer2[num2 + 1] = (byte)value;
				value >>= 8;
				textNodeBuffer2[num2 + 2] = (byte)value;
				Advance(3);
			}
			else
			{
				int num3;
				byte[] textNodeBuffer3 = GetTextNodeBuffer(5, out num3);
				textNodeBuffer3[num3] = 140;
				textNodeBuffer3[num3 + 1] = (byte)value;
				value >>= 8;
				textNodeBuffer3[num3 + 2] = (byte)value;
				value >>= 8;
				textNodeBuffer3[num3 + 3] = (byte)value;
				value >>= 8;
				textNodeBuffer3[num3 + 4] = (byte)value;
				Advance(5);
			}
		}

		public override void WriteInt64Text(long value)
		{
			if (value >= int.MinValue && value <= int.MaxValue)
			{
				WriteInt32Text((int)value);
			}
			else
			{
				WriteTextNodeWithInt64(XmlBinaryNodeType.Int64Text, value);
			}
		}

		public override void WriteUInt64Text(ulong value)
		{
			if (value <= long.MaxValue)
			{
				WriteInt64Text((long)value);
			}
			else
			{
				WriteTextNodeWithInt64(XmlBinaryNodeType.UInt64Text, (long)value);
			}
		}

		private void WriteInt64(long value)
		{
			int num;
			byte[] array = GetBuffer(8, out num);
			array[num] = (byte)value;
			value >>= 8;
			array[num + 1] = (byte)value;
			value >>= 8;
			array[num + 2] = (byte)value;
			value >>= 8;
			array[num + 3] = (byte)value;
			value >>= 8;
			array[num + 4] = (byte)value;
			value >>= 8;
			array[num + 5] = (byte)value;
			value >>= 8;
			array[num + 6] = (byte)value;
			value >>= 8;
			array[num + 7] = (byte)value;
			Advance(8);
		}

		public override void WriteBase64Text(byte[] trailBytes, int trailByteCount, byte[] base64Buffer, int base64Offset, int base64Count)
		{
			if (inAttribute)
			{
				attributeValue.WriteBase64Text(trailBytes, trailByteCount, base64Buffer, base64Offset, base64Count);
				return;
			}
			int num = trailByteCount + base64Count;
			if (num > 0)
			{
				WriteTextNodeWithLength(XmlBinaryNodeType.Bytes8Text, num);
				if (trailByteCount > 0)
				{
					int num2;
					byte[] array = GetBuffer(trailByteCount, out num2);
					for (int i = 0; i < trailByteCount; i++)
					{
						array[num2 + i] = trailBytes[i];
					}
					Advance(trailByteCount);
				}
				if (base64Count > 0)
				{
					WriteBytes(base64Buffer, base64Offset, base64Count);
				}
			}
			else
			{
				WriteEmptyText();
			}
		}

		public override void WriteText(XmlDictionaryString value)
		{
			if (inAttribute)
			{
				attributeValue.WriteText(value);
				return;
			}
			if (!TryGetKey(value, out var key))
			{
				WriteText(value.Value);
				return;
			}
			WriteTextNode(XmlBinaryNodeType.DictionaryText);
			WriteDictionaryString(value, key);
		}

		[SecuritySafeCritical]
		public unsafe override void WriteText(string value)
		{
			if (inAttribute)
			{
				attributeValue.WriteText(value);
			}
			else if (value.Length > 0)
			{
				fixed (char* chars = value)
				{
					UnsafeWriteText(chars, value.Length);
				}
			}
			else
			{
				WriteEmptyText();
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteText(char[] chars, int offset, int count)
		{
			if (inAttribute)
			{
				attributeValue.WriteText(new string(chars, offset, count));
			}
			else if (count > 0)
			{
				fixed (char* chars2 = &chars[offset])
				{
					UnsafeWriteText(chars2, count);
				}
			}
			else
			{
				WriteEmptyText();
			}
		}

		public override void WriteText(byte[] chars, int charOffset, int charCount)
		{
			WriteTextNodeWithLength(XmlBinaryNodeType.Chars8Text, charCount);
			WriteBytes(chars, charOffset, charCount);
		}

		[SecurityCritical]
		private unsafe void UnsafeWriteText(char* chars, int charCount)
		{
			if (charCount == 1)
			{
				switch (*chars)
				{
				case '0':
					WriteTextNode(XmlBinaryNodeType.MinText);
					return;
				case '1':
					WriteTextNode(XmlBinaryNodeType.OneText);
					return;
				}
			}
			if (charCount <= 85)
			{
				int num;
				byte[] array = GetBuffer(2 + charCount * 3, out num);
				int num2 = UnsafeGetUTF8Chars(chars, charCount, array, num + 2);
				if (num2 / 2 <= charCount)
				{
					array[num] = 152;
				}
				else
				{
					array[num] = 182;
					num2 = UnsafeGetUnicodeChars(chars, charCount, array, num + 2);
				}
				textNodeOffset = num;
				array[num + 1] = (byte)num2;
				Advance(2 + num2);
			}
			else
			{
				int num3 = UnsafeGetUTF8Length(chars, charCount);
				if (num3 / 2 > charCount)
				{
					WriteTextNodeWithLength(XmlBinaryNodeType.UnicodeChars8Text, charCount * 2);
					UnsafeWriteUnicodeChars(chars, charCount);
				}
				else
				{
					WriteTextNodeWithLength(XmlBinaryNodeType.Chars8Text, num3);
					UnsafeWriteUTF8Chars(chars, charCount);
				}
			}
		}

		public override void WriteEscapedText(string value)
		{
			WriteText(value);
		}

		public override void WriteEscapedText(XmlDictionaryString value)
		{
			WriteText(value);
		}

		public override void WriteEscapedText(char[] chars, int offset, int count)
		{
			WriteText(chars, offset, count);
		}

		public override void WriteEscapedText(byte[] chars, int offset, int count)
		{
			WriteText(chars, offset, count);
		}

		public override void WriteCharEntity(int ch)
		{
			if (ch > 65535)
			{
				SurrogateChar surrogateChar = new SurrogateChar(ch);
				char[] chars = new char[2] { surrogateChar.HighChar, surrogateChar.LowChar };
				WriteText(chars, 0, 2);
			}
			else
			{
				char[] chars2 = new char[1] { (char)ch };
				WriteText(chars2, 0, 1);
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteFloatText(float f)
		{
			long value;
			if (f >= -9.223372E+18f && f <= 9.223372E+18f && (float)(value = (long)f) == f)
			{
				WriteInt64Text(value);
				return;
			}
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(5, out num);
			byte* ptr = (byte*)(&f);
			textNodeBuffer[num] = 144;
			textNodeBuffer[num + 1] = *ptr;
			textNodeBuffer[num + 2] = ptr[1];
			textNodeBuffer[num + 3] = ptr[2];
			textNodeBuffer[num + 4] = ptr[3];
			Advance(5);
		}

		[SecuritySafeCritical]
		public unsafe override void WriteDoubleText(double d)
		{
			float value;
			if (d >= -3.4028234663852886E+38 && d <= 3.4028234663852886E+38 && (double)(value = (float)d) == d)
			{
				WriteFloatText(value);
				return;
			}
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(9, out num);
			byte* ptr = (byte*)(&d);
			textNodeBuffer[num] = 146;
			textNodeBuffer[num + 1] = *ptr;
			textNodeBuffer[num + 2] = ptr[1];
			textNodeBuffer[num + 3] = ptr[2];
			textNodeBuffer[num + 4] = ptr[3];
			textNodeBuffer[num + 5] = ptr[4];
			textNodeBuffer[num + 6] = ptr[5];
			textNodeBuffer[num + 7] = ptr[6];
			textNodeBuffer[num + 8] = ptr[7];
			Advance(9);
		}

		[SecuritySafeCritical]
		public unsafe override void WriteDecimalText(decimal d)
		{
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(17, out num);
			byte* ptr = (byte*)(&d);
			textNodeBuffer[num++] = 148;
			for (int i = 0; i < 16; i++)
			{
				textNodeBuffer[num++] = ptr[i];
			}
			Advance(17);
		}

		public override void WriteDateTimeText(DateTime dt)
		{
			WriteTextNodeWithInt64(XmlBinaryNodeType.DateTimeText, dt.ToBinary());
		}

		public override void WriteUniqueIdText(UniqueId value)
		{
			if (value.IsGuid)
			{
				int num;
				byte[] textNodeBuffer = GetTextNodeBuffer(17, out num);
				textNodeBuffer[num] = 172;
				value.TryGetGuid(textNodeBuffer, num + 1);
				Advance(17);
			}
			else
			{
				WriteText(value.ToString());
			}
		}

		public override void WriteGuidText(Guid guid)
		{
			int num;
			byte[] textNodeBuffer = GetTextNodeBuffer(17, out num);
			textNodeBuffer[num] = 176;
			Buffer.BlockCopy(guid.ToByteArray(), 0, textNodeBuffer, num + 1, 16);
			Advance(17);
		}

		public override void WriteTimeSpanText(TimeSpan value)
		{
			WriteTextNodeWithInt64(XmlBinaryNodeType.TimeSpanText, value.Ticks);
		}

		public override void WriteStartListText()
		{
			inList = true;
			WriteNode(XmlBinaryNodeType.StartListText);
		}

		public override void WriteListSeparator()
		{
		}

		public override void WriteEndListText()
		{
			inList = false;
			wroteAttributeValue = true;
			WriteNode(XmlBinaryNodeType.EndListText);
		}

		public void WriteArrayNode()
		{
			WriteNode(XmlBinaryNodeType.Array);
		}

		private void WriteArrayInfo(XmlBinaryNodeType nodeType, int count)
		{
			WriteNode(nodeType);
			WriteMultiByteInt32(count);
		}

		[SecurityCritical]
		public unsafe void UnsafeWriteArray(XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax)
		{
			WriteArrayInfo(nodeType, count);
			UnsafeWriteArray(array, (int)(arrayMax - array));
		}

		[SecurityCritical]
		private unsafe void UnsafeWriteArray(byte* array, int byteCount)
		{
			UnsafeWriteBytes(array, byteCount);
		}

		public void WriteDateTimeArray(DateTime[] array, int offset, int count)
		{
			WriteArrayInfo(XmlBinaryNodeType.DateTimeTextWithEndElement, count);
			for (int i = 0; i < count; i++)
			{
				WriteInt64(array[offset + i].ToBinary());
			}
		}

		public void WriteGuidArray(Guid[] array, int offset, int count)
		{
			WriteArrayInfo(XmlBinaryNodeType.GuidTextWithEndElement, count);
			for (int i = 0; i < count; i++)
			{
				byte[] byteBuffer = array[offset + i].ToByteArray();
				WriteBytes(byteBuffer, 0, 16);
			}
		}

		public void WriteTimeSpanArray(TimeSpan[] array, int offset, int count)
		{
			WriteArrayInfo(XmlBinaryNodeType.TimeSpanTextWithEndElement, count);
			for (int i = 0; i < count; i++)
			{
				WriteInt64(array[offset + i].Ticks);
			}
		}

		public override void WriteQualifiedName(string prefix, XmlDictionaryString localName)
		{
			if (prefix.Length == 0)
			{
				WriteText(localName);
				return;
			}
			char c = prefix[0];
			if (prefix.Length == 1 && c >= 'a' && c <= 'z' && TryGetKey(localName, out var key))
			{
				WriteTextNode(XmlBinaryNodeType.QNameDictionaryText);
				WriteByte((byte)(c - 97));
				WriteDictionaryString(localName, key);
			}
			else
			{
				WriteText(prefix);
				WriteText(":");
				WriteText(localName);
			}
		}

		protected override void FlushBuffer()
		{
			base.FlushBuffer();
			textNodeOffset = -1;
		}

		public override void Close()
		{
			base.Close();
			attributeValue.Clear();
		}
	}
	internal class XmlBinaryWriter : XmlBaseWriter, IXmlBinaryWriterInitializer
	{
		private XmlBinaryNodeWriter writer;

		private char[] chars;

		private byte[] bytes;

		public void SetOutput(Stream stream, IXmlDictionary dictionary, XmlBinaryWriterSession session, bool ownsStream)
		{
			if (stream == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentNullException("stream"));
			}
			if (writer == null)
			{
				writer = new XmlBinaryNodeWriter();
			}
			writer.SetOutput(stream, dictionary, session, ownsStream);
			SetOutput(writer);
		}

		protected override XmlSigningNodeWriter CreateSigningNodeWriter()
		{
			return new XmlSigningNodeWriter(text: false);
		}

		protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
		{
			Type valueType = reader.ValueType;
			if (valueType == typeof(string))
			{
				if (reader.TryGetValueAsDictionaryString(out var value))
				{
					WriteString(value);
				}
				else if (reader.CanReadValueChunk)
				{
					if (chars == null)
					{
						chars = new char[256];
					}
					int count;
					while ((count = reader.ReadValueChunk(chars, 0, chars.Length)) > 0)
					{
						WriteChars(chars, 0, count);
					}
				}
				else
				{
					WriteString(reader.Value);
				}
				if (!attribute)
				{
					reader.Read();
				}
			}
			else if (valueType == typeof(byte[]))
			{
				if (reader.CanReadBinaryContent)
				{
					if (bytes == null)
					{
						bytes = new byte[384];
					}
					int count2;
					while ((count2 = reader.ReadValueAsBase64(bytes, 0, bytes.Length)) > 0)
					{
						WriteBase64(bytes, 0, count2);
					}
				}
				else
				{
					WriteString(reader.Value);
				}
				if (!attribute)
				{
					reader.Read();
				}
			}
			else if (valueType == typeof(int))
			{
				WriteValue(reader.ReadContentAsInt());
			}
			else if (valueType == typeof(long))
			{
				WriteValue(reader.ReadContentAsLong());
			}
			else if (valueType == typeof(bool))
			{
				WriteValue(reader.ReadContentAsBoolean());
			}
			else if (valueType == typeof(double))
			{
				WriteValue(reader.ReadContentAsDouble());
			}
			else if (valueType == typeof(DateTime))
			{
				WriteValue(reader.ReadContentAsDateTime());
			}
			else if (valueType == typeof(float))
			{
				WriteValue(reader.ReadContentAsFloat());
			}
			else if (valueType == typeof(decimal))
			{
				WriteValue(reader.ReadContentAsDecimal());
			}
			else if (valueType == typeof(UniqueId))
			{
				WriteValue(reader.ReadContentAsUniqueId());
			}
			else if (valueType == typeof(Guid))
			{
				WriteValue(reader.ReadContentAsGuid());
			}
			else if (valueType == typeof(TimeSpan))
			{
				WriteValue(reader.ReadContentAsTimeSpan());
			}
			else
			{
				WriteValue(reader.ReadContentAsObject());
			}
		}

		private void WriteStartArray(string prefix, string localName, string namespaceUri, int count)
		{
			StartArray(count);
			writer.WriteArrayNode();
			WriteStartElement(prefix, localName, namespaceUri);
			WriteEndElement();
		}

		private void WriteStartArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int count)
		{
			StartArray(count);
			writer.WriteArrayNode();
			WriteStartElement(prefix, localName, namespaceUri);
			WriteEndElement();
		}

		private void WriteEndArray()
		{
			EndArray();
		}

		[SecurityCritical]
		private unsafe void UnsafeWriteArray(string prefix, string localName, string namespaceUri, XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax)
		{
			WriteStartArray(prefix, localName, namespaceUri, count);
			writer.UnsafeWriteArray(nodeType, count, array, arrayMax);
			WriteEndArray();
		}

		[SecurityCritical]
		private unsafe void UnsafeWriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, XmlBinaryNodeType nodeType, int count, byte* array, byte* arrayMax)
		{
			WriteStartArray(prefix, localName, namespaceUri, count);
			writer.UnsafeWriteArray(nodeType, count, array, arrayMax);
			WriteEndArray();
		}

		private void CheckArray(Array array, int offset, int count)
		{
			if (array == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentNullException("array"));
			}
			if (offset < 0)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentOutOfRangeException("offset", SR.GetString("ValueMustBeNonNegative")));
			}
			if (offset > array.Length)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentOutOfRangeException("offset", SR.GetString("OffsetExceedsBufferSize", array.Length)));
			}
			if (count < 0)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentOutOfRangeException("count", SR.GetString("ValueMustBeNonNegative")));
			}
			if (count > array.Length - offset)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentOutOfRangeException("count", SR.GetString("SizeExceedsRemainingBufferSpace", array.Length - offset)));
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, bool[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (bool* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, bool[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (bool* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.BoolTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, short[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (short* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, short[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (short* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int16TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, int[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (int* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, int[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (int* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int32TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, long[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (long* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, long[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (long* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.Int64TextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, float[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (float* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, float[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (float* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.FloatTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, double[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (double* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, double[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (double* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DoubleTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, string localName, string namespaceUri, decimal[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (decimal* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		[SecuritySafeCritical]
		public unsafe override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, decimal[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				fixed (decimal* ptr = &array[offset])
				{
					UnsafeWriteArray(prefix, localName, namespaceUri, XmlBinaryNodeType.DecimalTextWithEndElement, count, (byte*)ptr, (byte*)(ptr + count));
				}
			}
		}

		public override void WriteArray(string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteDateTimeArray(array, offset, count);
				WriteEndArray();
			}
		}

		public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, DateTime[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteDateTimeArray(array, offset, count);
				WriteEndArray();
			}
		}

		public override void WriteArray(string prefix, string localName, string namespaceUri, Guid[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteGuidArray(array, offset, count);
				WriteEndArray();
			}
		}

		public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, Guid[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteGuidArray(array, offset, count);
				WriteEndArray();
			}
		}

		public override void WriteArray(string prefix, string localName, string namespaceUri, TimeSpan[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteTimeSpanArray(array, offset, count);
				WriteEndArray();
			}
		}

		public override void WriteArray(string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, TimeSpan[] array, int offset, int count)
		{
			if (base.Signing)
			{
				base.WriteArray(prefix, localName, namespaceUri, array, offset, count);
				return;
			}
			CheckArray(array, offset, count);
			if (count > 0)
			{
				WriteStartArray(prefix, localName, namespaceUri, count);
				writer.WriteTimeSpanArray(array, offset, count);
				WriteEndArray();
			}
		}
	}
	[__DynamicallyInvokable]
	public class XmlBinaryWriterSession
	{
		private class PriorityDictionary<K, V> where K : class
		{
			private struct Entry
			{
				public K Key;

				public V Value;

				public int Time;
			}

			private Dictionary<K, V> dictionary;

			private Entry[] list;

			private int listCount;

			private int now;

			private int Now
			{
				get
				{
					if (++now == int.MaxValue)
					{
						DecreaseAll();
					}
					return now;
				}
			}

			public PriorityDictionary()
			{
				list = new Entry[16];
			}

			public void Clear()
			{
				now = 0;
				listCount = 0;
				Array.Clear(list, 0, list.Length);
				if (dictionary != null)
				{
					dictionary.Clear();
				}
			}

			public bool TryGetValue(K key, out V value)
			{
				for (int i = 0; i < listCount; i++)
				{
					if (list[i].Key == key)
					{
						value = list[i].Value;
						list[i].Time = Now;
						return true;
					}
				}
				for (int j = 0; j < listCount; j++)
				{
					if (list[j].Key.Equals(key))
					{
						value = list[j].Value;
						list[j].Time = Now;
						return true;
					}
				}
				if (dictionary == null)
				{
					value = default(V);
					return false;
				}
				if (!dictionary.TryGetValue(key, out value))
				{
					return false;
				}
				int num = 0;
				int time = list[0].Time;
				for (int k = 1; k < listCount; k++)
				{
					if (list[k].Time < time)
					{
						num = k;
						time = list[k].Time;
					}
				}
				list[num].Key = key;
				list[num].Value = value;
				list[num].Time = Now;
				return true;
			}

			public void Add(K key, V value)
			{
				if (listCount < list.Length)
				{
					list[listCount].Key = key;
					list[listCount].Value = value;
					listCount++;
					return;
				}
				if (dictionary == null)
				{
					dictionary = new Dictionary<K, V>();
					for (int i = 0; i < listCount; i++)
					{
						dictionary.Add(list[i].Key, list[i].Value);
					}
				}
				dictionary.Add(key, value);
			}

			private void DecreaseAll()
			{
				for (int i = 0; i < listCount; i++)
				{
					list[i].Time /= 2;
				}
				now /= 2;
			}
		}

		private class IntArray
		{
			private int[] array;

			public int this[int index]
			{
				get
				{
					if (index >= array.Length)
					{
						return 0;
					}
					return array[index];
				}
				set
				{
					if (index >= array.Length)
					{
						int[] destinationArray = new int[Math.Max(index + 1, array.Length * 2)];
						Array.Copy(array, destinationArray, array.Length);
						array = destinationArray;
					}
					array[index] = value;
				}
			}

			public IntArray(int size)
			{
				array = new int[size];
			}
		}

		private PriorityDictionary<string, int> strings;

		private PriorityDictionary<IXmlDictionary, IntArray> maps;

		private int nextKey;

		[__DynamicallyInvokable]
		public XmlBinaryWriterSession()
		{
			nextKey = 0;
			maps = new PriorityDictionary<IXmlDictionary, IntArray>();
			strings = new PriorityDictionary<string, int>();
		}

		[__DynamicallyInvokable]
		public virtual bool TryAdd(XmlDictionaryString value, out int key)
		{
			if (value == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
			}
			if (maps.TryGetValue(value.Dictionary, out var value2))
			{
				key = value2[value.Key] - 1;
				if (key != -1)
				{
					throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new InvalidOperationException(SR.GetString("XmlKeyAlreadyExists")));
				}
				key = Add(value.Value);
				value2[value.Key] = key + 1;
				return true;
			}
			key = Add(value.Value);
			value2 = AddKeys(value.Dictionary, value.Key + 1);
			value2[value.Key] = key + 1;
			return true;
		}

		private int Add(string s)
		{
			int num = nextKey++;
			strings.Add(s, num);
			return num;
		}

		private IntArray AddKeys(IXmlDictionary dictionary, int minCount)
		{
			IntArray intArray = new IntArray(Math.Max(minCount, 16));
			maps.Add(dictionary, intArray);
			return intArray;
		}

		[__DynamicallyInvokable]
		public void Reset()
		{
			nextKey = 0;
			maps.Clear();
			strings.Clear();
		}

		internal bool TryLookup(XmlDictionaryString s, out int key)
		{
			if (maps.TryGetValue(s.Dictionary, out var value))
			{
				key = value[s.Key] - 1;
				if (key != -1)
				{
					return true;
				}
			}
			if (strings.TryGetValue(s.Value, out key))
			{
				if (value == null)
				{
					value = AddKeys(s.Dictionary, s.Key + 1);
				}
				value[s.Key] = key + 1;
				return true;
			}
			key = -1;
			return false;
		}
	}
	[__DynamicallyInvokable]
	public class XmlDictionary : IXmlDictionary
	{
		private class EmptyDictionary : IXmlDictionary
		{
			public bool TryLookup(string value, out XmlDictionaryString result)
			{
				result = null;
				return false;
			}

			public bool TryLookup(int key, out XmlDictionaryString result)
			{
				result = null;
				return false;
			}

			public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result)
			{
				result = null;
				return false;
			}
		}

		private static IXmlDictionary empty;

		private Dictionary<string, XmlDictionaryString> lookup;

		private XmlDictionaryString[] strings;

		private int nextId;

		[__DynamicallyInvokable]
		public static IXmlDictionary Empty
		{
			[__DynamicallyInvokable]
			get
			{
				if (empty == null)
				{
					empty = new EmptyDictionary();
				}
				return empty;
			}
		}

		[__DynamicallyInvokable]
		public XmlDictionary()
		{
			lookup = new Dictionary<string, XmlDictionaryString>();
			strings = null;
			nextId = 0;
		}

		[__DynamicallyInvokable]
		public XmlDictionary(int capacity)
		{
			lookup = new Dictionary<string, XmlDictionaryString>(capacity);
			strings = new XmlDictionaryString[capacity];
			nextId = 0;
		}

		[__DynamicallyInvokable]
		public virtual XmlDictionaryString Add(string value)
		{
			if (!lookup.TryGetValue(value, out var value2))
			{
				if (strings == null)
				{
					strings = new XmlDictionaryString[4];
				}
				else if (nextId == strings.Length)
				{
					int num = nextId * 2;
					if (num == 0)
					{
						num = 4;
					}
					Array.Resize(ref strings, num);
				}
				value2 = new XmlDictionaryString(this, value, nextId);
				strings[nextId] = value2;
				lookup.Add(value, value2);
				nextId++;
			}
			return value2;
		}

		[__DynamicallyInvokable]
		public virtual bool TryLookup(string value, out XmlDictionaryString result)
		{
			return lookup.TryGetValue(value, out result);
		}

		[__DynamicallyInvokable]
		public virtual bool TryLookup(int key, out XmlDictionaryString result)
		{
			if (key < 0 || key >= nextId)
			{
				result = null;
				return false;
			}
			result = strings[key];
			return true;
		}

		[__DynamicallyInvokable]
		public virtual bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result)
		{
			if (value == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception)new ArgumentNullException("value"));
			}
			if (value.Dictionary != this)
			{
				result = null;
				return false;
			}
			result = value;
			return true;
		}
	}
	[__DynamicallyInvokable]
	public delegate void OnXmlDictionaryReaderClose(XmlDictionaryReader reader);
	[__DynamicallyInvokable]
	public abstract class XmlDictionaryReader : XmlReader
	{
		private class XmlWrappedReader : XmlDictionaryReader, IXmlLineInfo
		{
			private XmlReader reader;

			private XmlNamespaceManager nsMgr;

			public override int AttributeCount => reader.AttributeCount;

			public override string BaseURI => reader.BaseURI;

			public override bool CanReadBinaryContent => reader.CanReadBinaryContent;

			public override bool CanReadValueChunk => reader.CanReadValueChunk;

			public override int Depth => reader.Depth;

			public override bool EOF => reader.EOF;

			public override bool HasValue => reader.HasValue;

			public override bool IsDefault => reader.IsDefault;

			public override bool IsEmptyElement => reader.IsEmptyElement;

			public override string LocalName => reader.LocalName;

			public override string Name => reader.Name;

			public override string NamespaceURI => reader.NamespaceURI;

			public override XmlNameTable NameTable => reader.NameTable;

			public override XmlNodeType NodeType => reader.NodeType;

			public override string Prefix => reader.Prefix;

			public override char QuoteChar => reader.QuoteChar;

			public override ReadState ReadState => reader.ReadState;

			public override string this[int index] => reader[index];

			public override string this[string name] => reader[name];

			public override string this[string name, string namespaceUri] => reader[name, namespaceUri];

			public override string Value => reader.Value;

			public override string XmlLang => reader.XmlLang;

			public override XmlSpace XmlSpace => reader.XmlSpace;

			public override Type ValueType => reader.ValueType;

			public int LineNumber
			{
				get
				{
					if (!(reader is IXmlLineInfo xmlLineInfo))
					{
						return 1;
					}
					return xmlLineInfo.LineNumber;
				}
			}

			public int LinePosition
			{
				get
				{
					if (!(reader is IXmlLineInfo xmlLineInfo))
					{
						return 1;
					}
					return xmlLineInfo.LinePosition;
				}
			}

			public XmlWrappedReader(XmlReader reader, XmlNamespaceManager nsMgr)
			{
				this.reader = reader;
				this.nsMgr = nsMgr;
			}

			public override void Close()
			{
				reader.Close();
				nsMgr = null;
			}

			public override string GetAttribute(int index)
			{
				return reader.GetAttribute(index);
			}

			public override string GetAttribute(string name)
			{
				return reader.GetAttribute(name);
			}

			public override string GetAttribute(string name, string namespaceUri)
			{
				return reader.GetAttribute(name, namespaceUri);
			}

			public override bool IsStartElement(string name)
			{
				return reader.IsStartElement(name);
			}

			public override bool IsStartElement(string localName, string namespaceUri)
			{
				return reader.IsStartElement(localName, namespaceUri);
			}

			public override string LookupNamespace(string namespaceUri)
			{
				return reader.LookupNamespace(namespaceUri);
			}

			public override void MoveToAttribute(int index)
			{
				reader.MoveToAttribute(index);
			}

			public override bool MoveToAttribute(string name)
			{
				return reader.MoveToAttribute(name);
			}

			public override bool MoveToAttribute(string name, string namespaceUri)
			{
				return reader.MoveToAttribute(name, namespaceUri);
			}

			public override bool MoveToElement()
			{
				return reader.MoveToElement();
			}

			public override bool MoveToFirstAttribute()
			{
				return reader.MoveToFirstAttribute();
			}

			public override bool MoveToNextAttribute()
			{
				return reader.MoveToNextAttribute();
			}

			public override bool Read()
			{
				return reader.Read();
			}

			public override bool ReadAttributeValue()
			{
				return reader.ReadAttributeValue();
			}

			public override string ReadElementString(string name)
			{
				return reader.ReadElementString(name);
			}

			public override string ReadElementString(string localName, string namespaceUri)
			{
				return reader.ReadElementString(localName, namespaceUri);
			}

			public override string ReadInnerXml()
			{
				return reader.ReadInnerXml();
			}

			public override string ReadOuterXml()
			{
				return reader.ReadOuterXml();
			}

			public override void ReadStartElement(string name)
			{
				reader.ReadStartElement(name);
			}

			public override void ReadStartElement(string localName, string namespaceUri)
			{
				reader.ReadStartElement(localName, namespaceUri);
			}

			public override void ReadEndElement()
			{
				reader.ReadEndElement();
			}

			public override string ReadString()
			{
				return reader.ReadString();
			}

			public override void ResolveEntity()
			{
				reader.ResolveEntity();
			}

			public override int ReadElementContentAsBase64(byte[] buffer, int offset, int count)
			{
				return reader.ReadElementContentAsBase64(buffer, offset, count);
			}

			public override int ReadContentAsBase64(byte[] buffer, int offset, int count)
			{
				return reader.ReadContentAsBase64(buffer, offset, count);
			}

			public override int ReadElementContentAsBinHex(byte[] buffer, int offset, int count)
			{
				return reader.ReadElementContentAsBinHex(buffer, offset, count);
			}

			public override int ReadContentAsBinHex(byte[] buffer, int offset, int count)
			{
				return reader.ReadContentAsBinHex(buffer, offset, count);
			}

			public override int ReadValueChunk(char[] chars, int offset, int count)
			{
				return reader.ReadValueChunk(chars, offset, count);
			}

			public override bool ReadContentAsBoolean()
			{
				return reader.ReadContentAsBoolean();
			}

			public override DateTime ReadContentAsDateTime()
			{
				return reader.ReadContentAsDateTime();
			}

			public override decimal ReadContentAsDecimal()
			{
				return (decimal)reader.ReadContentAs(typeof(decimal), null);
			}

			public override double ReadContentAsDouble()
			{
				return reader.ReadContentAsDouble();
			}

			public override int ReadContentAsInt()
			{
				return reader.ReadContentAsInt();
			}

			public override long ReadContentAsLong()
			{
				return reader.ReadContentAsLong();
			}

			public override float ReadContentAsFloat()
			{
				return reader.ReadContentAsFloat();
			}

			public override string ReadContentAsString()
			{
				return reader.ReadContentAsString();
			}

			public override object ReadContentAs(Type type, IXmlNamespaceResolver namespaceResolver)
			{
				return reader.ReadContentAs(type, namespaceResolver);
			}

			public bool HasLineInfo()
			{
				if (!(reader is IXmlLineInfo xmlLineInfo))
				{
					return false;
				}
				return xmlLineInfo.HasLineInfo();
			}
		}

		internal const int MaxInitialArrayLength = 65535;

		[__DynamicallyInvokable]
		public virtual bool CanCanonicalize
		{
			[__DynamicallyInvokable]
			get
			{
				return false;
			}
		}

		[__DynamicallyInvokable]
		public virtual XmlDictionaryReaderQuotas Quotas
		{
			[__DynamicallyInvokable]
			get
			{
				return XmlDictionaryReaderQuotas.Max;
			}
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateDictionaryReader(XmlReader reader)
		{
			if (reader == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
			}
			XmlDictionaryReader xmlDictionaryReader = reader as XmlDictionaryReader;
			if (xmlDictionaryReader == null)
			{
				xmlDictionaryReader = new XmlWrappedReader(reader, null);
			}
			return xmlDictionaryReader;
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, XmlDictionaryReaderQuotas quotas)
		{
			if (buffer == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer");
			}
			return CreateBinaryReader(buffer, 0, buffer.Length, quotas);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas)
		{
			return CreateBinaryReader(buffer, offset, count, null, quotas);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas)
		{
			return CreateBinaryReader(buffer, offset, count, dictionary, quotas, null);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session)
		{
			return CreateBinaryReader(buffer, offset, count, dictionary, quotas, session, null);
		}

		public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose)
		{
			XmlBinaryReader xmlBinaryReader = new XmlBinaryReader();
			xmlBinaryReader.SetInput(buffer, offset, count, dictionary, quotas, session, onClose);
			return xmlBinaryReader;
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(Stream stream, XmlDictionaryReaderQuotas quotas)
		{
			return CreateBinaryReader(stream, null, quotas);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas)
		{
			return CreateBinaryReader(stream, dictionary, quotas, null);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session)
		{
			return CreateBinaryReader(stream, dictionary, quotas, session, null);
		}

		public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose)
		{
			XmlBinaryReader xmlBinaryReader = new XmlBinaryReader();
			xmlBinaryReader.SetInput(stream, dictionary, quotas, session, onClose);
			return xmlBinaryReader;
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateTextReader(byte[] buffer, XmlDictionaryReaderQuotas quotas)
		{
			if (buffer == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer");
			}
			return CreateTextReader(buffer, 0, buffer.Length, quotas);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas)
		{
			return CreateTextReader(buffer, offset, count, null, quotas, null);
		}

		public static XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
		{
			XmlUTF8TextReader xmlUTF8TextReader = new XmlUTF8TextReader();
			xmlUTF8TextReader.SetInput(buffer, offset, count, encoding, quotas, onClose);
			return xmlUTF8TextReader;
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateTextReader(Stream stream, XmlDictionaryReaderQuotas quotas)
		{
			return CreateTextReader(stream, null, quotas, null);
		}

		[__DynamicallyInvokable]
		public static XmlDictionaryReader CreateTextReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
		{
			XmlUTF8TextReader xmlUTF8TextReader = new XmlUTF8TextReader();
			xmlUTF8TextReader.SetInput(stream, encoding, quotas, onClose);
			return xmlUTF8TextReader;
		}

		public static XmlDictionaryReader CreateMtomReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas)
		{
			if (encoding == null)
			{
				throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("encoding");
			}
			return CreateMtomReader(stream, new Encoding[1] { encoding }, quotas);
		}

		public static XmlDictionaryReader CreateMtomReader(Stream stream, Encoding[] encodings, XmlDictionaryReaderQuotas quotas)
		{
			return CreateMtomReader(stream, encodings, null, quotas);
		}

		public static XmlDictionaryReader CreateMtomReader(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas)
		{
			return CreateMtomReader(stream, encodings, contentType, quotas, int.MaxValue, null);
		}

		public static XmlDictionaryReader CreateMtomReader(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
		{
			XmlMtomReader xmlMtomReader = new XmlMtomReader();
			xmlMtomReader.SetInput(stream, encodings, conte

FuriousButtplug/System.ValueTuple.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Numerics.Hashing;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using FxResources.System.ValueTuple;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.ValueTuple")]
[assembly: AssemblyDescription("System.ValueTuple")]
[assembly: AssemblyDefaultAlias("System.ValueTuple")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.26515.06")]
[assembly: AssemblyInformationalVersion("4.6.26515.06 @BuiltBy: dlab-DDVSOWINAGE059 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/30ab651fcb4354552bd4891619a0bdd81e0ebdbf")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyVersion("4.0.3.0")]
namespace FxResources.System.ValueTuple
{
	internal static class SR : Object
	{
	}
}
namespace System
{
	public static class TupleExtensions : Object
	{
		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1>(this Tuple<T1> value, out T1 item1)
		{
			item1 = value.Item1;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2>(this Tuple<T1, T2> value, out T1 item1, out T2 item2)
		{
			item1 = value.Item1;
			item2 = value.Item2;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3>(this Tuple<T1, T2, T3> value, out T1 item1, out T2 item2, out T3 item3)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5>(this Tuple<T1, T2, T3, T4, T5> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6>(this Tuple<T1, T2, T3, T4, T5, T6> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7>(this Tuple<T1, T2, T3, T4, T5, T6, T7> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19, out T20 item20)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
			item20 = value.Rest.Rest.Item6;
		}

		[EditorBrowsable(/*Could not decode attribute arguments.*/)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19, out T20 item20, out T21 item21)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
			item20 = value.Rest.Rest.Item6;
			item21 = value.Rest.Rest.Item7;
		}

		public static ValueTuple<T1> ToValueTuple<T1>(this Tuple<T1> value)
		{
			return ValueTuple.Create(value.Item1);
		}

		public static (T1, T2) ToValueTuple<T1, T2>(this Tuple<T1, T2> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2);
		}

		public static (T1, T2, T3) ToValueTuple<T1, T2, T3>(this Tuple<T1, T2, T3> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3);
		}

		public static (T1, T2, T3, T4) ToValueTuple<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4);
		}

		public static (T1, T2, T3, T4, T5) ToValueTuple<T1, T2, T3, T4, T5>(this Tuple<T1, T2, T3, T4, T5> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5);
		}

		public static (T1, T2, T3, T4, T5, T6) ToValueTuple<T1, T2, T3, T4, T5, T6>(this Tuple<T1, T2, T3, T4, T5, T6> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6);
		}

		public static (T1, T2, T3, T4, T5, T6, T7) ToValueTuple<T1, T2, T3, T4, T5, T6, T7>(this Tuple<T1, T2, T3, T4, T5, T6, T7> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7);
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, ValueTuple<T15>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19, T20)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19, T20, T21)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6, value.Rest.Rest.Item7)));
		}

		public static Tuple<T1> ToTuple<T1>(this ValueTuple<T1> value)
		{
			return Tuple.Create<T1>(value.Item1);
		}

		public static Tuple<T1, T2> ToTuple<T1, T2>(this (T1, T2) value)
		{
			return Tuple.Create<T1, T2>(value.Item1, value.Item2);
		}

		public static Tuple<T1, T2, T3> ToTuple<T1, T2, T3>(this (T1, T2, T3) value)
		{
			return Tuple.Create<T1, T2, T3>(value.Item1, value.Item2, value.Item3);
		}

		public static Tuple<T1, T2, T3, T4> ToTuple<T1, T2, T3, T4>(this (T1, T2, T3, T4) value)
		{
			return Tuple.Create<T1, T2, T3, T4>(value.Item1, value.Item2, value.Item3, value.Item4);
		}

		public static Tuple<T1, T2, T3, T4, T5> ToTuple<T1, T2, T3, T4, T5>(this (T1, T2, T3, T4, T5) value)
		{
			return Tuple.Create<T1, T2, T3, T4, T5>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6> ToTuple<T1, T2, T3, T4, T5, T6>(this (T1, T2, T3, T4, T5, T6) value)
		{
			return Tuple.Create<T1, T2, T3, T4, T5, T6>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7> ToTuple<T1, T2, T3, T4, T5, T6, T7>(this (T1, T2, T3, T4, T5, T6, T7) value)
		{
			return Tuple.Create<T1, T2, T3, T4, T5, T6, T7>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8>(this (T1, T2, T3, T4, T5, T6, T7, T8) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8>(value.Rest.Item1));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9>(value.Rest.Item1, value.Rest.Item2));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9, T10>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9, T10, T11>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9, T10, T11, T12>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9, T10, T11, T12, T13>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create<T8, T9, T10, T11, T12, T13, T14>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15>(value.Rest.Rest.Item1)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16>(value.Rest.Rest.Item1, value.Rest.Rest.Item2)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16, T17>(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16, T17, T18>(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16, T17, T18, T19>(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16, T17, T18, T19, T20>(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) value)
		{
			return CreateLongRef<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create<T15, T16, T17, T18, T19, T20, T21>(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6, value.Rest.Rest.Item7)));
		}

		private static ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> CreateLong<T1, T2, T3, T4, T5, T6, T7, TRest>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest) where TRest : struct, ValueType
		{
			return new ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>(item1, item2, item3, item4, item5, item6, item7, rest);
		}

		private static Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> CreateLongRef<T1, T2, T3, T4, T5, T6, T7, TRest>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
		{
			return new Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>(item1, item2, item3, item4, item5, item6, item7, rest);
		}
	}
	internal interface ITupleInternal
	{
		int Size { get; }

		int GetHashCode(IEqualityComparer comparer);

		string ToStringEnd();
	}
	[StructLayout(0, Size = 1)]
	public struct ValueTuple : ValueType, IEquatable<ValueTuple>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple>, ITupleInternal
	{
		int ITupleInternal.Size => 0;

		public override bool Equals(object obj)
		{
			return obj is ValueTuple;
		}

		public bool Equals(ValueTuple other)
		{
			return true;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			return other is ValueTuple;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return 0;
		}

		public int CompareTo(ValueTuple other)
		{
			return 0;
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return 0;
		}

		public override int GetHashCode()
		{
			return 0;
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return 0;
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return 0;
		}

		public override string ToString()
		{
			return "()";
		}

		string ITupleInternal.ToStringEnd()
		{
			return ")";
		}

		public static ValueTuple Create()
		{
			return default(ValueTuple);
		}

		public static ValueTuple<T1> Create<T1>(T1 item1)
		{
			return new ValueTuple<T1>(item1);
		}

		public static (T1, T2) Create<T1, T2>(T1 item1, T2 item2)
		{
			return (item1, item2);
		}

		public static (T1, T2, T3) Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
		{
			return (item1, item2, item3);
		}

		public static (T1, T2, T3, T4) Create<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4)
		{
			return (item1, item2, item3, item4);
		}

		public static (T1, T2, T3, T4, T5) Create<T1, T2, T3, T4, T5>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
		{
			return (item1, item2, item3, item4, item5);
		}

		public static (T1, T2, T3, T4, T5, T6) Create<T1, T2, T3, T4, T5, T6>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
		{
			return (item1, item2, item3, item4, item5, item6);
		}

		public static (T1, T2, T3, T4, T5, T6, T7) Create<T1, T2, T3, T4, T5, T6, T7>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
		{
			return (item1, item2, item3, item4, item5, item6, item7);
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8) Create<T1, T2, T3, T4, T5, T6, T7, T8>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
		{
			return new ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>>(item1, item2, item3, item4, item5, item6, item7, Create(item8));
		}

		internal static int CombineHashCodes(int h1, int h2)
		{
			return HashHelpers.Combine(HashHelpers.Combine(HashHelpers.RandomSeed, h1), h2);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2), h3);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3), h4);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4), h5);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5), h6);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5, h6), h7);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5, h6, h7), h8);
		}
	}
	public struct ValueTuple<T1> : ValueType, IEquatable<ValueTuple<T1>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1>>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		public T1 Item1;

		int ITupleInternal.Size => 1;

		public ValueTuple(T1 item1)
		{
			Item1 = item1;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1>)
			{
				return Equals((ValueTuple<T1>)obj);
			}
			return false;
		}

		public bool Equals(ValueTuple<T1> other)
		{
			return s_t1Comparer.Equals(Item1, other.Item1);
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is ValueTuple<T1> valueTuple))
			{
				return false;
			}
			return comparer.Equals((object)Item1, (object)valueTuple.Item1);
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return Comparer<T1>.Default.Compare(Item1, valueTuple.Item1);
		}

		public int CompareTo(ValueTuple<T1> other)
		{
			return Comparer<T1>.Default.Compare(Item1, other.Item1);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return comparer.Compare((object)Item1, (object)valueTuple.Item1);
		}

		public override int GetHashCode()
		{
			return s_t1Comparer.GetHashCode(Item1);
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return comparer.GetHashCode((object)Item1);
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return comparer.GetHashCode((object)Item1);
		}

		public override string ToString()
		{
			return String.Concat("(", ((Object)(Item1?)).ToString(), ")");
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat(((Object)(Item1?)).ToString(), ")");
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2> : ValueType, IEquatable<(T1, T2)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		int ITupleInternal.Size => 2;

		public ValueTuple(T1 item1, T2 item2)
		{
			Item1 = item1;
			Item2 = item2;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2>)
			{
				return Equals(((T1, T2))obj);
			}
			return false;
		}

		public bool Equals((T1, T2) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1))
			{
				return ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1))
			{
				return comparer.Equals((object)Item2, (object)tuple.Item2);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2))other);
		}

		public int CompareTo((T1, T2) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item2, (object)tuple.Item2);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[5]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat(((Object)(Item1?)).ToString(), ", ", ((Object)(Item2?)).ToString(), ")");
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3> : ValueType, IEquatable<(T1, T2, T3)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		int ITupleInternal.Size => 3;

		public ValueTuple(T1 item1, T2 item2, T3 item3)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3>)
			{
				return Equals(((T1, T2, T3))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2))
			{
				return ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1) && comparer.Equals((object)Item2, (object)tuple.Item2))
			{
				return comparer.Equals((object)Item3, (object)tuple.Item3);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3))other);
		}

		public int CompareTo((T1, T2, T3) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item3, (object)tuple.Item3);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[7]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat((string[])(object)new String[6]
			{
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				")"
			});
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3, T4> : ValueType, IEquatable<(T1, T2, T3, T4)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		int ITupleInternal.Size => 4;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4>)
			{
				return Equals(((T1, T2, T3, T4))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2) && ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3))
			{
				return ((EqualityComparer<?>)(object)s_t4Comparer).Equals(Item4, other.Item4);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1) && comparer.Equals((object)Item2, (object)tuple.Item2) && comparer.Equals((object)Item3, (object)tuple.Item3))
			{
				return comparer.Equals((object)Item4, (object)tuple.Item4);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4))other);
		}

		public int CompareTo((T1, T2, T3, T4) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item4, other.Item4);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item3, (object)tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item4, (object)tuple.Item4);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[9]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat((string[])(object)new String[8]
			{
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				")"
			});
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3, T4, T5> : ValueType, IEquatable<(T1, T2, T3, T4, T5)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		int ITupleInternal.Size => 5;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5>)
			{
				return Equals(((T1, T2, T3, T4, T5))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2) && ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3) && ((EqualityComparer<?>)(object)s_t4Comparer).Equals(Item4, other.Item4))
			{
				return ((EqualityComparer<?>)(object)s_t5Comparer).Equals(Item5, other.Item5);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1) && comparer.Equals((object)Item2, (object)tuple.Item2) && comparer.Equals((object)Item3, (object)tuple.Item3) && comparer.Equals((object)Item4, (object)tuple.Item4))
			{
				return comparer.Equals((object)Item5, (object)tuple.Item5);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item5, other.Item5);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item3, (object)tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item4, (object)tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item5, (object)tuple.Item5);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[11]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat((string[])(object)new String[10]
			{
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				")"
			});
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6> : ValueType, IEquatable<(T1, T2, T3, T4, T5, T6)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5, T6)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		int ITupleInternal.Size => 6;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6>)
			{
				return Equals(((T1, T2, T3, T4, T5, T6))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5, T6) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2) && ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3) && ((EqualityComparer<?>)(object)s_t4Comparer).Equals(Item4, other.Item4) && ((EqualityComparer<?>)(object)s_t5Comparer).Equals(Item5, other.Item5))
			{
				return ((EqualityComparer<?>)(object)s_t6Comparer).Equals(Item6, other.Item6);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5, T6) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1) && comparer.Equals((object)Item2, (object)tuple.Item2) && comparer.Equals((object)Item3, (object)tuple.Item3) && comparer.Equals((object)Item4, (object)tuple.Item4) && comparer.Equals((object)Item5, (object)tuple.Item5))
			{
				return comparer.Equals((object)Item6, (object)tuple.Item6);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5, T6))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5, T6) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item6, other.Item6);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5, T6) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item3, (object)tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item4, (object)tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item5, (object)tuple.Item5);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item6, (object)tuple.Item6);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[13]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				", ",
				((Object)(Item6?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat((string[])(object)new String[12]
			{
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				", ",
				((Object)(Item6?)).ToString(),
				")"
			});
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7> : ValueType, IEquatable<(T1, T2, T3, T4, T5, T6, T7)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5, T6, T7)>, ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T7> s_t7Comparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		public T7 Item7;

		int ITupleInternal.Size => 7;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
			Item7 = item7;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7>)
			{
				return Equals(((T1, T2, T3, T4, T5, T6, T7))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5, T6, T7) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2) && ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3) && ((EqualityComparer<?>)(object)s_t4Comparer).Equals(Item4, other.Item4) && ((EqualityComparer<?>)(object)s_t5Comparer).Equals(Item5, other.Item5) && ((EqualityComparer<?>)(object)s_t6Comparer).Equals(Item6, other.Item6))
			{
				return ((EqualityComparer<?>)(object)s_t7Comparer).Equals(Item7, other.Item7);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5, T6, T7) tuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)tuple.Item1) && comparer.Equals((object)Item2, (object)tuple.Item2) && comparer.Equals((object)Item3, (object)tuple.Item3) && comparer.Equals((object)Item4, (object)tuple.Item4) && comparer.Equals((object)Item5, (object)tuple.Item5) && comparer.Equals((object)Item6, (object)tuple.Item6))
			{
				return comparer.Equals((object)Item7, (object)tuple.Item7);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5, T6, T7))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5, T6, T7) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item6, other.Item6);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item7, other.Item7);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5, T6, T7) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item3, (object)tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item4, (object)tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item5, (object)tuple.Item5);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item6, (object)tuple.Item6);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Item7, (object)tuple.Item7);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7));
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return String.Concat((string[])(object)new String[15]
			{
				"(",
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				", ",
				((Object)(Item6?)).ToString(),
				", ",
				((Object)(Item7?)).ToString(),
				")"
			});
		}

		string ITupleInternal.ToStringEnd()
		{
			return String.Concat((string[])(object)new String[14]
			{
				((Object)(Item1?)).ToString(),
				", ",
				((Object)(Item2?)).ToString(),
				", ",
				((Object)(Item3?)).ToString(),
				", ",
				((Object)(Item4?)).ToString(),
				", ",
				((Object)(Item5?)).ToString(),
				", ",
				((Object)(Item6?)).ToString(),
				", ",
				((Object)(Item7?)).ToString(),
				")"
			});
		}
	}
	[StructLayout(3)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> : ValueType, IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, ITupleInternal where TRest : struct, ValueType
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<T7> s_t7Comparer = EqualityComparer<?>.Default;

		private static readonly EqualityComparer<TRest> s_tRestComparer = EqualityComparer<?>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		public T7 Item7;

		public TRest Rest;

		int ITupleInternal.Size
		{
			get
			{
				if ((object)Rest is ITupleInternal tupleInternal)
				{
					return 7 + tupleInternal.Size;
				}
				return 8;
			}
		}

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!(rest is ITupleInternal))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleLastArgumentNotAValueTuple);
			}
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
			Item7 = item7;
			Rest = rest;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)
			{
				return Equals((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)obj);
			}
			return false;
		}

		public bool Equals(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && ((EqualityComparer<?>)(object)s_t2Comparer).Equals(Item2, other.Item2) && ((EqualityComparer<?>)(object)s_t3Comparer).Equals(Item3, other.Item3) && ((EqualityComparer<?>)(object)s_t4Comparer).Equals(Item4, other.Item4) && ((EqualityComparer<?>)(object)s_t5Comparer).Equals(Item5, other.Item5) && ((EqualityComparer<?>)(object)s_t6Comparer).Equals(Item6, other.Item6) && ((EqualityComparer<?>)(object)s_t7Comparer).Equals(Item7, other.Item7))
			{
				return ((EqualityComparer<?>)(object)s_tRestComparer).Equals(Rest, other.Rest);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> valueTuple))
			{
				return false;
			}
			if (comparer.Equals((object)Item1, (object)valueTuple.Item1) && comparer.Equals((object)Item2, (object)valueTuple.Item2) && comparer.Equals((object)Item3, (object)valueTuple.Item3) && comparer.Equals((object)Item4, (object)valueTuple.Item4) && comparer.Equals((object)Item5, (object)valueTuple.Item5) && comparer.Equals((object)Item6, (object)valueTuple.Item6) && comparer.Equals((object)Item7, (object)valueTuple.Item7))
			{
				return comparer.Equals((object)Rest, (object)valueTuple.Rest);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)other);
		}

		public int CompareTo(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item6, other.Item6);
			if (num != 0)
			{
				return num;
			}
			num = ((Comparer<?>)(object)Comparer<?>.Default).Compare(Item7, other.Item7);
			if (num != 0)
			{
				return num;
			}
			return ((Comparer<?>)(object)Comparer<?>.Default).Compare(Rest, other.Rest);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare((object)Item1, (object)valueTuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item2, (object)valueTuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item3, (object)valueTuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item4, (object)valueTuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item5, (object)valueTuple.Item5);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item6, (object)valueTuple.Item6);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare((object)Item7, (object)valueTuple.Item7);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare((object)Rest, (object)valueTuple.Rest);
		}

		public override int GetHashCode()
		{
			if (!((object)Rest is ITupleInternal tupleInternal))
			{
				return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7));
			}
			int size = tupleInternal.Size;
			if (size >= 8)
			{
				return ((Object)tupleInternal).GetHashCode();
			}
			switch (8 - size)
			{
			case 1:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 2:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 3:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 4:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 5:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 6:
				return ValueTuple.CombineHashCodes(((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			case 7:
			case 8:
				return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), ((EqualityComparer<?>)(object)s_t2Comparer).GetHashCode(Item2), ((EqualityComparer<?>)(object)s_t3Comparer).GetHashCode(Item3), ((EqualityComparer<?>)(object)s_t4Comparer).GetHashCode(Item4), ((EqualityComparer<?>)(object)s_t5Comparer).GetHashCode(Item5), ((EqualityComparer<?>)(object)s_t6Comparer).GetHashCode(Item6), ((EqualityComparer<?>)(object)s_t7Comparer).GetHashCode(Item7), ((Object)tupleInternal).GetHashCode());
			default:
				return -1;
			}
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			if (!((object)Rest is ITupleInternal tupleInternal))
			{
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7));
			}
			int size = tupleInternal.Size;
			if (size >= 8)
			{
				return tupleInternal.GetHashCode(comparer);
			}
			switch (8 - size)
			{
			case 1:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 2:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 3:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 4:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 5:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 6:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			case 7:
			case 8:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode((object)Item1), comparer.GetHashCode((object)Item2), comparer.GetHashCode((object)Item3), comparer.GetHashCode((object)Item4), comparer.GetHashCode((object)Item5), comparer.GetHashCode((object)Item6), comparer.GetHashCode((object)Item7), tupleInternal.GetHashCode(comparer));
			default:
				return -1;
			}
		}

		int ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			String[] obj;
			T1 val;
			object obj2;
			if (!((object)Rest is ITupleInternal tupleInternal))
			{
				obj = new String[17]
				{
					"(",
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String),
					default(String)
				};
				ref T1 reference = ref Item1;
				val = default(T1);
				if (val == null)
				{
					val = reference;
					reference = ref val;
					if (val == null)
					{
						obj2 = null;
						goto IL_005d;
					}
				}
				obj2 = ((Object)reference).ToString();
				goto IL_005d;
			}
			String[] obj3 = new String[16]
			{
				"(",
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String),
				default(String)
			};
			ref T1 reference2 = ref Item1;
			val = default(T1);
			object obj4;
			if (val == null)
			{
				val = reference2;
				reference2 = ref val;
				if (val == null)
				{
					obj4 = null;
					goto IL_0262;
				}
			}
			obj4 = ((Object)reference2).ToString();
			goto IL_0262;
			IL_02e2:
			object obj5;
			obj3[5] = (String)obj5;
			obj3[6] = ", ";
			ref T4 reference3 = ref Item4;
			T4 val2 = default(T4);
			object obj6;
			if (val2 == null)
			{
				val2 = reference3;
				reference3 = ref val2;
				if (val2 == null)
				{
					obj6 = null;
					goto IL_0325;
				}
			}
			obj6 = ((Object)reference3).ToString();
			goto IL_0325;
			IL_03f3:
			object obj7;
			obj3[13] = (String)obj7;
			obj3[14] = ", ";
			obj3[15] = tupleInternal.ToStringEnd();
			return String.Concat((string[])(object)obj3);
			IL_03ae:
			object obj8;
			obj3[11] = (String)obj8;
			obj3[12] = ", ";
			ref T7 reference4 = ref Item7;
			T7 val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference4;
				reference4 = ref val3;
				if (val3 == null)
				{
					obj7 = null;
					goto IL_03f3;
				}
			}
			obj7 = ((Object)reference4).ToString();
			goto IL_03f3;
			IL_0120:
			object obj9;
			obj[7] = (String)obj9;
			obj[8] = ", ";
			ref T5 reference5 = ref Item5;
			T5 val4 = default(T5);
			object obj10;
			if (val4 == null)
			{
				val4 = reference5;
				reference5 = ref val4;
				if (val4 == null)
				{
					obj10 = null;
					goto IL_0164;
				}
			}
			obj10 = ((Object)reference5).ToString();
			goto IL_0164;
			IL_005d:
			obj[1] = (String)obj2;
			obj[2] = ", ";
			ref T2 reference6 = ref Item2;
			T2 val5 = default(T2);
			object obj11;
			if (val5 == null)
			{
				val5 = reference6;
				reference6 = ref val5;
				if (val5 == null)
				{
					obj11 = null;
					goto IL_009d;
				}
			}
			obj11 = ((Object)reference6).ToString();
			goto IL_009d;
			IL_0164:
			obj[9] = (String)obj10;
			obj[10] = ", ";
			ref T6 reference7 = ref Item6;
			T6 val6 = default(T6);
			object obj12;
			if (val6 == null)
			{
				val6 = reference7;
				reference7 = ref val6;
				if (val6 == null)
				{
					obj12 = null;
					goto IL_01a9;
				}
			}
			obj12 = ((Object)reference7).ToString();
			goto IL_01a9;
			IL_02a2:
			object obj13;
			obj3[3] = (String)obj13;
			obj3[4] = ", ";
			ref T3 reference8 = ref Item3;
			T3 val7 = default(T3);
			if (val7 == null)
			{
				val7 = reference8;
				reference8 = ref val7;
				if (val7 == null)
				{
					obj5 = null;
					goto IL_02e2;
				}
			}
			obj5 = ((Object)reference8).ToString();
			goto IL_02e2;
			IL_01ee:
			object obj14;
			obj[13] = (String)obj14;
			obj[14] = ", ";
			obj[15] = ((Object)Rest).ToString();
			obj[16] = ")";
			return String.Concat((string[])(object)obj);
			IL_009d:
			obj[3] = (String)obj11;
			obj[4] = ", ";
			ref T3 reference9 = ref Item3;
			val7 = default(T3);
			object obj15;
			if (val7 == null)
			{
				val7 = reference9;
				reference9 = ref val7;
				if (val7 == null)
				{
					obj15 = null;
					goto IL_00dd;
				}
			}
			obj15 = ((Object)reference9).ToString();
			goto IL_00dd;
			IL_0325:
			obj3[7] = (String)obj6;
			obj3[8] = ", ";
			ref T5 reference10 = ref Item5;
			val4 = default(T5);
			object obj16;
			if (val4 == null)
			{
				val4 = reference10;
				reference10 = ref val4;
				if (val4 == null)
				{
					obj16 = null;
					goto IL_0369;
				}
			}
			obj16 = ((Object)reference10).ToString();
			goto IL_0369;
			IL_01a9:
			obj[11] = (String)obj12;
			obj[12] = ", ";
			ref T7 reference11 = ref Item7;
			val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference11;
				reference11 = ref val3;
				if (val3 == null)
				{
					obj14 = null;
					goto IL_01ee;
				}
			}
			obj14 = ((Object)reference11).ToString();
			goto IL_01ee;
			IL_0262:
			obj3[1] = (String)obj4;
			obj3[2] = ", ";
			ref T2 reference12 = ref Item2;
			val5 = default(T2);
			if (val5 == null)
			{
				val5 = reference12;
				reference12 = ref val5;
				if (val5 == null)
				{
					obj13 = null;
					goto IL_02a2;
				}
			}
			obj13 = ((Object)reference12).ToString();
			goto IL_02a2;
			IL_00dd:
			obj[5] = (String)obj15;
			obj[6] = ", ";
			ref T4 reference13 = ref Item4;
			val2 = default(T4);
			if (val2 == null)
			{
				val2 = reference13;
				reference13 = ref val2;
				if (val2 == null)
				{
					obj9 = null;
					goto IL_0120;
				}
			}
			obj9 = ((Object)reference13).ToString();
			goto IL_0120;
			IL_0369:
			obj3[9] = (String)obj16;
			obj3[10] = ", ";
			ref T6 reference14 = ref Item6;
			val6 = default(T6);
			if (val6 == null)
			{
				val6 = reference14;
				reference14 = ref val6;
				if (val6 == null)
				{
					obj8 = null;
					goto IL_03ae;
				}
			}
			obj8 = ((Object)reference14).ToString();
			goto IL_03ae;
		}

		string ITupleInternal.ToStringEnd()
		{
			String[] array;
			T1 val;
			object obj;
			if (!((object)Rest is ITupleInternal tupleInternal))
			{
				array = new String[16];
				ref T1 reference = ref Item1;
				val = default(T1);
				if (val == null)
				{
					val = reference;
					reference = ref val;
					if (val == null)
					{
						obj = null;
						goto IL_0055;
					}
				}
				obj = ((Object)reference).ToString();
				goto IL_0055;
			}
			String[] array2 = new String[15];
			ref T1 reference2 = ref Item1;
			val = default(T1);
			object obj2;
			if (val == null)
			{
				val = reference2;
				reference2 = ref val;
				if (val == null)
				{
					obj2 = null;
					goto IL_0251;
				}
			}
			obj2 = ((Object)reference2).ToString();
			goto IL_0251;
			IL_02d1:
			object obj3;
			array2[4] = (String)obj3;
			array2[5] = ", ";
			ref T4 reference3 = ref Item4;
			T4 val2 = default(T4);
			object obj4;
			if (val2 == null)
			{
				val2 = reference3;
				reference3 = ref val2;
				if (val2 == null)
				{
					obj4 = null;
					goto IL_0314;
				}
			}
			obj4 = ((Object)reference3).ToString();
			goto IL_0314;
			IL_03e1:
			object obj5;
			array2[12] = (String)obj5;
			array2[13] = ", ";
			array2[14] = tupleInternal.ToStringEnd();
			return String.Concat((string[])(object)array2);
			IL_039c:
			object obj6;
			array2[10] = (String)obj6;
			array2[11] = ", ";
			ref T7 reference4 = ref Item7;
			T7 val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference4;
				reference4 = ref val3;
				if (val3 == null)
				{
					obj5 = null;
					goto IL_03e1;
				}
			}
			obj5 = ((Object)reference4).ToString();
			goto IL_03e1;
			IL_0118:
			object obj7;
			array[6] = (String)obj7;
			array[7] = ", ";
			ref T5 reference5 = ref Item5;
			T5 val4 = default(T5);
			object obj8;
			if (val4 == null)
			{
				val4 = reference5;
				reference5 = ref val4;
				if (val4 == null)
				{
					obj8 = null;
					goto IL_015b;
				}
			}
			obj8 = ((Object)reference5).ToString();
			goto IL_015b;
			IL_0055:
			array[0] = (String)obj;
			array[1] = ", ";
			ref T2 reference6 = ref Item2;
			T2 val5 = default(T2);
			object obj9;
			if (val5 == null)
			{
				val5 = reference6;
				reference6 = ref val5;
				if (val5 == null)
				{
					obj9 = null;
					goto IL_0095;
				}
			}
			obj9 = ((Object)reference6).ToString();
			goto IL_0095;
			IL_015b:
			array[8] = (String)obj8;
			array[9] = ", ";
			ref T6 reference7 = ref Item6;
			T6 val6 = default(T6);
			object obj10;
			if (val6 == null)
			{
				val6 = reference7;
				reference7 = ref val6;
				if (val6 == null)
				{
					obj10 = null;
					goto IL_01a0;
				}
			}
			obj10 = ((Object)reference7).ToString();
			goto IL_01a0;
			IL_0291:
			object obj11;
			array2[2] = (String)obj11;
			array2[3] = ", ";
			ref T3 reference8 = ref Item3;
			T3 val7 = default(T3);
			if (val7 == null)
			{
				val7 = reference8;
				reference8 = ref val7;
				if (val7 == null)
				{
					obj3 = null;
					goto IL_02d1;
				}
			}
			obj3 = ((Object)reference8).ToString();
			goto IL_02d1;
			IL_01e5:
			object obj12;
			array[12] = (String)obj12;
			array[13] = ", ";
			array[14] = ((Object)Rest).ToString();
			array[15] = ")";
			return String.Concat((string[])(object)array);
			IL_0095:
			array[2] = (String)obj9;
			array[3] = ", ";
			ref T3 reference9 = ref Item3;
			val7 = default(T3);
			object obj13;
			if (val7 == null)
			{
				val7 = reference9;
				reference9 = ref val7;
				if (val7 == null)
				{
					obj13 = null;
					goto IL_00d5;
				}
			}
			obj13 = ((Object)reference9).ToString();
			goto IL_00d5;
			IL_0314:
			array2[6] = (String)obj4;
			array2[7] = ", ";
			ref T5 reference10 = ref Item5;
			val4 = default(T5);
			object obj14;
			if (val4 == null)
			{
				val4 = reference10;
				reference10 = ref val4;
				if (val4 == null)
				{
					obj14 = null;
					goto IL_0357;
				}
			}
			obj14 = ((Object)reference10).ToString();
			goto IL_0357;
			IL_01a0:
			array[10] = (String)obj10;
			array[11] = ", ";
			ref T7 reference11 = ref Item7;
			val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference11;
				reference11 = ref val3;
				if (val3 == null)
				{
					obj12 = null;
					goto IL_01e5;
				}
			}
			obj12 = ((Object)reference11).ToString();
			goto IL_01e5;
			IL_0251:
			array2[0] = (String)obj2;
			array2[1] = ", ";
			ref T2 reference12 = ref Item2;
			val5 = default(T2);
			if (val5 == null)
			{
				val5 = reference12;
				reference12 = ref val5;
				if (val5 == null)
				{
					obj11 = null;
					goto IL_0291;
				}
			}
			obj11 = ((Object)reference12).ToString();
			goto IL_0291;
			IL_00d5:
			array[4] = (String)obj13;
			array[5] = ", ";
			ref T4 reference13 = ref Item4;
			val2 = default(T4);
			if (val2 == null)
			{
				val2 = reference13;
				reference13 = ref val2;
				if (val2 == null)
				{
					obj7 = null;
					goto IL_0118;
				}
			}
			obj7 = ((Object)reference13).ToString();
			goto IL_0118;
			IL_0357:
			array2[8] = (String)obj14;
			array2[9] = ", ";
			ref T6 reference14 = ref Item6;
			val6 = default(T6);
			if (val6 == null)
			{
				val6 = reference14;
				reference14 = ref val6;
				if (val6 == null)
				{
					obj6 = null;
					goto IL_039c;
				}
			}
			obj6 = ((Object)reference14).ToString();
			goto IL_039c;
		}
	}
	internal static class SR : Object
	{
		private static ResourceManager s_resourceManager;

		private static ResourceManager ResourceManager
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Expected O, but got Unknown
				object obj = s_resourceManager;
				if (obj == null)
				{
					ResourceManager val = new ResourceManager(ResourceType);
					s_resourceManager = val;
					obj = (object)val;
				}
				return (ResourceManager)obj;
			}
		}

		[field: CompilerGenerated]
		internal static Type ResourceType
		{
			[CompilerGenerated]
			get;
		} = typeof(SR);


		internal static string ArgumentException_ValueTupleIncorrectType => GetResourceString("ArgumentException_ValueTupleIncorrectType", null);

		internal static string ArgumentException_ValueTupleLastArgumentNotAValueTuple => GetResourceString("ArgumentException_ValueTupleLastArgumentNotAValueTuple", null);

		[MethodImpl(8)]
		private static bool UsingResourceKeys()
		{
			return false;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string text = null;
			try
			{
				text = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			if (defaultString != null && resourceKey.Equals(text, (StringComparison)4))
			{
				return defaultString;
			}
			return text;
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return String.Concat(resourceFormat, String.Join(", ", args));
				}
				return String.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return String.Join(", ", (object[])(object)new Object[2]
				{
					(Object)resourceFormat,
					p1
				});
			}
			return String.Format(resourceFormat, (object[])(object)new Object[1] { p1 });
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return String.Join(", ", (object[])(object)new Object[3]
				{
					(Object)resourceFormat,
					p1,
					p2
				});
			}
			return String.Format(resourceFormat, (object[])(object)new Object[2] { p1, p2 });
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return String.Join(", ", (object[])(object)new Object[4]
				{
					(Object)resourceFormat,
					p1,
					p2,
					p3
				});
			}
			return String.Format(resourceFormat, (object[])(object)new Object[3] { p1, p2, p3 });
		}
	}
}
namespace System.Numerics.Hashing
{
	internal static class HashHelpers : Object
	{
		public static readonly int RandomSeed;

		public static int Combine(int h1, int h2)
		{
			uint num = (uint)(h1 << 5) | ((uint)h1 >> 27);
			return ((int)num + h1) ^ h2;
		}

		static HashHelpers()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Guid val = Guid.NewGuid();
			RandomSeed = ((Object)(Guid)(ref val)).GetHashCode();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[CLSCompliant(false)]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	public sealed class TupleElementNamesAttribute : Attribute
	{
		private readonly string[] _transformNames;

		public IList<string> TransformNames => (IList<string>)(object)_transformNames;

		public TupleElementNamesAttribute(string[] transformNames)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (transformNames == null)
			{
				throw new ArgumentNullException("transformNames");
			}
			_transformNames = transformNames;
		}
	}
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal class __BlockReflectionAttribute : Attribute
	{
	}
}