Decompiled source of Mod the Gungeon API v1.7.6

monomod/UnityEngine.CoreModule.MTGAPIPatcher.mm.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using MonoMod;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MTGAPIPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MTGAPIPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d59c59db-e716-4050-860e-762f0a0d8524")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MTGAPIPatcher;

[MonoModPatch("UnityEngine.Object")]
internal class patch_Object : Object
{
	public static T Instantiate<T>(T original) where T : Object
	{
		return (T)(object)Instantiate((Object)(object)original);
	}

	public static Object Instantiate(Object original)
	{
		return orig_Instantiate(original);
	}

	public static extern Object orig_Instantiate(Object original);
}

plugins/MtGAPI/Ionic.Zip.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Ionic.BZip2;
using Ionic.Crc;
using Ionic.Zip;
using Ionic.Zlib;
using Microsoft.CSharp;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Guid("dfd2b1f6-e3be-43d1-9b43-11aae1e901d8")]
[assembly: CLSCompliant(true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: ComVisible(true)]
[assembly: AssemblyCopyright("Copyright © Dino Chiesa 2006 - 2011")]
[assembly: AssemblyDescription("a library for handling zip archives. http://www.codeplex.com/DotNetZip (Flavor=Retail)")]
[assembly: AssemblyCompany("Dino Chiesa")]
[assembly: AssemblyProduct("DotNetZip Library")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyFileVersion("1.9.1.8")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyTitle("Ionic's Zip Library")]
[assembly: AssemblyConfiguration("Retail")]
[assembly: AssemblyVersion("1.9.1.8")]
namespace Ionic.Zip
{
	public enum ZipEntrySource
	{
		None,
		FileSystem,
		Stream,
		ZipFile,
		WriteDelegate,
		JitStream,
		ZipOutputStream
	}
	public class ZipOutputStream : Stream
	{
		private EncryptionAlgorithm _encryption;

		private ZipEntryTimestamp _timestamp;

		internal string _password;

		private string _comment;

		private Stream _outputStream;

		private ZipEntry _currentEntry;

		internal Zip64Option _zip64;

		private Dictionary<string, ZipEntry> _entriesWritten;

		private int _entryCount;

		private ZipOption _alternateEncodingUsage;

		private Encoding _alternateEncoding = Encoding.GetEncoding("IBM437");

		private bool _leaveUnderlyingStreamOpen;

		private bool _disposed;

		private bool _exceptionPending;

		private bool _anyEntriesUsedZip64;

		private bool _directoryNeededZip64;

		private CountingStream _outputCounter;

		private Stream _encryptor;

		private Stream _deflater;

		private CrcCalculatorStream _entryOutputStream;

		private bool _needToWriteEntryHeader;

		private string _name;

		private bool _DontIgnoreCase;

		internal ParallelDeflateOutputStream ParallelDeflater;

		private long _ParallelDeflateThreshold;

		private int _maxBufferPairs = 16;

		public string Password
		{
			set
			{
				if (_disposed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				_password = value;
				if (_password == null)
				{
					_encryption = EncryptionAlgorithm.None;
				}
				else if (_encryption == EncryptionAlgorithm.None)
				{
					_encryption = EncryptionAlgorithm.PkzipWeak;
				}
			}
		}

		public EncryptionAlgorithm Encryption
		{
			get
			{
				return _encryption;
			}
			set
			{
				if (_disposed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				if (value == EncryptionAlgorithm.Unsupported)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("You may not set Encryption to that value.");
				}
				_encryption = value;
			}
		}

		public int CodecBufferSize { get; set; }

		public CompressionStrategy Strategy { get; set; }

		public ZipEntryTimestamp Timestamp
		{
			get
			{
				return _timestamp;
			}
			set
			{
				if (_disposed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				_timestamp = value;
			}
		}

		public CompressionLevel CompressionLevel { get; set; }

		public CompressionMethod CompressionMethod { get; set; }

		public string Comment
		{
			get
			{
				return _comment;
			}
			set
			{
				if (_disposed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				_comment = value;
			}
		}

		public Zip64Option EnableZip64
		{
			get
			{
				return _zip64;
			}
			set
			{
				if (_disposed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				_zip64 = value;
			}
		}

		public bool OutputUsedZip64
		{
			get
			{
				if (!_anyEntriesUsedZip64)
				{
					return _directoryNeededZip64;
				}
				return true;
			}
		}

		public bool IgnoreCase
		{
			get
			{
				return !_DontIgnoreCase;
			}
			set
			{
				_DontIgnoreCase = !value;
			}
		}

		[Obsolete("Beginning with v1.9.1.6 of DotNetZip, this property is obsolete. It will be removed in a future version of the library. Use AlternateEncoding and AlternateEncodingUsage instead.")]
		public bool UseUnicodeAsNecessary
		{
			get
			{
				if (_alternateEncoding == Encoding.UTF8)
				{
					return AlternateEncodingUsage == ZipOption.AsNecessary;
				}
				return false;
			}
			set
			{
				if (value)
				{
					_alternateEncoding = Encoding.UTF8;
					_alternateEncodingUsage = ZipOption.AsNecessary;
				}
				else
				{
					_alternateEncoding = DefaultEncoding;
					_alternateEncodingUsage = ZipOption.Default;
				}
			}
		}

		[Obsolete("use AlternateEncoding and AlternateEncodingUsage instead.")]
		public Encoding ProvisionalAlternateEncoding
		{
			get
			{
				if (_alternateEncodingUsage == ZipOption.AsNecessary)
				{
					return _alternateEncoding;
				}
				return null;
			}
			set
			{
				_alternateEncoding = value;
				_alternateEncodingUsage = ZipOption.AsNecessary;
			}
		}

		public Encoding AlternateEncoding
		{
			get
			{
				return _alternateEncoding;
			}
			set
			{
				_alternateEncoding = value;
			}
		}

		public ZipOption AlternateEncodingUsage
		{
			get
			{
				return _alternateEncodingUsage;
			}
			set
			{
				_alternateEncodingUsage = value;
			}
		}

		public static Encoding DefaultEncoding => Encoding.GetEncoding("IBM437");

		public long ParallelDeflateThreshold
		{
			get
			{
				return _ParallelDeflateThreshold;
			}
			set
			{
				if (value != 0 && value != -1 && value < 65536)
				{
					throw new ArgumentOutOfRangeException("value must be greater than 64k, or 0, or -1");
				}
				_ParallelDeflateThreshold = value;
			}
		}

		public int ParallelDeflateMaxBufferPairs
		{
			get
			{
				return _maxBufferPairs;
			}
			set
			{
				if (value < 4)
				{
					throw new ArgumentOutOfRangeException("ParallelDeflateMaxBufferPairs", "Value must be 4 or greater.");
				}
				_maxBufferPairs = value;
			}
		}

		internal Stream OutputStream => _outputStream;

		internal string Name => _name;

		public override bool CanRead => false;

		public override bool CanSeek => false;

		public override bool CanWrite => true;

		public override long Length
		{
			get
			{
				throw new NotSupportedException();
			}
		}

		public override long Position
		{
			get
			{
				return _outputStream.Position;
			}
			set
			{
				throw new NotSupportedException();
			}
		}

		public ZipOutputStream(Stream stream)
			: this(stream, leaveOpen: false)
		{
		}

		public ZipOutputStream(string fileName)
		{
			Stream stream = File.Open(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
			_Init(stream, leaveOpen: false, fileName);
		}

		public ZipOutputStream(Stream stream, bool leaveOpen)
		{
			_Init(stream, leaveOpen, null);
		}

		private void _Init(Stream stream, bool leaveOpen, string name)
		{
			_outputStream = (stream.CanRead ? stream : new CountingStream(stream));
			CompressionLevel = CompressionLevel.Default;
			CompressionMethod = CompressionMethod.Deflate;
			_encryption = EncryptionAlgorithm.None;
			_entriesWritten = new Dictionary<string, ZipEntry>(StringComparer.Ordinal);
			_zip64 = Zip64Option.Default;
			_leaveUnderlyingStreamOpen = leaveOpen;
			Strategy = CompressionStrategy.Default;
			_name = name ?? "(stream)";
			ParallelDeflateThreshold = -1L;
		}

		public override string ToString()
		{
			return $"ZipOutputStream::{_name}(leaveOpen({_leaveUnderlyingStreamOpen})))";
		}

		private void InsureUniqueEntry(ZipEntry ze1)
		{
			if (_entriesWritten.ContainsKey(ze1.FileName))
			{
				_exceptionPending = true;
				throw new ArgumentException($"The entry '{ze1.FileName}' already exists in the zip archive.");
			}
		}

		public bool ContainsEntry(string name)
		{
			return _entriesWritten.ContainsKey(SharedUtilities.NormalizePathForUseInZipFile(name));
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (_disposed)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("The stream has been closed.");
			}
			if (buffer == null)
			{
				_exceptionPending = true;
				throw new ArgumentNullException("buffer");
			}
			if (_currentEntry == null)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("You must call PutNextEntry() before calling Write().");
			}
			if (_currentEntry.IsDirectory)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("You cannot Write() data for an entry that is a directory.");
			}
			if (_needToWriteEntryHeader)
			{
				_InitiateCurrentEntry(finishing: false);
			}
			if (count != 0)
			{
				_entryOutputStream.Write(buffer, offset, count);
			}
		}

		public ZipEntry PutNextEntry(string entryName)
		{
			if (string.IsNullOrEmpty(entryName))
			{
				throw new ArgumentNullException("entryName");
			}
			if (_disposed)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("The stream has been closed.");
			}
			_FinishCurrentEntry();
			_currentEntry = ZipEntry.CreateForZipOutputStream(entryName);
			_currentEntry._container = new ZipContainer(this);
			_currentEntry._BitField |= 8;
			_currentEntry.SetEntryTimes(DateTime.Now, DateTime.Now, DateTime.Now);
			_currentEntry.CompressionLevel = CompressionLevel;
			_currentEntry.CompressionMethod = CompressionMethod;
			_currentEntry.Password = _password;
			_currentEntry.Encryption = Encryption;
			_currentEntry.AlternateEncoding = AlternateEncoding;
			_currentEntry.AlternateEncodingUsage = AlternateEncodingUsage;
			if (entryName.EndsWith("/"))
			{
				_currentEntry.MarkAsDirectory();
			}
			_currentEntry.EmitTimesInWindowsFormatWhenSaving = (_timestamp & ZipEntryTimestamp.Windows) != 0;
			_currentEntry.EmitTimesInUnixFormatWhenSaving = (_timestamp & ZipEntryTimestamp.Unix) != 0;
			InsureUniqueEntry(_currentEntry);
			_needToWriteEntryHeader = true;
			return _currentEntry;
		}

		private void _InitiateCurrentEntry(bool finishing)
		{
			_entriesWritten.Add(_currentEntry.FileName, _currentEntry);
			_entryCount++;
			if (_entryCount > 65534 && _zip64 == Zip64Option.Default)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("Too many entries. Consider setting ZipOutputStream.EnableZip64.");
			}
			_currentEntry.WriteHeader(_outputStream, finishing ? 99 : 0);
			_currentEntry.StoreRelativeOffset();
			if (!_currentEntry.IsDirectory)
			{
				_currentEntry.WriteSecurityMetadata(_outputStream);
				_currentEntry.PrepOutputStream(_outputStream, (!finishing) ? (-1) : 0, out _outputCounter, out _encryptor, out _deflater, out _entryOutputStream);
			}
			_needToWriteEntryHeader = false;
		}

		private void _FinishCurrentEntry()
		{
			if (_currentEntry != null)
			{
				if (_needToWriteEntryHeader)
				{
					_InitiateCurrentEntry(finishing: true);
				}
				_currentEntry.FinishOutputStream(_outputStream, _outputCounter, _encryptor, _deflater, _entryOutputStream);
				_currentEntry.PostProcessOutput(_outputStream);
				if (_currentEntry.OutputUsedZip64.HasValue)
				{
					_anyEntriesUsedZip64 |= _currentEntry.OutputUsedZip64.Value;
				}
				_outputCounter = null;
				_encryptor = (_deflater = null);
				_entryOutputStream = null;
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (_disposed)
			{
				return;
			}
			if (disposing && !_exceptionPending)
			{
				_FinishCurrentEntry();
				_directoryNeededZip64 = ZipOutput.WriteCentralDirectoryStructure(_outputStream, _entriesWritten.Values, 1u, _zip64, Comment, new ZipContainer(this));
				Stream stream = null;
				if (_outputStream is CountingStream countingStream)
				{
					stream = countingStream.WrappedStream;
					countingStream.Dispose();
				}
				else
				{
					stream = _outputStream;
				}
				if (!_leaveUnderlyingStreamOpen)
				{
					stream.Dispose();
				}
				_outputStream = null;
			}
			_disposed = true;
		}

		public override void Flush()
		{
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			throw new NotSupportedException("Read");
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotSupportedException("Seek");
		}

		public override void SetLength(long value)
		{
			throw new NotSupportedException();
		}
	}
	internal class ZipContainer
	{
		private ZipFile _zf;

		private ZipOutputStream _zos;

		private ZipInputStream _zis;

		public ZipFile ZipFile => _zf;

		public ZipOutputStream ZipOutputStream => _zos;

		public string Name
		{
			get
			{
				if (_zf != null)
				{
					return _zf.Name;
				}
				if (_zis != null)
				{
					throw new NotSupportedException();
				}
				return _zos.Name;
			}
		}

		public string Password
		{
			get
			{
				if (_zf != null)
				{
					return _zf._Password;
				}
				if (_zis != null)
				{
					return _zis._Password;
				}
				return _zos._password;
			}
		}

		public Zip64Option Zip64
		{
			get
			{
				if (_zf != null)
				{
					return _zf._zip64;
				}
				if (_zis != null)
				{
					throw new NotSupportedException();
				}
				return _zos._zip64;
			}
		}

		public int BufferSize
		{
			get
			{
				if (_zf != null)
				{
					return _zf.BufferSize;
				}
				if (_zis != null)
				{
					throw new NotSupportedException();
				}
				return 0;
			}
		}

		public ParallelDeflateOutputStream ParallelDeflater
		{
			get
			{
				if (_zf != null)
				{
					return _zf.ParallelDeflater;
				}
				if (_zis != null)
				{
					return null;
				}
				return _zos.ParallelDeflater;
			}
			set
			{
				if (_zf != null)
				{
					_zf.ParallelDeflater = value;
				}
				else if (_zos != null)
				{
					_zos.ParallelDeflater = value;
				}
			}
		}

		public long ParallelDeflateThreshold
		{
			get
			{
				if (_zf != null)
				{
					return _zf.ParallelDeflateThreshold;
				}
				return _zos.ParallelDeflateThreshold;
			}
		}

		public int ParallelDeflateMaxBufferPairs
		{
			get
			{
				if (_zf != null)
				{
					return _zf.ParallelDeflateMaxBufferPairs;
				}
				return _zos.ParallelDeflateMaxBufferPairs;
			}
		}

		public int CodecBufferSize
		{
			get
			{
				if (_zf != null)
				{
					return _zf.CodecBufferSize;
				}
				if (_zis != null)
				{
					return _zis.CodecBufferSize;
				}
				return _zos.CodecBufferSize;
			}
		}

		public CompressionStrategy Strategy
		{
			get
			{
				if (_zf != null)
				{
					return _zf.Strategy;
				}
				return _zos.Strategy;
			}
		}

		public Zip64Option UseZip64WhenSaving
		{
			get
			{
				if (_zf != null)
				{
					return _zf.UseZip64WhenSaving;
				}
				return _zos.EnableZip64;
			}
		}

		public Encoding AlternateEncoding
		{
			get
			{
				if (_zf != null)
				{
					return _zf.AlternateEncoding;
				}
				if (_zos != null)
				{
					return _zos.AlternateEncoding;
				}
				return null;
			}
		}

		public Encoding DefaultEncoding
		{
			get
			{
				if (_zf != null)
				{
					return ZipFile.DefaultEncoding;
				}
				if (_zos != null)
				{
					return ZipOutputStream.DefaultEncoding;
				}
				return null;
			}
		}

		public ZipOption AlternateEncodingUsage
		{
			get
			{
				if (_zf != null)
				{
					return _zf.AlternateEncodingUsage;
				}
				if (_zos != null)
				{
					return _zos.AlternateEncodingUsage;
				}
				return ZipOption.Default;
			}
		}

		public Stream ReadStream
		{
			get
			{
				if (_zf != null)
				{
					return _zf.ReadStream;
				}
				return _zis.ReadStream;
			}
		}

		public ZipContainer(object o)
		{
			_zf = o as ZipFile;
			_zos = o as ZipOutputStream;
			_zis = o as ZipInputStream;
		}
	}
	public class ZipInputStream : Stream
	{
		private Stream _inputStream;

		private Encoding _provisionalAlternateEncoding;

		private ZipEntry _currentEntry;

		private bool _firstEntry;

		private bool _needSetup;

		private ZipContainer _container;

		private CrcCalculatorStream _crcStream;

		private long _LeftToRead;

		internal string _Password;

		private long _endOfEntry;

		private string _name;

		private bool _leaveUnderlyingStreamOpen;

		private bool _closed;

		private bool _findRequired;

		private bool _exceptionPending;

		public Encoding ProvisionalAlternateEncoding
		{
			get
			{
				return _provisionalAlternateEncoding;
			}
			set
			{
				_provisionalAlternateEncoding = value;
			}
		}

		public int CodecBufferSize { get; set; }

		public string Password
		{
			set
			{
				if (_closed)
				{
					_exceptionPending = true;
					throw new InvalidOperationException("The stream has been closed.");
				}
				_Password = value;
			}
		}

		internal Stream ReadStream => _inputStream;

		public override bool CanRead => true;

		public override bool CanSeek => _inputStream.CanSeek;

		public override bool CanWrite => false;

		public override long Length => _inputStream.Length;

		public override long Position
		{
			get
			{
				return _inputStream.Position;
			}
			set
			{
				Seek(value, SeekOrigin.Begin);
			}
		}

		public ZipInputStream(Stream stream)
			: this(stream, leaveOpen: false)
		{
		}

		public ZipInputStream(string fileName)
		{
			Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
			_Init(stream, leaveOpen: false, fileName);
		}

		public ZipInputStream(Stream stream, bool leaveOpen)
		{
			_Init(stream, leaveOpen, null);
		}

		private void _Init(Stream stream, bool leaveOpen, string name)
		{
			_inputStream = stream;
			if (!_inputStream.CanRead)
			{
				throw new ZipException("The stream must be readable.");
			}
			_container = new ZipContainer(this);
			_provisionalAlternateEncoding = Encoding.GetEncoding("IBM437");
			_leaveUnderlyingStreamOpen = leaveOpen;
			_findRequired = true;
			_name = name ?? "(stream)";
		}

		public override string ToString()
		{
			return $"ZipInputStream::{_name}(leaveOpen({_leaveUnderlyingStreamOpen})))";
		}

		private void SetupStream()
		{
			_crcStream = _currentEntry.InternalOpenReader(_Password);
			_LeftToRead = _crcStream.Length;
			_needSetup = false;
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (_closed)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("The stream has been closed.");
			}
			if (_needSetup)
			{
				SetupStream();
			}
			if (_LeftToRead == 0)
			{
				return 0;
			}
			int count2 = (int)((_LeftToRead > count) ? count : _LeftToRead);
			int num = _crcStream.Read(buffer, offset, count2);
			_LeftToRead -= num;
			if (_LeftToRead == 0)
			{
				int crc = _crcStream.Crc;
				_currentEntry.VerifyCrcAfterExtract(crc);
				_inputStream.Seek(_endOfEntry, SeekOrigin.Begin);
			}
			return num;
		}

		public ZipEntry GetNextEntry()
		{
			if (_findRequired)
			{
				long num = SharedUtilities.FindSignature(_inputStream, 67324752);
				if (num == -1)
				{
					return null;
				}
				_inputStream.Seek(-4L, SeekOrigin.Current);
			}
			else if (_firstEntry)
			{
				_inputStream.Seek(_endOfEntry, SeekOrigin.Begin);
			}
			_currentEntry = ZipEntry.ReadEntry(_container, !_firstEntry);
			_endOfEntry = _inputStream.Position;
			_firstEntry = true;
			_needSetup = true;
			_findRequired = false;
			return _currentEntry;
		}

		protected override void Dispose(bool disposing)
		{
			if (_closed)
			{
				return;
			}
			if (disposing)
			{
				if (_exceptionPending)
				{
					return;
				}
				if (!_leaveUnderlyingStreamOpen)
				{
					_inputStream.Dispose();
				}
			}
			_closed = true;
		}

		public override void Flush()
		{
			throw new NotSupportedException("Flush");
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			throw new NotSupportedException("Write");
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			_findRequired = true;
			return _inputStream.Seek(offset, origin);
		}

		public override void SetLength(long value)
		{
			throw new NotSupportedException();
		}
	}
	internal class ZipSegmentedStream : Stream
	{
		private enum RwMode
		{
			None,
			ReadOnly,
			Write
		}

		private RwMode rwMode;

		private bool _exceptionPending;

		private string _baseName;

		private string _baseDir;

		private string _currentName;

		private string _currentTempName;

		private uint _currentDiskNumber;

		private uint _maxDiskNumber;

		private int _maxSegmentSize;

		private Stream _innerStream;

		public bool ContiguousWrite { get; set; }

		public uint CurrentSegment
		{
			get
			{
				return _currentDiskNumber;
			}
			private set
			{
				_currentDiskNumber = value;
				_currentName = null;
			}
		}

		public string CurrentName
		{
			get
			{
				if (_currentName == null)
				{
					_currentName = _NameForSegment(CurrentSegment);
				}
				return _currentName;
			}
		}

		public string CurrentTempName => _currentTempName;

		public override bool CanRead
		{
			get
			{
				if (rwMode == RwMode.ReadOnly && _innerStream != null)
				{
					return _innerStream.CanRead;
				}
				return false;
			}
		}

		public override bool CanSeek
		{
			get
			{
				if (_innerStream != null)
				{
					return _innerStream.CanSeek;
				}
				return false;
			}
		}

		public override bool CanWrite
		{
			get
			{
				if (rwMode == RwMode.Write && _innerStream != null)
				{
					return _innerStream.CanWrite;
				}
				return false;
			}
		}

		public override long Length => _innerStream.Length;

		public override long Position
		{
			get
			{
				return _innerStream.Position;
			}
			set
			{
				_innerStream.Position = value;
			}
		}

		private ZipSegmentedStream()
		{
			_exceptionPending = false;
		}

		public static ZipSegmentedStream ForReading(string name, uint initialDiskNumber, uint maxDiskNumber)
		{
			ZipSegmentedStream zipSegmentedStream = new ZipSegmentedStream();
			zipSegmentedStream.rwMode = RwMode.ReadOnly;
			zipSegmentedStream.CurrentSegment = initialDiskNumber;
			zipSegmentedStream._maxDiskNumber = maxDiskNumber;
			zipSegmentedStream._baseName = name;
			ZipSegmentedStream zipSegmentedStream2 = zipSegmentedStream;
			zipSegmentedStream2._SetReadStream();
			return zipSegmentedStream2;
		}

		public static ZipSegmentedStream ForWriting(string name, int maxSegmentSize)
		{
			ZipSegmentedStream zipSegmentedStream = new ZipSegmentedStream();
			zipSegmentedStream.rwMode = RwMode.Write;
			zipSegmentedStream.CurrentSegment = 0u;
			zipSegmentedStream._baseName = name;
			zipSegmentedStream._maxSegmentSize = maxSegmentSize;
			zipSegmentedStream._baseDir = Path.GetDirectoryName(name);
			ZipSegmentedStream zipSegmentedStream2 = zipSegmentedStream;
			if (zipSegmentedStream2._baseDir == "")
			{
				zipSegmentedStream2._baseDir = ".";
			}
			zipSegmentedStream2._SetWriteStream(0u);
			return zipSegmentedStream2;
		}

		public static Stream ForUpdate(string name, uint diskNumber)
		{
			if (diskNumber >= 99)
			{
				throw new ArgumentOutOfRangeException("diskNumber");
			}
			string path = $"{Path.Combine(Path.GetDirectoryName(name), Path.GetFileNameWithoutExtension(name))}.z{diskNumber + 1:D2}";
			return File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
		}

		private string _NameForSegment(uint diskNumber)
		{
			if (diskNumber >= 99)
			{
				_exceptionPending = true;
				throw new OverflowException("The number of zip segments would exceed 99.");
			}
			return $"{Path.Combine(Path.GetDirectoryName(_baseName), Path.GetFileNameWithoutExtension(_baseName))}.z{diskNumber + 1:D2}";
		}

		public uint ComputeSegment(int length)
		{
			if (_innerStream.Position + length > _maxSegmentSize)
			{
				return CurrentSegment + 1;
			}
			return CurrentSegment;
		}

		public override string ToString()
		{
			return string.Format("{0}[{1}][{2}], pos=0x{3:X})", "ZipSegmentedStream", CurrentName, rwMode.ToString(), Position);
		}

		private void _SetReadStream()
		{
			if (_innerStream != null)
			{
				_innerStream.Dispose();
			}
			if (CurrentSegment + 1 == _maxDiskNumber)
			{
				_currentName = _baseName;
			}
			_innerStream = File.OpenRead(CurrentName);
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (rwMode != RwMode.ReadOnly)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("Stream Error: Cannot Read.");
			}
			int num = _innerStream.Read(buffer, offset, count);
			int num2 = num;
			while (num2 != count)
			{
				if (_innerStream.Position != _innerStream.Length)
				{
					_exceptionPending = true;
					throw new ZipException($"Read error in file {CurrentName}");
				}
				if (CurrentSegment + 1 == _maxDiskNumber)
				{
					return num;
				}
				CurrentSegment++;
				_SetReadStream();
				offset += num2;
				count -= num2;
				num2 = _innerStream.Read(buffer, offset, count);
				num += num2;
			}
			return num;
		}

		private void _SetWriteStream(uint increment)
		{
			if (_innerStream != null)
			{
				_innerStream.Dispose();
				if (File.Exists(CurrentName))
				{
					File.Delete(CurrentName);
				}
				File.Move(_currentTempName, CurrentName);
			}
			if (increment != 0)
			{
				CurrentSegment += increment;
			}
			SharedUtilities.CreateAndOpenUniqueTempFile(_baseDir, out _innerStream, out _currentTempName);
			if (CurrentSegment == 0)
			{
				_innerStream.Write(BitConverter.GetBytes(134695760), 0, 4);
			}
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (rwMode != RwMode.Write)
			{
				_exceptionPending = true;
				throw new InvalidOperationException("Stream Error: Cannot Write.");
			}
			if (ContiguousWrite)
			{
				if (_innerStream.Position + count > _maxSegmentSize)
				{
					_SetWriteStream(1u);
				}
			}
			else
			{
				while (_innerStream.Position + count > _maxSegmentSize)
				{
					int num = _maxSegmentSize - (int)_innerStream.Position;
					_innerStream.Write(buffer, offset, num);
					_SetWriteStream(1u);
					count -= num;
					offset += num;
				}
			}
			_innerStream.Write(buffer, offset, count);
		}

		public long TruncateBackward(uint diskNumber, long offset)
		{
			if (diskNumber >= 99)
			{
				throw new ArgumentOutOfRangeException("diskNumber");
			}
			if (rwMode != RwMode.Write)
			{
				_exceptionPending = true;
				throw new ZipException("bad state.");
			}
			if (diskNumber == CurrentSegment)
			{
				return _innerStream.Seek(offset, SeekOrigin.Begin);
			}
			if (_innerStream != null)
			{
				_innerStream.Dispose();
				if (File.Exists(_currentTempName))
				{
					File.Delete(_currentTempName);
				}
			}
			for (uint num = CurrentSegment - 1; num > diskNumber; num--)
			{
				string path = _NameForSegment(num);
				if (File.Exists(path))
				{
					File.Delete(path);
				}
			}
			CurrentSegment = diskNumber;
			for (int i = 0; i < 3; i++)
			{
				try
				{
					_currentTempName = SharedUtilities.InternalGetTempFileName();
					File.Move(CurrentName, _currentTempName);
				}
				catch (IOException)
				{
					if (i == 2)
					{
						throw;
					}
					continue;
				}
				break;
			}
			_innerStream = new FileStream(_currentTempName, FileMode.Open);
			return _innerStream.Seek(offset, SeekOrigin.Begin);
		}

		public override void Flush()
		{
			_innerStream.Flush();
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			return _innerStream.Seek(offset, origin);
		}

		public override void SetLength(long value)
		{
			if (rwMode != RwMode.Write)
			{
				_exceptionPending = true;
				throw new InvalidOperationException();
			}
			_innerStream.SetLength(value);
		}

		protected override void Dispose(bool disposing)
		{
			try
			{
				if (_innerStream != null)
				{
					_innerStream.Dispose();
					if (rwMode == RwMode.Write)
					{
						_ = _exceptionPending;
					}
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
	}
	[ComVisible(true)]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d0000F")]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class ComHelper
	{
		public bool IsZipFile(string filename)
		{
			return ZipFile.IsZipFile(filename);
		}

		public bool IsZipFileWithExtract(string filename)
		{
			return ZipFile.IsZipFile(filename, testExtract: true);
		}

		public bool CheckZip(string filename)
		{
			return ZipFile.CheckZip(filename);
		}

		public bool CheckZipPassword(string filename, string password)
		{
			return ZipFile.CheckZipPassword(filename, password);
		}

		public void FixZipDirectory(string filename)
		{
			ZipFile.FixZipDirectory(filename);
		}

		public string GetZipLibraryVersion()
		{
			return ZipFile.LibraryVersion.ToString();
		}
	}
	internal class OffsetStream : Stream, IDisposable
	{
		private long _originalPosition;

		private Stream _innerStream;

		public override bool CanRead => _innerStream.CanRead;

		public override bool CanSeek => _innerStream.CanSeek;

		public override bool CanWrite => false;

		public override long Length => _innerStream.Length;

		public override long Position
		{
			get
			{
				return _innerStream.Position - _originalPosition;
			}
			set
			{
				_innerStream.Position = _originalPosition + value;
			}
		}

		public OffsetStream(Stream s)
		{
			_originalPosition = s.Position;
			_innerStream = s;
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			return _innerStream.Read(buffer, offset, count);
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			throw new NotImplementedException();
		}

		public override void Flush()
		{
			_innerStream.Flush();
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;
		}

		public override void SetLength(long value)
		{
			throw new NotImplementedException();
		}

		void IDisposable.Dispose()
		{
			Close();
		}

		public override void Close()
		{
			base.Close();
		}
	}
	public enum ZipErrorAction
	{
		Throw,
		Skip,
		Retry,
		InvokeErrorEvent
	}
	public enum EncryptionAlgorithm
	{
		None,
		PkzipWeak,
		WinZipAes128,
		WinZipAes256,
		Unsupported
	}
	public enum ExtractExistingFileAction
	{
		Throw,
		OverwriteSilently,
		DoNotOverwrite,
		InvokeExtractProgressEvent
	}
}
namespace Ionic
{
	internal enum LogicalConjunction
	{
		NONE,
		AND,
		OR,
		XOR
	}
	internal enum WhichTime
	{
		atime,
		mtime,
		ctime
	}
	internal enum ComparisonOperator
	{
		[Description(">")]
		GreaterThan,
		[Description(">=")]
		GreaterThanOrEqualTo,
		[Description("<")]
		LesserThan,
		[Description("<=")]
		LesserThanOrEqualTo,
		[Description("=")]
		EqualTo,
		[Description("!=")]
		NotEqualTo
	}
	internal abstract class SelectionCriterion
	{
		internal virtual bool Verbose { get; set; }

		internal abstract bool Evaluate(string filename);

		[Conditional("SelectorTrace")]
		protected static void CriterionTrace(string format, params object[] args)
		{
		}

		internal abstract bool Evaluate(ZipEntry entry);
	}
	internal class SizeCriterion : SelectionCriterion
	{
		internal ComparisonOperator Operator;

		internal long Size;

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("size ").Append(EnumUtil.GetDescription(Operator)).Append(" ")
				.Append(Size.ToString());
			return stringBuilder.ToString();
		}

		internal override bool Evaluate(string filename)
		{
			FileInfo fileInfo = new FileInfo(filename);
			return _Evaluate(fileInfo.Length);
		}

		private bool _Evaluate(long Length)
		{
			bool flag = false;
			return Operator switch
			{
				ComparisonOperator.GreaterThanOrEqualTo => Length >= Size, 
				ComparisonOperator.GreaterThan => Length > Size, 
				ComparisonOperator.LesserThanOrEqualTo => Length <= Size, 
				ComparisonOperator.LesserThan => Length < Size, 
				ComparisonOperator.EqualTo => Length == Size, 
				ComparisonOperator.NotEqualTo => Length != Size, 
				_ => throw new ArgumentException("Operator"), 
			};
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			return _Evaluate(entry.UncompressedSize);
		}
	}
	internal class TimeCriterion : SelectionCriterion
	{
		internal ComparisonOperator Operator;

		internal WhichTime Which;

		internal DateTime Time;

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(Which.ToString()).Append(" ").Append(EnumUtil.GetDescription(Operator))
				.Append(" ")
				.Append(Time.ToString("yyyy-MM-dd-HH:mm:ss"));
			return stringBuilder.ToString();
		}

		internal override bool Evaluate(string filename)
		{
			return _Evaluate(Which switch
			{
				WhichTime.atime => File.GetLastAccessTime(filename).ToUniversalTime(), 
				WhichTime.mtime => File.GetLastWriteTime(filename).ToUniversalTime(), 
				WhichTime.ctime => File.GetCreationTime(filename).ToUniversalTime(), 
				_ => throw new ArgumentException("Operator"), 
			});
		}

		private bool _Evaluate(DateTime x)
		{
			bool flag = false;
			return Operator switch
			{
				ComparisonOperator.GreaterThanOrEqualTo => x >= Time, 
				ComparisonOperator.GreaterThan => x > Time, 
				ComparisonOperator.LesserThanOrEqualTo => x <= Time, 
				ComparisonOperator.LesserThan => x < Time, 
				ComparisonOperator.EqualTo => x == Time, 
				ComparisonOperator.NotEqualTo => x != Time, 
				_ => throw new ArgumentException("Operator"), 
			};
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			return _Evaluate(Which switch
			{
				WhichTime.atime => entry.AccessedTime, 
				WhichTime.mtime => entry.ModifiedTime, 
				WhichTime.ctime => entry.CreationTime, 
				_ => throw new ArgumentException("??time"), 
			});
		}
	}
	internal class NameCriterion : SelectionCriterion
	{
		private Regex _re;

		private string _regexString;

		internal ComparisonOperator Operator;

		private string _MatchingFileSpec;

		internal virtual string MatchingFileSpec
		{
			set
			{
				if (Directory.Exists(value))
				{
					_MatchingFileSpec = ".\\" + value + "\\*.*";
				}
				else
				{
					_MatchingFileSpec = value;
				}
				_regexString = "^" + Regex.Escape(_MatchingFileSpec).Replace("\\\\\\*\\.\\*", "\\\\([^\\.]+|.*\\.[^\\\\\\.]*)").Replace("\\.\\*", "\\.[^\\\\\\.]*")
					.Replace("\\*", ".*")
					.Replace("\\?", "[^\\\\\\.]") + "$";
				_re = new Regex(_regexString, RegexOptions.IgnoreCase);
			}
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("name ").Append(EnumUtil.GetDescription(Operator)).Append(" '")
				.Append(_MatchingFileSpec)
				.Append("'");
			return stringBuilder.ToString();
		}

		internal override bool Evaluate(string filename)
		{
			return _Evaluate(filename);
		}

		private bool _Evaluate(string fullpath)
		{
			string input = ((_MatchingFileSpec.IndexOf('\\') == -1) ? Path.GetFileName(fullpath) : fullpath);
			bool flag = _re.IsMatch(input);
			if (Operator != ComparisonOperator.EqualTo)
			{
				flag = !flag;
			}
			return flag;
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			string fullpath = entry.FileName.Replace("/", "\\");
			return _Evaluate(fullpath);
		}
	}
	internal class TypeCriterion : SelectionCriterion
	{
		private char ObjectType;

		internal ComparisonOperator Operator;

		internal string AttributeString
		{
			get
			{
				return ObjectType.ToString();
			}
			set
			{
				if (value.Length != 1 || (value[0] != 'D' && value[0] != 'F'))
				{
					throw new ArgumentException("Specify a single character: either D or F");
				}
				ObjectType = value[0];
			}
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("type ").Append(EnumUtil.GetDescription(Operator)).Append(" ")
				.Append(AttributeString);
			return stringBuilder.ToString();
		}

		internal override bool Evaluate(string filename)
		{
			bool flag = ((ObjectType == 'D') ? Directory.Exists(filename) : File.Exists(filename));
			if (Operator != ComparisonOperator.EqualTo)
			{
				flag = !flag;
			}
			return flag;
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			bool flag = ((ObjectType == 'D') ? entry.IsDirectory : (!entry.IsDirectory));
			if (Operator != ComparisonOperator.EqualTo)
			{
				flag = !flag;
			}
			return flag;
		}
	}
	internal class AttributesCriterion : SelectionCriterion
	{
		private FileAttributes _Attributes;

		internal ComparisonOperator Operator;

		internal string AttributeString
		{
			get
			{
				string text = "";
				if ((_Attributes & FileAttributes.Hidden) != 0)
				{
					text += "H";
				}
				if ((_Attributes & FileAttributes.System) != 0)
				{
					text += "S";
				}
				if ((_Attributes & FileAttributes.ReadOnly) != 0)
				{
					text += "R";
				}
				if ((_Attributes & FileAttributes.Archive) != 0)
				{
					text += "A";
				}
				if ((_Attributes & FileAttributes.ReparsePoint) != 0)
				{
					text += "L";
				}
				if ((_Attributes & FileAttributes.NotContentIndexed) != 0)
				{
					text += "I";
				}
				return text;
			}
			set
			{
				_Attributes = FileAttributes.Normal;
				string text = value.ToUpper();
				foreach (char c in text)
				{
					switch (c)
					{
					case 'H':
						if ((_Attributes & FileAttributes.Hidden) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.Hidden;
						break;
					case 'R':
						if ((_Attributes & FileAttributes.ReadOnly) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.ReadOnly;
						break;
					case 'S':
						if ((_Attributes & FileAttributes.System) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.System;
						break;
					case 'A':
						if ((_Attributes & FileAttributes.Archive) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.Archive;
						break;
					case 'I':
						if ((_Attributes & FileAttributes.NotContentIndexed) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.NotContentIndexed;
						break;
					case 'L':
						if ((_Attributes & FileAttributes.ReparsePoint) != 0)
						{
							throw new ArgumentException($"Repeated flag. ({c})", "value");
						}
						_Attributes |= FileAttributes.ReparsePoint;
						break;
					default:
						throw new ArgumentException(value);
					}
				}
			}
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("attributes ").Append(EnumUtil.GetDescription(Operator)).Append(" ")
				.Append(AttributeString);
			return stringBuilder.ToString();
		}

		private bool _EvaluateOne(FileAttributes fileAttrs, FileAttributes criterionAttrs)
		{
			bool flag = false;
			if ((_Attributes & criterionAttrs) == criterionAttrs)
			{
				return (fileAttrs & criterionAttrs) == criterionAttrs;
			}
			return true;
		}

		internal override bool Evaluate(string filename)
		{
			if (Directory.Exists(filename))
			{
				return Operator != ComparisonOperator.EqualTo;
			}
			FileAttributes attributes = File.GetAttributes(filename);
			return _Evaluate(attributes);
		}

		private bool _Evaluate(FileAttributes fileAttrs)
		{
			bool flag = _EvaluateOne(fileAttrs, FileAttributes.Hidden);
			if (flag)
			{
				flag = _EvaluateOne(fileAttrs, FileAttributes.System);
			}
			if (flag)
			{
				flag = _EvaluateOne(fileAttrs, FileAttributes.ReadOnly);
			}
			if (flag)
			{
				flag = _EvaluateOne(fileAttrs, FileAttributes.Archive);
			}
			if (flag)
			{
				flag = _EvaluateOne(fileAttrs, FileAttributes.NotContentIndexed);
			}
			if (flag)
			{
				flag = _EvaluateOne(fileAttrs, FileAttributes.ReparsePoint);
			}
			if (Operator != ComparisonOperator.EqualTo)
			{
				flag = !flag;
			}
			return flag;
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			FileAttributes attributes = entry.Attributes;
			return _Evaluate(attributes);
		}
	}
	internal class CompoundCriterion : SelectionCriterion
	{
		internal LogicalConjunction Conjunction;

		internal SelectionCriterion Left;

		private SelectionCriterion _Right;

		internal SelectionCriterion Right
		{
			get
			{
				return _Right;
			}
			set
			{
				_Right = value;
				if (value == null)
				{
					Conjunction = LogicalConjunction.NONE;
				}
				else if (Conjunction == LogicalConjunction.NONE)
				{
					Conjunction = LogicalConjunction.AND;
				}
			}
		}

		internal override bool Evaluate(string filename)
		{
			bool flag = Left.Evaluate(filename);
			switch (Conjunction)
			{
			case LogicalConjunction.AND:
				if (flag)
				{
					flag = Right.Evaluate(filename);
				}
				break;
			case LogicalConjunction.OR:
				if (!flag)
				{
					flag = Right.Evaluate(filename);
				}
				break;
			case LogicalConjunction.XOR:
				flag ^= Right.Evaluate(filename);
				break;
			default:
				throw new ArgumentException("Conjunction");
			}
			return flag;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("(").Append((Left != null) ? Left.ToString() : "null").Append(" ")
				.Append(Conjunction.ToString())
				.Append(" ")
				.Append((Right != null) ? Right.ToString() : "null")
				.Append(")");
			return stringBuilder.ToString();
		}

		internal override bool Evaluate(ZipEntry entry)
		{
			bool flag = Left.Evaluate(entry);
			switch (Conjunction)
			{
			case LogicalConjunction.AND:
				if (flag)
				{
					flag = Right.Evaluate(entry);
				}
				break;
			case LogicalConjunction.OR:
				if (!flag)
				{
					flag = Right.Evaluate(entry);
				}
				break;
			case LogicalConjunction.XOR:
				flag ^= Right.Evaluate(entry);
				break;
			}
			return flag;
		}
	}
	public class FileSelector
	{
		private enum ParseState
		{
			Start,
			OpenParen,
			CriterionDone,
			ConjunctionPending,
			Whitespace
		}

		private static class RegexAssertions
		{
			public static readonly string PrecededByOddNumberOfSingleQuotes = "(?<=(?:[^']*'[^']*')*'[^']*)";

			public static readonly string FollowedByOddNumberOfSingleQuotesAndLineEnd = "(?=[^']*'(?:[^']*'[^']*')*[^']*$)";

			public static readonly string PrecededByEvenNumberOfSingleQuotes = "(?<=(?:[^']*'[^']*')*[^']*)";

			public static readonly string FollowedByEvenNumberOfSingleQuotesAndLineEnd = "(?=(?:[^']*'[^']*')*[^']*$)";
		}

		internal SelectionCriterion _Criterion;

		public string SelectionCriteria
		{
			get
			{
				if (_Criterion == null)
				{
					return null;
				}
				return _Criterion.ToString();
			}
			set
			{
				if (value == null)
				{
					_Criterion = null;
				}
				else if (value.Trim() == "")
				{
					_Criterion = null;
				}
				else
				{
					_Criterion = _ParseCriterion(value);
				}
			}
		}

		public bool TraverseReparsePoints { get; set; }

		public FileSelector(string selectionCriteria)
			: this(selectionCriteria, traverseDirectoryReparsePoints: true)
		{
		}

		public FileSelector(string selectionCriteria, bool traverseDirectoryReparsePoints)
		{
			if (!string.IsNullOrEmpty(selectionCriteria))
			{
				_Criterion = _ParseCriterion(selectionCriteria);
			}
			TraverseReparsePoints = traverseDirectoryReparsePoints;
		}

		private static string NormalizeCriteriaExpression(string source)
		{
			string[][] array = new string[11][]
			{
				new string[2] { "([^']*)\\(\\(([^']+)", "$1( ($2" },
				new string[2] { "(.)\\)\\)", "$1) )" },
				new string[2] { "\\((\\S)", "( $1" },
				new string[2] { "(\\S)\\)", "$1 )" },
				new string[2] { "^\\)", " )" },
				new string[2] { "(\\S)\\(", "$1 (" },
				new string[2] { "\\)(\\S)", ") $1" },
				new string[2] { "(=)('[^']*')", "$1 $2" },
				new string[2] { "([^ !><])(>|<|!=|=)", "$1 $2" },
				new string[2] { "(>|<|!=|=)([^ =])", "$1 $2" },
				new string[2] { "/", "\\" }
			};
			string input = source;
			for (int i = 0; i < array.Length; i++)
			{
				string pattern = RegexAssertions.PrecededByEvenNumberOfSingleQuotes + array[i][0] + RegexAssertions.FollowedByEvenNumberOfSingleQuotesAndLineEnd;
				input = Regex.Replace(input, pattern, array[i][1]);
			}
			string pattern2 = "/" + RegexAssertions.FollowedByOddNumberOfSingleQuotesAndLineEnd;
			input = Regex.Replace(input, pattern2, "\\");
			pattern2 = " " + RegexAssertions.FollowedByOddNumberOfSingleQuotesAndLineEnd;
			return Regex.Replace(input, pattern2, "\u0006");
		}

		private static SelectionCriterion _ParseCriterion(string s)
		{
			if (s == null)
			{
				return null;
			}
			s = NormalizeCriteriaExpression(s);
			if (s.IndexOf(" ") == -1)
			{
				s = "name = " + s;
			}
			string[] array = s.Trim().Split(' ', '\t');
			if (array.Length < 3)
			{
				throw new ArgumentException(s);
			}
			SelectionCriterion selectionCriterion = null;
			LogicalConjunction logicalConjunction = LogicalConjunction.NONE;
			Stack<ParseState> stack = new Stack<ParseState>();
			Stack<SelectionCriterion> stack2 = new Stack<SelectionCriterion>();
			stack.Push(ParseState.Start);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].ToLower();
				ParseState parseState;
				switch (text)
				{
				case "and":
				case "xor":
				case "or":
				{
					parseState = stack.Peek();
					if (parseState != ParseState.CriterionDone)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					if (array.Length <= i + 3)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					logicalConjunction = (LogicalConjunction)Enum.Parse(typeof(LogicalConjunction), array[i].ToUpper(), ignoreCase: true);
					CompoundCriterion compoundCriterion = new CompoundCriterion();
					compoundCriterion.Left = selectionCriterion;
					compoundCriterion.Right = null;
					compoundCriterion.Conjunction = logicalConjunction;
					selectionCriterion = compoundCriterion;
					stack.Push(parseState);
					stack.Push(ParseState.ConjunctionPending);
					stack2.Push(selectionCriterion);
					break;
				}
				case "(":
					parseState = stack.Peek();
					if (parseState != 0 && parseState != ParseState.ConjunctionPending && parseState != ParseState.OpenParen)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					if (array.Length <= i + 4)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					stack.Push(ParseState.OpenParen);
					break;
				case ")":
					parseState = stack.Pop();
					if (stack.Peek() != ParseState.OpenParen)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					stack.Pop();
					stack.Push(ParseState.CriterionDone);
					break;
				case "atime":
				case "ctime":
				case "mtime":
				{
					if (array.Length <= i + 2)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					DateTime value;
					try
					{
						value = DateTime.ParseExact(array[i + 2], "yyyy-MM-dd-HH:mm:ss", null);
					}
					catch (FormatException)
					{
						try
						{
							value = DateTime.ParseExact(array[i + 2], "yyyy/MM/dd-HH:mm:ss", null);
						}
						catch (FormatException)
						{
							try
							{
								value = DateTime.ParseExact(array[i + 2], "yyyy/MM/dd", null);
								goto end_IL_035d;
							}
							catch (FormatException)
							{
								try
								{
									value = DateTime.ParseExact(array[i + 2], "MM/dd/yyyy", null);
									goto end_IL_035d;
								}
								catch (FormatException)
								{
									value = DateTime.ParseExact(array[i + 2], "yyyy-MM-dd", null);
									goto end_IL_035d;
								}
							}
							end_IL_035d:;
						}
					}
					value = DateTime.SpecifyKind(value, DateTimeKind.Local).ToUniversalTime();
					TimeCriterion timeCriterion = new TimeCriterion();
					timeCriterion.Which = (WhichTime)Enum.Parse(typeof(WhichTime), array[i], ignoreCase: true);
					timeCriterion.Operator = (ComparisonOperator)EnumUtil.Parse(typeof(ComparisonOperator), array[i + 1]);
					timeCriterion.Time = value;
					selectionCriterion = timeCriterion;
					i += 2;
					stack.Push(ParseState.CriterionDone);
					break;
				}
				case "length":
				case "size":
				{
					if (array.Length <= i + 2)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					long num = 0L;
					string text2 = array[i + 2];
					num = (text2.ToUpper().EndsWith("K") ? (long.Parse(text2.Substring(0, text2.Length - 1)) * 1024) : (text2.ToUpper().EndsWith("KB") ? (long.Parse(text2.Substring(0, text2.Length - 2)) * 1024) : (text2.ToUpper().EndsWith("M") ? (long.Parse(text2.Substring(0, text2.Length - 1)) * 1024 * 1024) : (text2.ToUpper().EndsWith("MB") ? (long.Parse(text2.Substring(0, text2.Length - 2)) * 1024 * 1024) : (text2.ToUpper().EndsWith("G") ? (long.Parse(text2.Substring(0, text2.Length - 1)) * 1024 * 1024 * 1024) : ((!text2.ToUpper().EndsWith("GB")) ? long.Parse(array[i + 2]) : (long.Parse(text2.Substring(0, text2.Length - 2)) * 1024 * 1024 * 1024)))))));
					SizeCriterion sizeCriterion = new SizeCriterion();
					sizeCriterion.Size = num;
					sizeCriterion.Operator = (ComparisonOperator)EnumUtil.Parse(typeof(ComparisonOperator), array[i + 1]);
					selectionCriterion = sizeCriterion;
					i += 2;
					stack.Push(ParseState.CriterionDone);
					break;
				}
				case "filename":
				case "name":
				{
					if (array.Length <= i + 2)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					ComparisonOperator comparisonOperator2 = (ComparisonOperator)EnumUtil.Parse(typeof(ComparisonOperator), array[i + 1]);
					if (comparisonOperator2 != ComparisonOperator.NotEqualTo && comparisonOperator2 != ComparisonOperator.EqualTo)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					string text3 = array[i + 2];
					if (text3.StartsWith("'") && text3.EndsWith("'"))
					{
						text3 = text3.Substring(1, text3.Length - 2).Replace("\u0006", " ");
					}
					NameCriterion nameCriterion = new NameCriterion();
					nameCriterion.MatchingFileSpec = text3;
					nameCriterion.Operator = comparisonOperator2;
					selectionCriterion = nameCriterion;
					i += 2;
					stack.Push(ParseState.CriterionDone);
					break;
				}
				case "attrs":
				case "attributes":
				case "type":
				{
					if (array.Length <= i + 2)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					ComparisonOperator comparisonOperator = (ComparisonOperator)EnumUtil.Parse(typeof(ComparisonOperator), array[i + 1]);
					if (comparisonOperator != ComparisonOperator.NotEqualTo && comparisonOperator != ComparisonOperator.EqualTo)
					{
						throw new ArgumentException(string.Join(" ", array, i, array.Length - i));
					}
					object obj;
					if (!(text == "type"))
					{
						AttributesCriterion attributesCriterion = new AttributesCriterion();
						attributesCriterion.AttributeString = array[i + 2];
						attributesCriterion.Operator = comparisonOperator;
						obj = attributesCriterion;
					}
					else
					{
						TypeCriterion typeCriterion = new TypeCriterion();
						typeCriterion.AttributeString = array[i + 2];
						typeCriterion.Operator = comparisonOperator;
						obj = typeCriterion;
					}
					selectionCriterion = (SelectionCriterion)obj;
					i += 2;
					stack.Push(ParseState.CriterionDone);
					break;
				}
				case "":
					stack.Push(ParseState.Whitespace);
					break;
				default:
					throw new ArgumentException("'" + array[i] + "'");
				}
				parseState = stack.Peek();
				if (parseState == ParseState.CriterionDone)
				{
					stack.Pop();
					if (stack.Peek() == ParseState.ConjunctionPending)
					{
						while (stack.Peek() == ParseState.ConjunctionPending)
						{
							CompoundCriterion compoundCriterion2 = stack2.Pop() as CompoundCriterion;
							compoundCriterion2.Right = selectionCriterion;
							selectionCriterion = compoundCriterion2;
							stack.Pop();
							parseState = stack.Pop();
							if (parseState != ParseState.CriterionDone)
							{
								throw new ArgumentException("??");
							}
						}
					}
					else
					{
						stack.Push(ParseState.CriterionDone);
					}
				}
				if (parseState == ParseState.Whitespace)
				{
					stack.Pop();
				}
			}
			return selectionCriterion;
		}

		public override string ToString()
		{
			return "FileSelector(" + _Criterion.ToString() + ")";
		}

		private bool Evaluate(string filename)
		{
			return _Criterion.Evaluate(filename);
		}

		[Conditional("SelectorTrace")]
		private void SelectorTrace(string format, params object[] args)
		{
			if (_Criterion != null && _Criterion.Verbose)
			{
				Console.WriteLine(format, args);
			}
		}

		public ICollection<string> SelectFiles(string directory)
		{
			return SelectFiles(directory, recurseDirectories: false);
		}

		public ReadOnlyCollection<string> SelectFiles(string directory, bool recurseDirectories)
		{
			if (_Criterion == null)
			{
				throw new ArgumentException("SelectionCriteria has not been set");
			}
			List<string> list = new List<string>();
			try
			{
				if (Directory.Exists(directory))
				{
					string[] files = Directory.GetFiles(directory);
					string[] array = files;
					foreach (string text in array)
					{
						if (Evaluate(text))
						{
							list.Add(text);
						}
					}
					if (recurseDirectories)
					{
						string[] directories = Directory.GetDirectories(directory);
						string[] array2 = directories;
						foreach (string text2 in array2)
						{
							if (TraverseReparsePoints || (File.GetAttributes(text2) & FileAttributes.ReparsePoint) == 0)
							{
								if (Evaluate(text2))
								{
									list.Add(text2);
								}
								list.AddRange(SelectFiles(text2, recurseDirectories));
							}
						}
					}
				}
			}
			catch (UnauthorizedAccessException)
			{
			}
			catch (IOException)
			{
			}
			return list.AsReadOnly();
		}

		private bool Evaluate(ZipEntry entry)
		{
			return _Criterion.Evaluate(entry);
		}

		public ICollection<ZipEntry> SelectEntries(ZipFile zip)
		{
			if (zip == null)
			{
				throw new ArgumentNullException("zip");
			}
			List<ZipEntry> list = new List<ZipEntry>();
			foreach (ZipEntry item in zip)
			{
				if (Evaluate(item))
				{
					list.Add(item);
				}
			}
			return list;
		}

		public ICollection<ZipEntry> SelectEntries(ZipFile zip, string directoryPathInArchive)
		{
			if (zip == null)
			{
				throw new ArgumentNullException("zip");
			}
			List<ZipEntry> list = new List<ZipEntry>();
			string text = directoryPathInArchive?.Replace("/", "\\");
			if (text != null)
			{
				while (text.EndsWith("\\"))
				{
					text = text.Substring(0, text.Length - 1);
				}
			}
			foreach (ZipEntry item in zip)
			{
				if ((directoryPathInArchive == null || Path.GetDirectoryName(item.FileName) == directoryPathInArchive || Path.GetDirectoryName(item.FileName) == text) && Evaluate(item))
				{
					list.Add(item);
				}
			}
			return list;
		}
	}
	internal sealed class EnumUtil
	{
		private EnumUtil()
		{
		}

		internal static string GetDescription(Enum value)
		{
			FieldInfo field = value.GetType().GetField(value.ToString());
			DescriptionAttribute[] array = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false);
			if (array.Length > 0)
			{
				return array[0].Description;
			}
			return value.ToString();
		}

		internal static object Parse(Type enumType, string stringRepresentation)
		{
			return Parse(enumType, stringRepresentation, ignoreCase: false);
		}

		internal static object Parse(Type enumType, string stringRepresentation, bool ignoreCase)
		{
			if (ignoreCase)
			{
				stringRepresentation = stringRepresentation.ToLower();
			}
			foreach (Enum value in Enum.GetValues(enumType))
			{
				string text = GetDescription(value);
				if (ignoreCase)
				{
					text = text.ToLower();
				}
				if (text == stringRepresentation)
				{
					return value;
				}
			}
			return Enum.Parse(enumType, stringRepresentation, ignoreCase);
		}
	}
}
namespace Ionic.Zip
{
	internal class WinZipAesCrypto
	{
		internal byte[] _Salt;

		internal byte[] _providedPv;

		internal byte[] _generatedPv;

		internal int _KeyStrengthInBits;

		private byte[] _MacInitializationVector;

		private byte[] _StoredMac;

		private byte[] _keyBytes;

		private short PasswordVerificationStored;

		private short PasswordVerificationGenerated;

		private int Rfc2898KeygenIterations = 1000;

		private string _Password;

		private bool _cryptoGenerated;

		public byte[] CalculatedMac;

		public byte[] GeneratedPV
		{
			get
			{
				if (!_cryptoGenerated)
				{
					_GenerateCryptoBytes();
				}
				return _generatedPv;
			}
		}

		public byte[] Salt => _Salt;

		private int _KeyStrengthInBytes => _KeyStrengthInBits / 8;

		public int SizeOfEncryptionMetadata => _KeyStrengthInBytes / 2 + 10 + 2;

		public string Password
		{
			private get
			{
				return _Password;
			}
			set
			{
				_Password = value;
				if (_Password != null)
				{
					PasswordVerificationGenerated = (short)(GeneratedPV[0] + GeneratedPV[1] * 256);
					if (PasswordVerificationGenerated != PasswordVerificationStored)
					{
						throw new BadPasswordException();
					}
				}
			}
		}

		public byte[] KeyBytes
		{
			get
			{
				if (!_cryptoGenerated)
				{
					_GenerateCryptoBytes();
				}
				return _keyBytes;
			}
		}

		public byte[] MacIv
		{
			get
			{
				if (!_cryptoGenerated)
				{
					_GenerateCryptoBytes();
				}
				return _MacInitializationVector;
			}
		}

		private WinZipAesCrypto(string password, int KeyStrengthInBits)
		{
			_Password = password;
			_KeyStrengthInBits = KeyStrengthInBits;
		}

		public static WinZipAesCrypto Generate(string password, int KeyStrengthInBits)
		{
			WinZipAesCrypto winZipAesCrypto = new WinZipAesCrypto(password, KeyStrengthInBits);
			int num = winZipAesCrypto._KeyStrengthInBytes / 2;
			winZipAesCrypto._Salt = new byte[num];
			Random random = new Random();
			random.NextBytes(winZipAesCrypto._Salt);
			return winZipAesCrypto;
		}

		public static WinZipAesCrypto ReadFromStream(string password, int KeyStrengthInBits, Stream s)
		{
			WinZipAesCrypto winZipAesCrypto = new WinZipAesCrypto(password, KeyStrengthInBits);
			int num = winZipAesCrypto._KeyStrengthInBytes / 2;
			winZipAesCrypto._Salt = new byte[num];
			winZipAesCrypto._providedPv = new byte[2];
			s.Read(winZipAesCrypto._Salt, 0, winZipAesCrypto._Salt.Length);
			s.Read(winZipAesCrypto._providedPv, 0, winZipAesCrypto._providedPv.Length);
			winZipAesCrypto.PasswordVerificationStored = (short)(winZipAesCrypto._providedPv[0] + winZipAesCrypto._providedPv[1] * 256);
			if (password != null)
			{
				winZipAesCrypto.PasswordVerificationGenerated = (short)(winZipAesCrypto.GeneratedPV[0] + winZipAesCrypto.GeneratedPV[1] * 256);
				if (winZipAesCrypto.PasswordVerificationGenerated != winZipAesCrypto.PasswordVerificationStored)
				{
					throw new BadPasswordException("bad password");
				}
			}
			return winZipAesCrypto;
		}

		private void _GenerateCryptoBytes()
		{
			Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(_Password, Salt, Rfc2898KeygenIterations);
			_keyBytes = rfc2898DeriveBytes.GetBytes(_KeyStrengthInBytes);
			_MacInitializationVector = rfc2898DeriveBytes.GetBytes(_KeyStrengthInBytes);
			_generatedPv = rfc2898DeriveBytes.GetBytes(2);
			_cryptoGenerated = true;
		}

		public void ReadAndVerifyMac(Stream s)
		{
			bool flag = false;
			_StoredMac = new byte[10];
			s.Read(_StoredMac, 0, _StoredMac.Length);
			if (_StoredMac.Length != CalculatedMac.Length)
			{
				flag = true;
			}
			if (!flag)
			{
				for (int i = 0; i < _StoredMac.Length; i++)
				{
					if (_StoredMac[i] != CalculatedMac[i])
					{
						flag = true;
					}
				}
			}
			if (flag)
			{
				throw new BadStateException("The MAC does not match.");
			}
		}
	}
	internal class WinZipAesCipherStream : Stream
	{
		private const int BLOCK_SIZE_IN_BYTES = 16;

		private WinZipAesCrypto _params;

		private Stream _s;

		private CryptoMode _mode;

		private int _nonce;

		private bool _finalBlock;

		internal HMACSHA1 _mac;

		internal RijndaelManaged _aesCipher;

		internal ICryptoTransform _xform;

		private byte[] counter = new byte[16];

		private byte[] counterOut = new byte[16];

		private long _length;

		private long _totalBytesXferred;

		private byte[] _PendingWriteBlock;

		private int _pendingCount;

		private byte[] _iobuf;

		private object _outputLock = new object();

		public byte[] FinalAuthentication
		{
			get
			{
				if (!_finalBlock)
				{
					if (_totalBytesXferred != 0)
					{
						throw new BadStateException("The final hash has not been computed.");
					}
					byte[] buffer = new byte[0];
					_mac.ComputeHash(buffer);
				}
				byte[] array = new byte[10];
				Array.Copy(_mac.Hash, 0, array, 0, 10);
				return array;
			}
		}

		public override bool CanRead
		{
			get
			{
				if (_mode != CryptoMode.Decrypt)
				{
					return false;
				}
				return true;
			}
		}

		public override bool CanSeek => false;

		public override bool CanWrite => _mode == CryptoMode.Encrypt;

		public override long Length
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public override long Position
		{
			get
			{
				throw new NotImplementedException();
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		internal WinZipAesCipherStream(Stream s, WinZipAesCrypto cryptoParams, long length, CryptoMode mode)
			: this(s, cryptoParams, mode)
		{
			_length = length;
		}

		internal WinZipAesCipherStream(Stream s, WinZipAesCrypto cryptoParams, CryptoMode mode)
		{
			_params = cryptoParams;
			_s = s;
			_mode = mode;
			_nonce = 1;
			if (_params == null)
			{
				throw new BadPasswordException("Supply a password to use AES encryption.");
			}
			int num = _params.KeyBytes.Length * 8;
			if (num != 256 && num != 128 && num != 192)
			{
				throw new ArgumentOutOfRangeException("keysize", "size of key must be 128, 192, or 256");
			}
			_mac = new HMACSHA1(_params.MacIv);
			_aesCipher = new RijndaelManaged();
			_aesCipher.BlockSize = 128;
			_aesCipher.KeySize = num;
			_aesCipher.Mode = CipherMode.ECB;
			_aesCipher.Padding = PaddingMode.None;
			byte[] rgbIV = new byte[16];
			_xform = _aesCipher.CreateEncryptor(_params.KeyBytes, rgbIV);
			if (_mode == CryptoMode.Encrypt)
			{
				_iobuf = new byte[2048];
				_PendingWriteBlock = new byte[16];
			}
		}

		private void XorInPlace(byte[] buffer, int offset, int count)
		{
			for (int i = 0; i < count; i++)
			{
				buffer[offset + i] = (byte)(counterOut[i] ^ buffer[offset + i]);
			}
		}

		private void WriteTransformOneBlock(byte[] buffer, int offset)
		{
			Array.Copy(BitConverter.GetBytes(_nonce++), 0, counter, 0, 4);
			_xform.TransformBlock(counter, 0, 16, counterOut, 0);
			XorInPlace(buffer, offset, 16);
			_mac.TransformBlock(buffer, offset, 16, null, 0);
		}

		private void WriteTransformBlocks(byte[] buffer, int offset, int count)
		{
			int i = offset;
			for (int num = count + offset; i < buffer.Length && i < num; i += 16)
			{
				WriteTransformOneBlock(buffer, i);
			}
		}

		private void WriteTransformFinalBlock()
		{
			if (_pendingCount == 0)
			{
				throw new InvalidOperationException("No bytes available.");
			}
			if (_finalBlock)
			{
				throw new InvalidOperationException("The final block has already been transformed.");
			}
			Array.Copy(BitConverter.GetBytes(_nonce++), 0, counter, 0, 4);
			counterOut = _xform.TransformFinalBlock(counter, 0, 16);
			XorInPlace(_PendingWriteBlock, 0, _pendingCount);
			_mac.TransformFinalBlock(_PendingWriteBlock, 0, _pendingCount);
			_finalBlock = true;
		}

		private int ReadTransformOneBlock(byte[] buffer, int offset, int last)
		{
			if (_finalBlock)
			{
				throw new NotSupportedException();
			}
			int num = last - offset;
			int num2 = ((num > 16) ? 16 : num);
			Array.Copy(BitConverter.GetBytes(_nonce++), 0, counter, 0, 4);
			if (num2 == num && _length > 0 && _totalBytesXferred + last == _length)
			{
				_mac.TransformFinalBlock(buffer, offset, num2);
				counterOut = _xform.TransformFinalBlock(counter, 0, 16);
				_finalBlock = true;
			}
			else
			{
				_mac.TransformBlock(buffer, offset, num2, null, 0);
				_xform.TransformBlock(counter, 0, 16, counterOut, 0);
			}
			XorInPlace(buffer, offset, num2);
			return num2;
		}

		private void ReadTransformBlocks(byte[] buffer, int offset, int count)
		{
			int i = offset;
			int num2;
			for (int num = count + offset; i < buffer.Length && i < num; i += num2)
			{
				num2 = ReadTransformOneBlock(buffer, i, num);
			}
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (_mode == CryptoMode.Encrypt)
			{
				throw new NotSupportedException();
			}
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (offset < 0)
			{
				throw new ArgumentOutOfRangeException("offset", "Must not be less than zero.");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count", "Must not be less than zero.");
			}
			if (buffer.Length < offset + count)
			{
				throw new ArgumentException("The buffer is too small");
			}
			int count2 = count;
			if (_totalBytesXferred >= _length)
			{
				return 0;
			}
			long num = _length - _totalBytesXferred;
			if (num < count)
			{
				count2 = (int)num;
			}
			int num2 = _s.Read(buffer, offset, count2);
			ReadTransformBlocks(buffer, offset, count2);
			_totalBytesXferred += num2;
			return num2;
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (_finalBlock)
			{
				throw new InvalidOperationException("The final block has already been transformed.");
			}
			if (_mode == CryptoMode.Decrypt)
			{
				throw new NotSupportedException();
			}
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (offset < 0)
			{
				throw new ArgumentOutOfRangeException("offset", "Must not be less than zero.");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count", "Must not be less than zero.");
			}
			if (buffer.Length < offset + count)
			{
				throw new ArgumentException("The offset and count are too large");
			}
			if (count == 0)
			{
				return;
			}
			if (count + _pendingCount <= 16)
			{
				Buffer.BlockCopy(buffer, offset, _PendingWriteBlock, _pendingCount, count);
				_pendingCount += count;
				return;
			}
			int num = count;
			int num2 = offset;
			if (_pendingCount != 0)
			{
				int num3 = 16 - _pendingCount;
				if (num3 > 0)
				{
					Buffer.BlockCopy(buffer, offset, _PendingWriteBlock, _pendingCount, num3);
					num -= num3;
					num2 += num3;
				}
				WriteTransformOneBlock(_PendingWriteBlock, 0);
				_s.Write(_PendingWriteBlock, 0, 16);
				_totalBytesXferred += 16L;
				_pendingCount = 0;
			}
			int num4 = (num - 1) / 16;
			_pendingCount = num - num4 * 16;
			Buffer.BlockCopy(buffer, num2 + num - _pendingCount, _PendingWriteBlock, 0, _pendingCount);
			num -= _pendingCount;
			_totalBytesXferred += num;
			if (num4 <= 0)
			{
				return;
			}
			do
			{
				int num5 = _iobuf.Length;
				if (num5 > num)
				{
					num5 = num;
				}
				Buffer.BlockCopy(buffer, num2, _iobuf, 0, num5);
				WriteTransformBlocks(_iobuf, 0, num5);
				_s.Write(_iobuf, 0, num5);
				num -= num5;
				num2 += num5;
			}
			while (num > 0);
		}

		public override void Close()
		{
			if (_pendingCount > 0)
			{
				WriteTransformFinalBlock();
				_s.Write(_PendingWriteBlock, 0, _pendingCount);
				_totalBytesXferred += _pendingCount;
				_pendingCount = 0;
			}
			_s.Close();
		}

		public override void Flush()
		{
			_s.Flush();
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotImplementedException();
		}

		public override void SetLength(long value)
		{
			throw new NotImplementedException();
		}

		[Conditional("Trace")]
		private void TraceOutput(string format, params object[] varParams)
		{
			lock (_outputLock)
			{
				int hashCode = Thread.CurrentThread.GetHashCode();
				Console.ForegroundColor = (ConsoleColor)(hashCode % 8 + 8);
				Console.Write("{0:000} WZACS ", hashCode);
				Console.WriteLine(format, varParams);
				Console.ResetColor();
			}
		}
	}
	internal static class ZipConstants
	{
		public const uint PackedToRemovableMedia = 808471376u;

		public const uint Zip64EndOfCentralDirectoryRecordSignature = 101075792u;

		public const uint Zip64EndOfCentralDirectoryLocatorSignature = 117853008u;

		public const uint EndOfCentralDirectorySignature = 101010256u;

		public const int ZipEntrySignature = 67324752;

		public const int ZipEntryDataDescriptorSignature = 134695760;

		public const int SplitArchiveSignature = 134695760;

		public const int ZipDirEntrySignature = 33639248;

		public const int AesKeySize = 192;

		public const int AesBlockSize = 128;

		public const ushort AesAlgId128 = 26126;

		public const ushort AesAlgId192 = 26127;

		public const ushort AesAlgId256 = 26128;
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d00006")]
	public class ZipException : Exception
	{
		public ZipException()
		{
		}

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

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

		protected ZipException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d0000B")]
	public class BadPasswordException : ZipException
	{
		public BadPasswordException()
		{
		}

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

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

		protected BadPasswordException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d0000A")]
	public class BadReadException : ZipException
	{
		public BadReadException()
		{
		}

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

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

		protected BadReadException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d00009")]
	public class BadCrcException : ZipException
	{
		public BadCrcException()
		{
		}

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

		protected BadCrcException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d00008")]
	public class SfxGenerationException : ZipException
	{
		public SfxGenerationException()
		{
		}

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

		protected SfxGenerationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	[Serializable]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d00007")]
	public class BadStateException : ZipException
	{
		public BadStateException()
		{
		}

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

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

		protected BadStateException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal static class SharedUtilities
	{
		private static Regex doubleDotRegex1 = new Regex("^(.*/)?([^/\\\\.]+/\\\\.\\\\./)(.+)$");

		private static Encoding ibm437 = Encoding.GetEncoding("IBM437");

		private static Encoding utf8 = Encoding.GetEncoding("UTF-8");

		public static long GetFileLength(string fileName)
		{
			if (!File.Exists(fileName))
			{
				throw new FileNotFoundException(fileName);
			}
			long num = 0L;
			FileShare fileShare = FileShare.ReadWrite;
			fileShare |= FileShare.Delete;
			using FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, fileShare);
			return fileStream.Length;
		}

		[Conditional("NETCF")]
		public static void Workaround_Ladybug318918(Stream s)
		{
			s.Flush();
		}

		private static string SimplifyFwdSlashPath(string path)
		{
			if (path.StartsWith("./"))
			{
				path = path.Substring(2);
			}
			path = path.Replace("/./", "/");
			path = doubleDotRegex1.Replace(path, "$1$3");
			return path;
		}

		public static string NormalizePathForUseInZipFile(string pathName)
		{
			if (string.IsNullOrEmpty(pathName))
			{
				return pathName;
			}
			if (pathName.Length >= 2 && pathName[1] == ':' && pathName[2] == '\\')
			{
				pathName = pathName.Substring(3);
			}
			pathName = pathName.Replace('\\', '/');
			while (pathName.StartsWith("/"))
			{
				pathName = pathName.Substring(1);
			}
			return SimplifyFwdSlashPath(pathName);
		}

		internal static byte[] StringToByteArray(string value, Encoding encoding)
		{
			return encoding.GetBytes(value);
		}

		internal static byte[] StringToByteArray(string value)
		{
			return StringToByteArray(value, ibm437);
		}

		internal static string Utf8StringFromBuffer(byte[] buf)
		{
			return StringFromBuffer(buf, utf8);
		}

		internal static string StringFromBuffer(byte[] buf, Encoding encoding)
		{
			return encoding.GetString(buf, 0, buf.Length);
		}

		internal static int ReadSignature(Stream s)
		{
			int result = 0;
			try
			{
				result = _ReadFourBytes(s, "n/a");
			}
			catch (BadReadException)
			{
			}
			return result;
		}

		internal static int ReadEntrySignature(Stream s)
		{
			int num = 0;
			try
			{
				num = _ReadFourBytes(s, "n/a");
				if (num == 134695760)
				{
					s.Seek(12L, SeekOrigin.Current);
					num = _ReadFourBytes(s, "n/a");
					if (num != 67324752)
					{
						s.Seek(8L, SeekOrigin.Current);
						num = _ReadFourBytes(s, "n/a");
						if (num != 67324752)
						{
							s.Seek(-24L, SeekOrigin.Current);
							num = _ReadFourBytes(s, "n/a");
						}
					}
				}
			}
			catch (BadReadException)
			{
			}
			return num;
		}

		internal static int ReadInt(Stream s)
		{
			return _ReadFourBytes(s, "Could not read block - no data!  (position 0x{0:X8})");
		}

		private static int _ReadFourBytes(Stream s, string message)
		{
			int num = 0;
			byte[] array = new byte[4];
			num = s.Read(array, 0, array.Length);
			if (num != array.Length)
			{
				throw new BadReadException(string.Format(message, s.Position));
			}
			return ((array[3] * 256 + array[2]) * 256 + array[1]) * 256 + array[0];
		}

		internal static long FindSignature(Stream stream, int SignatureToFind)
		{
			long position = stream.Position;
			int num = 65536;
			byte[] array = new byte[4]
			{
				(byte)(SignatureToFind >> 24),
				(byte)((SignatureToFind & 0xFF0000) >> 16),
				(byte)((SignatureToFind & 0xFF00) >> 8),
				(byte)((uint)SignatureToFind & 0xFFu)
			};
			byte[] array2 = new byte[num];
			int num2 = 0;
			bool flag = false;
			do
			{
				num2 = stream.Read(array2, 0, array2.Length);
				if (num2 == 0)
				{
					break;
				}
				for (int i = 0; i < num2; i++)
				{
					if (array2[i] == array[3])
					{
						long position2 = stream.Position;
						stream.Seek(i - num2, SeekOrigin.Current);
						int num3 = ReadSignature(stream);
						flag = num3 == SignatureToFind;
						if (flag)
						{
							break;
						}
						stream.Seek(position2, SeekOrigin.Begin);
					}
				}
			}
			while (!flag);
			if (!flag)
			{
				stream.Seek(position, SeekOrigin.Begin);
				return -1L;
			}
			return stream.Position - position - 4;
		}

		internal static DateTime AdjustTime_Reverse(DateTime time)
		{
			if (time.Kind == DateTimeKind.Utc)
			{
				return time;
			}
			DateTime result = time;
			if (DateTime.Now.IsDaylightSavingTime() && !time.IsDaylightSavingTime())
			{
				result = time - new TimeSpan(1, 0, 0);
			}
			else if (!DateTime.Now.IsDaylightSavingTime() && time.IsDaylightSavingTime())
			{
				result = time + new TimeSpan(1, 0, 0);
			}
			return result;
		}

		internal static DateTime PackedToDateTime(int packedDateTime)
		{
			if (packedDateTime == 65535 || packedDateTime == 0)
			{
				return new DateTime(1995, 1, 1, 0, 0, 0, 0);
			}
			short num = (short)(packedDateTime & 0xFFFF);
			short num2 = (short)((packedDateTime & 0xFFFF0000u) >> 16);
			int i = 1980 + ((num2 & 0xFE00) >> 9);
			int j = (num2 & 0x1E0) >> 5;
			int k = num2 & 0x1F;
			int num3 = (num & 0xF800) >> 11;
			int l = (num & 0x7E0) >> 5;
			int m = (num & 0x1F) * 2;
			if (m >= 60)
			{
				l++;
				m = 0;
			}
			if (l >= 60)
			{
				num3++;
				l = 0;
			}
			if (num3 >= 24)
			{
				k++;
				num3 = 0;
			}
			DateTime value = DateTime.Now;
			bool flag = false;
			try
			{
				value = new DateTime(i, j, k, num3, l, m, 0);
				flag = true;
			}
			catch (ArgumentOutOfRangeException)
			{
				if (i == 1980 && (j == 0 || k == 0))
				{
					try
					{
						value = new DateTime(1980, 1, 1, num3, l, m, 0);
						flag = true;
					}
					catch (ArgumentOutOfRangeException)
					{
						try
						{
							value = new DateTime(1980, 1, 1, 0, 0, 0, 0);
							flag = true;
							goto end_IL_00f1;
						}
						catch (ArgumentOutOfRangeException)
						{
							goto end_IL_00f1;
						}
						end_IL_00f1:;
					}
				}
				else
				{
					try
					{
						for (; i < 1980; i++)
						{
						}
						while (i > 2030)
						{
							i--;
						}
						for (; j < 1; j++)
						{
						}
						while (j > 12)
						{
							j--;
						}
						for (; k < 1; k++)
						{
						}
						while (k > 28)
						{
							k--;
						}
						for (; l < 0; l++)
						{
						}
						while (l > 59)
						{
							l--;
						}
						for (; m < 0; m++)
						{
						}
						while (m > 59)
						{
							m--;
						}
						value = new DateTime(i, j, k, num3, l, m, 0);
						flag = true;
					}
					catch (ArgumentOutOfRangeException)
					{
					}
				}
			}
			if (!flag)
			{
				string arg = $"y({i}) m({j}) d({k}) h({num3}) m({l}) s({m})";
				throw new ZipException($"Bad date/time format in the zip file. ({arg})");
			}
			return DateTime.SpecifyKind(value, DateTimeKind.Local);
		}

		internal static int DateTimeToPacked(DateTime time)
		{
			time = time.ToLocalTime();
			ushort num = (ushort)(((uint)time.Day & 0x1Fu) | ((uint)(time.Month << 5) & 0x1E0u) | ((uint)(time.Year - 1980 << 9) & 0xFE00u));
			ushort num2 = (ushort)(((uint)(time.Second / 2) & 0x1Fu) | ((uint)(time.Minute << 5) & 0x7E0u) | ((uint)(time.Hour << 11) & 0xF800u));
			return (num << 16) | num2;
		}

		public static void CreateAndOpenUniqueTempFile(string dir, out Stream fs, out string filename)
		{
			for (int i = 0; i < 3; i++)
			{
				try
				{
					filename = Path.Combine(dir, InternalGetTempFileName());
					fs = new FileStream(filename, FileMode.CreateNew);
					return;
				}
				catch (IOException)
				{
					if (i == 2)
					{
						throw;
					}
				}
			}
			throw new IOException();
		}

		public static string InternalGetTempFileName()
		{
			return "DotNetZip-" + Path.GetRandomFileName().Substring(0, 8) + ".tmp";
		}

		internal static int ReadWithRetry(Stream s, byte[] buffer, int offset, int count, string FileName)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			int result = 0;
			bool flag = false;
			int num = 0;
			do
			{
				try
				{
					result = s.Read(buffer, offset, count);
					flag = true;
				}
				catch (IOException ex)
				{
					SecurityPermission val = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
					if (val.IsUnrestricted())
					{
						uint num2 = _HRForException(ex);
						if (num2 != 2147942433u)
						{
							throw new IOException($"Cannot read file {FileName}", ex);
						}
						num++;
						if (num > 10)
						{
							throw new IOException($"Cannot read file {FileName}, at offset 0x{offset:X8} after 10 retries", ex);
						}
						Thread.Sleep(250 + num * 550);
						continue;
					}
					throw;
				}
			}
			while (!flag);
			return result;
		}

		private static uint _HRForException(Exception ex1)
		{
			return (uint)Marshal.GetHRForException(ex1);
		}
	}
	public class CountingStream : Stream
	{
		private Stream _s;

		private long _bytesWritten;

		private long _bytesRead;

		private long _initialOffset;

		public Stream WrappedStream => _s;

		public long BytesWritten => _bytesWritten;

		public long BytesRead => _bytesRead;

		public override bool CanRead => _s.CanRead;

		public override bool CanSeek => _s.CanSeek;

		public override bool CanWrite => _s.CanWrite;

		public override long Length => _s.Length;

		public long ComputedPosition => _initialOffset + _bytesWritten;

		public override long Position
		{
			get
			{
				return _s.Position;
			}
			set
			{
				_s.Seek(value, SeekOrigin.Begin);
			}
		}

		public CountingStream(Stream stream)
		{
			_s = stream;
			try
			{
				_initialOffset = _s.Position;
			}
			catch
			{
				_initialOffset = 0L;
			}
		}

		public void Adjust(long delta)
		{
			_bytesWritten -= delta;
			if (_bytesWritten < 0)
			{
				throw new InvalidOperationException();
			}
			if (_s is CountingStream)
			{
				((CountingStream)_s).Adjust(delta);
			}
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			int num = _s.Read(buffer, offset, count);
			_bytesRead += num;
			return num;
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (count != 0)
			{
				_s.Write(buffer, offset, count);
				_bytesWritten += count;
			}
		}

		public override void Flush()
		{
			_s.Flush();
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			return _s.Seek(offset, origin);
		}

		public override void SetLength(long value)
		{
			_s.SetLength(value);
		}
	}
	internal class ZipCrypto
	{
		private uint[] _Keys = new uint[3] { 305419896u, 591751049u, 878082192u };

		private CRC32 crc32 = new CRC32();

		private byte MagicByte
		{
			get
			{
				ushort num = (ushort)((ushort)(_Keys[2] & 0xFFFFu) | 2u);
				return (byte)(num * (num ^ 1) >> 8);
			}
		}

		private ZipCrypto()
		{
		}

		public static ZipCrypto ForWrite(string password)
		{
			ZipCrypto zipCrypto = new ZipCrypto();
			if (password == null)
			{
				throw new BadPasswordException("This entry requires a password.");
			}
			zipCrypto.InitCipher(password);
			return zipCrypto;
		}

		public static ZipCrypto ForRead(string password, ZipEntry e)
		{
			Stream archiveStream = e._archiveStream;
			e._WeakEncryptionHeader = new byte[12];
			byte[] weakEncryptionHeader = e._WeakEncryptionHeader;
			ZipCrypto zipCrypto = new ZipCrypto();
			if (password == null)
			{
				throw new BadPasswordException("This entry requires a password.");
			}
			zipCrypto.InitCipher(password);
			ZipEntry.ReadWeakEncryptionHeader(archiveStream, weakEncryptionHeader);
			byte[] array = zipCrypto.DecryptMessage(weakEncryptionHeader, weakEncryptionHeader.Length);
			if (array[11] != (byte)((e._Crc32 >> 24) & 0xFF))
			{
				if ((e._BitField & 8) != 8)
				{
					throw new BadPasswordException("The password did not match.");
				}
				if (array[11] != (byte)((e._TimeBlob >> 8) & 0xFF))
				{
					throw new BadPasswordException("The password did not match.");
				}
			}
			return zipCrypto;
		}

		public byte[] DecryptMessage(byte[] cipherText, int length)
		{
			if (cipherText == null)
			{
				throw new ArgumentNullException("cipherText");
			}
			if (length > cipherText.Length)
			{
				throw new ArgumentOutOfRangeException("length", "Bad length during Decryption: the length parameter must be smaller than or equal to the size of the destination array.");
			}
			byte[] array = new byte[length];
			for (int i = 0; i < length; i++)
			{
				byte b = (byte)(cipherText[i] ^ MagicByte);
				UpdateKeys(b);
				array[i] = b;
			}
			return array;
		}

		public byte[] EncryptMessage(byte[] plainText, int length)
		{
			if (plainText == null)
			{
				throw new ArgumentNullException("plaintext");
			}
			if (length > plainText.Length)
			{
				throw new ArgumentOutOfRangeException("length", "Bad length during Encryption: The length parameter must be smaller than or equal to the size of the destination array.");
			}
			byte[] array = new byte[length];
			for (int i = 0; i < length; i++)
			{
				byte byteValue = plainText[i];
				array[i] = (byte)(plainText[i] ^ MagicByte);
				UpdateKeys(byteValue);
			}
			return array;
		}

		public void InitCipher(string passphrase)
		{
			byte[] array = SharedUtilities.StringToByteArray(passphrase);
			for (int i = 0; i < passphrase.Length; i++)
			{
				UpdateKeys(array[i]);
			}
		}

		private void UpdateKeys(byte byteValue)
		{
			_Keys[0] = (uint)crc32.ComputeCrc32((int)_Keys[0], byteValue);
			_Keys[1] = _Keys[1] + (byte)_Keys[0];
			_Keys[1] = _Keys[1] * 134775813 + 1;
			_Keys[2] = (uint)crc32.ComputeCrc32((int)_Keys[2], (byte)(_Keys[1] >> 24));
		}
	}
	internal enum CryptoMode
	{
		Encrypt,
		Decrypt
	}
	internal class ZipCipherStream : Stream
	{
		private ZipCrypto _cipher;

		private Stream _s;

		private CryptoMode _mode;

		public override bool CanRead => _mode == CryptoMode.Decrypt;

		public override bool CanSeek => false;

		public override bool CanWrite => _mode == CryptoMode.Encrypt;

		public override long Length
		{
			get
			{
				throw new NotSupportedException();
			}
		}

		public override long Position
		{
			get
			{
				throw new NotSupportedException();
			}
			set
			{
				throw new NotSupportedException();
			}
		}

		public ZipCipherStream(Stream s, ZipCrypto cipher, CryptoMode mode)
		{
			_cipher = cipher;
			_s = s;
			_mode = mode;
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			if (_mode == CryptoMode.Encrypt)
			{
				throw new NotSupportedException("This stream does not encrypt via Read()");
			}
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			byte[] array = new byte[count];
			int num = _s.Read(array, 0, count);
			byte[] array2 = _cipher.DecryptMessage(array, num);
			for (int i = 0; i < num; i++)
			{
				buffer[offset + i] = array2[i];
			}
			return num;
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			if (_mode == CryptoMode.Decrypt)
			{
				throw new NotSupportedException("This stream does not Decrypt via Write()");
			}
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (count == 0)
			{
				return;
			}
			byte[] array = null;
			if (offset != 0)
			{
				array = new byte[count];
				for (int i = 0; i < count; i++)
				{
					array[i] = buffer[offset + i];
				}
			}
			else
			{
				array = buffer;
			}
			byte[] array2 = _cipher.EncryptMessage(array, count);
			_s.Write(array2, 0, array2.Length);
		}

		public override void Flush()
		{
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotSupportedException();
		}

		public override void SetLength(long value)
		{
			throw new NotSupportedException();
		}
	}
	public delegate void WriteDelegate(string entryName, Stream stream);
	public delegate Stream OpenDelegate(string entryName);
	public delegate void CloseDelegate(string entryName, Stream stream);
	public delegate CompressionLevel SetCompressionCallback(string localFileName, string fileNameInArchive);
	public enum ZipProgressEventType
	{
		Adding_Started,
		Adding_AfterAddEntry,
		Adding_Completed,
		Reading_Started,
		Reading_BeforeReadEntry,
		Reading_AfterReadEntry,
		Reading_Completed,
		Reading_ArchiveBytesRead,
		Saving_Started,
		Saving_BeforeWriteEntry,
		Saving_AfterWriteEntry,
		Saving_Completed,
		Saving_AfterSaveTempArchive,
		Saving_BeforeRenameTempArchive,
		Saving_AfterRenameTempArchive,
		Saving_AfterCompileSelfExtractor,
		Saving_EntryBytesRead,
		Extracting_BeforeExtractEntry,
		Extracting_AfterExtractEntry,
		Extracting_ExtractEntryWouldOverwrite,
		Extracting_EntryBytesWritten,
		Extracting_BeforeExtractAll,
		Extracting_AfterExtractAll,
		Error_Saving
	}
	public class ZipProgressEventArgs : EventArgs
	{
		private int _entriesTotal;

		private bool _cancel;

		private ZipEntry _latestEntry;

		private ZipProgressEventType _flavor;

		private string _archiveName;

		private long _bytesTransferred;

		private long _totalBytesToTransfer;

		public int EntriesTotal
		{
			get
			{
				return _entriesTotal;
			}
			set
			{
				_entriesTotal = value;
			}
		}

		public ZipEntry CurrentEntry
		{
			get
			{
				return _latestEntry;
			}
			set
			{
				_latestEntry = value;
			}
		}

		public bool Cancel
		{
			get
			{
				return _cancel;
			}
			set
			{
				_cancel = _cancel || value;
			}
		}

		public ZipProgressEventType EventType
		{
			get
			{
				return _flavor;
			}
			set
			{
				_flavor = value;
			}
		}

		public string ArchiveName
		{
			get
			{
				return _archiveName;
			}
			set
			{
				_archiveName = value;
			}
		}

		public long BytesTransferred
		{
			get
			{
				return _bytesTransferred;
			}
			set
			{
				_bytesTransferred = value;
			}
		}

		public long TotalBytesToTransfer
		{
			get
			{
				return _totalBytesToTransfer;
			}
			set
			{
				_totalBytesToTransfer = value;
			}
		}

		internal ZipProgressEventArgs()
		{
		}

		internal ZipProgressEventArgs(string archiveName, ZipProgressEventType flavor)
		{
			_archiveName = archiveName;
			_flavor = flavor;
		}
	}
	public class ReadProgressEventArgs : ZipProgressEventArgs
	{
		internal ReadProgressEventArgs()
		{
		}

		private ReadProgressEventArgs(string archiveName, ZipProgressEventType flavor)
			: base(archiveName, flavor)
		{
		}

		internal static ReadProgressEventArgs Before(string archiveName, int entriesTotal)
		{
			ReadProgressEventArgs readProgressEventArgs = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_BeforeReadEntry);
			readProgressEventArgs.EntriesTotal = entriesTotal;
			return readProgressEventArgs;
		}

		internal static ReadProgressEventArgs After(string archiveName, ZipEntry entry, int entriesTotal)
		{
			ReadProgressEventArgs readProgressEventArgs = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_AfterReadEntry);
			readProgressEventArgs.EntriesTotal = entriesTotal;
			readProgressEventArgs.CurrentEntry = entry;
			return readProgressEventArgs;
		}

		internal static ReadProgressEventArgs Started(string archiveName)
		{
			return new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_Started);
		}

		internal static ReadProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, long bytesXferred, long totalBytes)
		{
			ReadProgressEventArgs readProgressEventArgs = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_ArchiveBytesRead);
			readProgressEventArgs.CurrentEntry = entry;
			readProgressEventArgs.BytesTransferred = bytesXferred;
			readProgressEventArgs.TotalBytesToTransfer = totalBytes;
			return readProgressEventArgs;
		}

		internal static ReadProgressEventArgs Completed(string archiveName)
		{
			return new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_Completed);
		}
	}
	public class AddProgressEventArgs : ZipProgressEventArgs
	{
		internal AddProgressEventArgs()
		{
		}

		private AddProgressEventArgs(string archiveName, ZipProgressEventType flavor)
			: base(archiveName, flavor)
		{
		}

		internal static AddProgressEventArgs AfterEntry(string archiveName, ZipEntry entry, int entriesTotal)
		{
			AddProgressEventArgs addProgressEventArgs = new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_AfterAddEntry);
			addProgressEventArgs.EntriesTotal = entriesTotal;
			addProgressEventArgs.CurrentEntry = entry;
			return addProgressEventArgs;
		}

		internal static AddProgressEventArgs Started(string archiveName)
		{
			return new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_Started);
		}

		internal static AddProgressEventArgs Completed(string archiveName)
		{
			return new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_Completed);
		}
	}
	public class SaveProgressEventArgs : ZipProgressEventArgs
	{
		private int _entriesSaved;

		public int EntriesSaved => _entriesSaved;

		internal SaveProgressEventArgs(string archiveName, bool before, int entriesTotal, int entriesSaved, ZipEntry entry)
			: base(archiveName, before ? ZipProgressEventType.Saving_BeforeWriteEntry : ZipProgressEventType.Saving_AfterWriteEntry)
		{
			base.EntriesTotal = entriesTotal;
			base.CurrentEntry = entry;
			_entriesSaved = entriesSaved;
		}

		internal SaveProgressEventArgs()
		{
		}

		internal SaveProgressEventArgs(string archiveName, ZipProgressEventType flavor)
			: base(archiveName, flavor)
		{
		}

		internal static SaveProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, long bytesXferred, long totalBytes)
		{
			SaveProgressEventArgs saveProgressEventArgs = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_EntryBytesRead);
			saveProgressEventArgs.ArchiveName = archiveName;
			saveProgressEventArgs.CurrentEntry = entry;
			saveProgressEventArgs.BytesTransferred = bytesXferred;
			saveProgressEventArgs.TotalBytesToTransfer = totalBytes;
			return saveProgressEventArgs;
		}

		internal static SaveProgressEventArgs Started(string archiveName)
		{
			return new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Started);
		}

		internal static SaveProgressEventArgs Completed(string archiveName)
		{
			return new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Completed);
		}
	}
	public class ExtractProgressEventArgs : ZipProgressEventArgs
	{
		private int _entriesExtracted;

		private string _target;

		public int EntriesExtracted => _entriesExtracted;

		public string ExtractLocation => _target;

		internal ExtractProgressEventArgs(string archiveName, bool before, int entriesTotal, int entriesExtracted, ZipEntry entry, string extractLocation)
			: base(archiveName, before ? ZipProgressEventType.Extracting_BeforeExtractEntry : ZipProgressEventType.Extracting_AfterExtractEntry)
		{
			base.EntriesTotal = entriesTotal;
			base.CurrentEntry = entry;
			_entriesExtracted = entriesExtracted;
			_target = extractLocation;
		}

		internal ExtractProgressEventArgs(string archiveName, ZipProgressEventType flavor)
			: base(archiveName, flavor)
		{
		}

		internal ExtractProgressEventArgs()
		{
		}

		internal static ExtractProgressEventArgs BeforeExtractEntry(string archiveName, ZipEntry entry, string extractLocation)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs();
			extractProgressEventArgs.ArchiveName = archiveName;
			extractProgressEventArgs.EventType = ZipProgressEventType.Extracting_BeforeExtractEntry;
			extractProgressEventArgs.CurrentEntry = entry;
			extractProgressEventArgs._target = extractLocation;
			return extractProgressEventArgs;
		}

		internal static ExtractProgressEventArgs ExtractExisting(string archiveName, ZipEntry entry, string extractLocation)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs();
			extractProgressEventArgs.ArchiveName = archiveName;
			extractProgressEventArgs.EventType = ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite;
			extractProgressEventArgs.CurrentEntry = entry;
			extractProgressEventArgs._target = extractLocation;
			return extractProgressEventArgs;
		}

		internal static ExtractProgressEventArgs AfterExtractEntry(string archiveName, ZipEntry entry, string extractLocation)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs();
			extractProgressEventArgs.ArchiveName = archiveName;
			extractProgressEventArgs.EventType = ZipProgressEventType.Extracting_AfterExtractEntry;
			extractProgressEventArgs.CurrentEntry = entry;
			extractProgressEventArgs._target = extractLocation;
			return extractProgressEventArgs;
		}

		internal static ExtractProgressEventArgs ExtractAllStarted(string archiveName, string extractLocation)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_BeforeExtractAll);
			extractProgressEventArgs._target = extractLocation;
			return extractProgressEventArgs;
		}

		internal static ExtractProgressEventArgs ExtractAllCompleted(string archiveName, string extractLocation)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_AfterExtractAll);
			extractProgressEventArgs._target = extractLocation;
			return extractProgressEventArgs;
		}

		internal static ExtractProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, long bytesWritten, long totalBytes)
		{
			ExtractProgressEventArgs extractProgressEventArgs = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_EntryBytesWritten);
			extractProgressEventArgs.ArchiveName = archiveName;
			extractProgressEventArgs.CurrentEntry = entry;
			extractProgressEventArgs.BytesTransferred = bytesWritten;
			extractProgressEventArgs.TotalBytesToTransfer = totalBytes;
			return extractProgressEventArgs;
		}
	}
	public class ZipErrorEventArgs : ZipProgressEventArgs
	{
		private Exception _exc;

		public Exception Exception => _exc;

		public string FileName => base.CurrentEntry.LocalFileName;

		private ZipErrorEventArgs()
		{
		}

		internal static ZipErrorEventArgs Saving(string archiveName, ZipEntry entry, Exception exception)
		{
			ZipErrorEventArgs zipErrorEventArgs = new ZipErrorEventArgs();
			zipErrorEventArgs.EventType = ZipProgressEventType.Error_Saving;
			zipErrorEventArgs.ArchiveName = archiveName;
			zipErrorEventArgs.CurrentEntry = entry;
			zipErrorEventArgs._exc = exception;
			return zipErrorEventArgs;
		}
	}
	[ComVisible(true)]
	[Guid("ebc25cf6-9120-4283-b972-0e5520d00004")]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class ZipEntry
	{
		private class CopyHelper
		{
			private static Regex re = new Regex(" \\(copy (\\d+)\\)$");

			private static int callCount = 0;

			internal static string AppendCopyToFileName(string f)
			{
				callCount++;
				if (callCount > 25)
				{
					throw new OverflowException("overflow while creating filename");
				}
				int num = 1;
				int num2 = f.LastIndexOf(".");
				if (num2 == -1)
				{
					Match match = re.Match(f);
					if (match.Success)
					{
						num = int.Parse(match.Groups[1].Value) + 1;
						string text = $" (copy {num})";
						f = f.Substring(0, match.Index) + text;
					}
					else
					{
						string text2 = $" (copy {num})";
						f += text2;
					}
				}
				else
				{
					Match match2 = re.Match(f.Substring(0, num2));
					if (match2.Success)
					{
						num = int.Parse(match2.Groups[1].Value) + 1;
						string text3 = $" (copy {num})";
						f = f.Substring(0, match2.Index) + text3 + f.Substring(num2);
					}
					else
					{
						string text4 = $" (copy {num})";
						f = f.Substring(0, num2) + text4 + f.Substring(num2);
					}
				}
				return f;
			}
		}

		private delegate T Func<T>();

		private short _VersionMadeBy;

		private short _InternalFileAttrs;

		private int _ExternalFileAttrs;

		private short _filenameLength;

		private short _extraFieldLength;

		private short _commentLength;

		private ZipCrypto _zipCrypto_forExtract;

		private ZipCrypto _zipCrypto_forWrite;

		private WinZipAesCrypto _aesCrypto_forExtract;

		private WinZipAesCrypto _aesCrypto_forWrite;

		private short _WinZipAesMethod;

		internal DateTime _LastModified;

		private DateTime _Mtime;

		private DateTime _Atime;

		private DateTime _Ctime;

		private bool _ntfsTimesAreSet;

		private bool _emitNtfsTimes = true;

		private bool _emitUnixTimes;

		private bool _TrimVolumeFromFullyQualifiedPaths = true;

		internal string _LocalFileName;

		private string _FileNameInArchive;

		internal short _VersionNeeded;

		internal short _BitField;

		internal short _CompressionMethod;

		private short _CompressionMethod_FromZipFile;

		private CompressionLevel _CompressionLevel;

		internal string _Comment;

		private bool _IsDirectory;

		private byte[] _CommentBytes;

		internal long _CompressedSize;

		internal long _CompressedFileDataSize;

		internal long _UncompressedSize;

		internal int _TimeBlob;

		private bool _crcCalculated;

		internal int _Crc32;

		internal byte[] _Extra;

		private bool _metadataChanged;

		private bool _restreamRequiredOnSave;

		private bool _sourceIsEncrypted;

		private bool _skippedDuringSave;

		private uint _diskNumber;

		private static Encoding ibm437 = Encoding.GetEncoding("IBM437");

		private Encoding _actualEncoding;

		internal ZipContainer _container;

		private long __FileDataPosition = -1L;

		private byte[] _EntryHeader;

		internal long _RelativeOffsetOfLocalHeader;

		private long _future_ROLH;

		private long _TotalEntrySize;

		private int _LengthOfHeader;

		private int _LengthOfTrailer;

		internal bool _InputUsesZip64;

		private uint _UnsupportedAlgorithmId;

		internal string _Password;

		internal ZipEntrySource _Source;

		internal EncryptionAlgorithm _Encryption;

		internal EncryptionAlgorithm _Encryption_FromZipFile;

		internal byte[] _WeakEncryptionHeader;

		internal Stream _archiveStream;

		private Stream _sourceStream;

		private long? _sourceStreamOriginalPosition;

		private bool _sourceWasJitProvided;

		private bool _ioOperationCanceled;

		private bool _presumeZip64;

		private bool? _entryRequiresZip64;

		private bool? _OutputUsesZip64;

		private bool _IsText;

		private ZipEntryTimestamp _timestamp;

		private static DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

		private

plugins/MtGAPI/ModTheGungeonAPI.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Dungeonator;
using ETGGUI;
using FullSerializer;
using FullSerializer.Internal;
using Gungeon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pathfinding;
using SGUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("EtG.ModTheGungeonAPI")]
[assembly: AssemblyDescription("An API for Enter the Gungeon that brings the good parts of MtG (Mod the Gungeon) to BepInEx as a plugin.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ModTheGungeonAPI")]
[assembly: AssemblyProduct("ModTheGungeonAPI")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("74614e13-b452-410a-838d-f0e1fefc0d85")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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;
		}
	}
}
internal class BeamBehaviourTracker : MonoBehaviour
{
	public GunBehaviour gunBehaviour;
}
public static class ETGMod
{
	public static class Assets
	{
		public const string DEFINITION_METADATA_EXTENSION = "jtk2d";

		public const string FULL_DEFINITION_METADATA_EXTENSION = ".jtk2d";

		private static List<tk2dSpriteCollectionData> _spriteCollections;

		private static readonly List<string> processedFolders = new List<string>();

		internal static readonly Dictionary<string, Texture2D> unprocessedSingleTextureReplacements = new Dictionary<string, Texture2D>();

		internal static readonly Dictionary<string, Dictionary<string, Texture2D>> unprocessedReplacements = new Dictionary<string, Dictionary<string, Texture2D>>();

		internal static readonly Dictionary<string, Dictionary<string, AssetSpriteData>> unprocessedJsons = new Dictionary<string, Dictionary<string, AssetSpriteData>>();

		public static Dictionary<string, Texture2D> TextureMap = new Dictionary<string, Texture2D>();

		public static RuntimeAtlasPacker Packer = new RuntimeAtlasPacker(0, 0, (TextureFormat)4);

		public static List<tk2dSpriteCollectionData> Collections => _spriteCollections ?? (_spriteCollections = (from x in Resources.FindObjectsOfTypeAll<tk2dSpriteCollectionData>()
			where (Object)(object)((x != null) ? ((Component)x).gameObject : null) != (Object)null
			select x).ToList());

		public static Vector2[] GenerateUVs(Texture2D texture, int x, int y, int width, int height)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			return (Vector2[])(object)new Vector2[4]
			{
				new Vector2((float)x / (float)((Texture)texture).width, (float)y / (float)((Texture)texture).height),
				new Vector2((float)(x + width) / (float)((Texture)texture).width, (float)y / (float)((Texture)texture).height),
				new Vector2((float)x / (float)((Texture)texture).width, (float)(y + height) / (float)((Texture)texture).height),
				new Vector2((float)(x + width) / (float)((Texture)texture).width, (float)(y + height) / (float)((Texture)texture).height)
			};
		}

		public static void SetupSpritesFromFolder(string folder)
		{
			//IL_0869: Unknown result type (might be due to invalid IL or missing references)
			//IL_086e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Unknown result type (might be due to invalid IL or missing references)
			//IL_0887: Expected O, but got Unknown
			//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_092d: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_0960: Unknown result type (might be due to invalid IL or missing references)
			//IL_0965: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0981: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			//IL_0989: Unknown result type (might be due to invalid IL or missing references)
			//IL_098e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Expected O, but got Unknown
			//IL_0c85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8c: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			if (processedFolders.Contains(folder))
			{
				return;
			}
			if (!Directory.Exists(folder))
			{
				ETGModConsole.Log("Part of the path to " + folder + " is missing!");
				return;
			}
			string[] files = Directory.GetFiles(folder, "*.png");
			foreach (string text in files)
			{
				string trimmed2 = text.Substring(text.LastIndexOf(Path.DirectorySeparatorChar) + 1);
				if (trimmed2.LastIndexOf(".") >= 0)
				{
					trimmed2 = trimmed2.Substring(0, trimmed2.LastIndexOf("."));
				}
				Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
				try
				{
					ImageConversion.LoadImage(val, File.ReadAllBytes(text));
				}
				catch
				{
				}
				((Texture)val).filterMode = (FilterMode)0;
				tk2dSpriteCollectionData val2 = Collections.Find((tk2dSpriteCollectionData x) => x != null && x.spriteCollectionName != null && x.spriteCollectionName.ToLowerInvariant() == trimmed2.ToLowerInvariant());
				if ((Object)(object)val2 == (Object)null || val2.materials == null || val2.materials.Length == 0)
				{
					if ((Object)(object)val2 == (Object)null)
					{
						string key = trimmed2.Replace("_", " ");
						if (!unprocessedSingleTextureReplacements.ContainsKey(key) || (Object)(object)unprocessedSingleTextureReplacements[key] == (Object)null)
						{
							unprocessedSingleTextureReplacements[key] = val;
						}
					}
					continue;
				}
				Material val3 = val2.materials[0];
				if (!Object.op_Implicit((Object)(object)val3))
				{
					continue;
				}
				Texture mainTexture = val3.mainTexture;
				if (!Object.op_Implicit((Object)(object)mainTexture))
				{
					continue;
				}
				string name = ((Object)mainTexture).name;
				if (string.IsNullOrEmpty(name) || name[0] == '~')
				{
					continue;
				}
				Dictionary<int, Texture> dictionary = new Dictionary<int, Texture>();
				if (val2.spriteDefinitions != null)
				{
					for (int j = 0; j < val2.spriteDefinitions.Length; j++)
					{
						tk2dSpriteDefinition val4 = val2.spriteDefinitions[j];
						bool flag = (Object)(object)val4.materialInst != (Object)null;
						Material[] materials = val2.materials;
						foreach (Material val5 in materials)
						{
							if ((Object)(object)val4.materialInst == (Object)null || (Object)(object)val4.materialInst.mainTexture == (Object)(object)val5.mainTexture)
							{
								flag = false;
							}
						}
						if (flag)
						{
							dictionary[j] = val4.materialInst.mainTexture;
						}
					}
				}
				((Object)val).name = "~" + name;
				for (int l = 0; l < val2.materials.Length; l++)
				{
					Material obj2 = val2.materials[l];
					if (!((Object)(object)((obj2 != null) ? obj2.mainTexture : null) == (Object)null))
					{
						val2.materials[l].mainTexture = (Texture)(object)val;
					}
				}
				val2.inst.materialInsts = null;
				val2.inst.Init();
				bool flag2 = (Object)(object)val2.inst != (Object)(object)val2;
				foreach (KeyValuePair<int, Texture> item in dictionary)
				{
					if (item.Key < val2.Count)
					{
						tk2dSpriteDefinition val6 = val2.spriteDefinitions[item.Key];
						if (val6 != null && (Object)(object)val6.materialInst != (Object)null)
						{
							val6.materialInst = new Material(val6.material);
							val6.materialInst.mainTexture = item.Value;
						}
					}
				}
				if (!flag2)
				{
					continue;
				}
				if (val2.inst?.materials != null)
				{
					for (int m = 0; m < val2.inst.materials.Length; m++)
					{
						Material obj3 = val2.inst.materials[m];
						if (!((Object)(object)((obj3 != null) ? obj3.mainTexture : null) == (Object)null))
						{
							val2.inst.materials[m].mainTexture = (Texture)(object)val;
						}
					}
				}
				foreach (KeyValuePair<int, Texture> item2 in dictionary)
				{
					if (item2.Key < val2.inst.Count)
					{
						tk2dSpriteDefinition val7 = val2.inst.spriteDefinitions[item2.Key];
						if (val7 != null && (Object)(object)val7.materialInst != (Object)null)
						{
							val7.materialInst.mainTexture = item2.Value;
						}
					}
				}
			}
			string[] directories = Directory.GetDirectories(folder);
			foreach (string text2 in directories)
			{
				string trimmed = "";
				if (text2.LastIndexOf(Path.DirectorySeparatorChar) + 1 == text2.Length)
				{
					trimmed = text2.Substring(0, trimmed.LastIndexOf(Path.DirectorySeparatorChar));
					if (trimmed.LastIndexOf(Path.DirectorySeparatorChar) != trimmed.Length)
					{
						trimmed = trimmed.Substring(trimmed.LastIndexOf(Path.DirectorySeparatorChar) + 1);
					}
				}
				else
				{
					trimmed = text2.Substring(text2.LastIndexOf(Path.DirectorySeparatorChar) + 1);
				}
				tk2dSpriteCollectionData val8 = Collections.Find((tk2dSpriteCollectionData x) => x != null && x.spriteCollectionName != null && x.spriteCollectionName.ToLowerInvariant() == trimmed.ToLowerInvariant());
				if (val8?.spriteDefinitions != null && val8.Count > 0)
				{
					List<tk2dSpriteDefinition> list = new List<tk2dSpriteDefinition>(val8.spriteDefinitions);
					List<tk2dSpriteDefinition> list2 = new List<tk2dSpriteDefinition>(val8.inst.spriteDefinitions);
					bool flag3 = (Object)(object)val8.inst != (Object)(object)val8;
					IEnumerable<string> enumerable = Directory.GetFiles(text2, "*.json").Concat(Directory.GetFiles(text2, ".jtk2d"));
					foreach (string item3 in enumerable)
					{
						string text3 = item3.Substring(0, item3.LastIndexOf("."));
						string text4 = text3.Substring(text3.LastIndexOf(Path.DirectorySeparatorChar) + 1);
						int spriteIdByName = val8.GetSpriteIdByName(text4, -1);
						if (spriteIdByName < 0)
						{
							continue;
						}
						using FileStream stream = File.OpenRead(item3);
						AssetSpriteData assetSpriteData = default(AssetSpriteData);
						try
						{
							assetSpriteData = JSONHelper.ReadJSON<AssetSpriteData>(stream);
						}
						catch
						{
							ETGModConsole.Log("Error: invalid json at path " + item3);
							goto end_IL_0714;
						}
						val8.SetAttachPoints(spriteIdByName, assetSpriteData.attachPoints);
						if (flag3)
						{
							val8.inst.SetAttachPoints(spriteIdByName, assetSpriteData.attachPoints);
						}
						end_IL_0714:;
					}
					string[] files2 = Directory.GetFiles(text2, "*.png");
					foreach (string text5 in files2)
					{
						string text6 = text5.Substring(0, text5.LastIndexOf("."));
						string text7 = text6.Substring(text6.LastIndexOf(Path.DirectorySeparatorChar) + 1);
						Texture2D val9 = new Texture2D(1, 1, (TextureFormat)4, false);
						try
						{
							ImageConversion.LoadImage(val9, File.ReadAllBytes(text5));
						}
						catch
						{
						}
						int num2 = -1;
						int spriteIdByName2 = val8.GetSpriteIdByName(text7, -1);
						if (spriteIdByName2 >= 0)
						{
							val8.spriteDefinitions[spriteIdByName2].ReplaceTexture(val9, pack: true);
							if (flag3)
							{
								val8.inst.spriteDefinitions[spriteIdByName2].ReplaceTexture(val9, pack: true);
							}
							num2 = spriteIdByName2;
							goto IL_0afb;
						}
						tk2dSpriteDefinition val10 = new tk2dSpriteDefinition
						{
							name = text7,
							material = val8.materials[0]
						};
						val10.ReplaceTexture(val9, pack: true);
						val10.normals = (Vector3[])(object)new Vector3[0];
						val10.tangents = (Vector4[])(object)new Vector4[0];
						val10.indices = new int[6] { 0, 3, 1, 2, 3, 0 };
						float num3 = (float)((Texture)val9).width * 0.0625f;
						float num4 = (float)((Texture)val9).height * 0.0625f;
						val10.position0 = new Vector3(0f, 0f, 0f);
						val10.position1 = new Vector3(num3, 0f, 0f);
						val10.position2 = new Vector3(0f, num4, 0f);
						val10.position3 = new Vector3(num3, num4, 0f);
						val10.boundsDataCenter = (val10.untrimmedBoundsDataCenter = new Vector3(num3 / 2f, num4 / 2f, 0f));
						val10.boundsDataExtents = (val10.untrimmedBoundsDataExtents = new Vector3(num3, num4, 0f));
						num2 = list.Count;
						if (File.Exists(text6 + ".jtk2d"))
						{
							using (FileStream stream2 = File.OpenRead(text6 + ".jtk2d"))
							{
								AssetSpriteData assetSpriteData2 = default(AssetSpriteData);
								try
								{
									assetSpriteData2 = JSONHelper.ReadJSON<AssetSpriteData>(stream2);
								}
								catch
								{
									ETGModConsole.Log("Error: invalid json at path " + text6 + ".jtk2d");
									goto end_IL_09cc;
								}
								val8.SetAttachPoints(num2, assetSpriteData2.attachPoints);
								if (flag3)
								{
									val8.inst.SetAttachPoints(num2, assetSpriteData2.attachPoints);
								}
								goto IL_0ae6;
								end_IL_09cc:;
							}
							continue;
						}
						if (File.Exists(text6 + ".json"))
						{
							using (FileStream stream3 = File.OpenRead(text6 + ".json"))
							{
								AssetSpriteData assetSpriteData3 = default(AssetSpriteData);
								try
								{
									assetSpriteData3 = JSONHelper.ReadJSON<AssetSpriteData>(stream3);
								}
								catch
								{
									ETGModConsole.Log("Error: invalid json at path " + text6 + ".json");
									goto end_IL_0a74;
								}
								val8.SetAttachPoints(num2, assetSpriteData3.attachPoints);
								if (flag3)
								{
									val8.inst.SetAttachPoints(num2, assetSpriteData3.attachPoints);
								}
								goto IL_0ae6;
								end_IL_0a74:;
							}
							continue;
						}
						goto IL_0ae6;
						IL_0afb:
						TextureMap["sprites/" + val8.spriteCollectionName + "/" + text7] = val9;
						continue;
						IL_0ae6:
						list.Add(val10);
						list2.Add(val10);
						goto IL_0afb;
					}
					val8.spriteDefinitions = list.ToArray();
					val8.spriteNameLookupDict = null;
					if (flag3)
					{
						val8.inst.spriteDefinitions = list2.ToArray();
						val8.inst.spriteNameLookupDict = null;
					}
				}
				else
				{
					if (!((Object)(object)val8 == (Object)null))
					{
						continue;
					}
					if (!unprocessedReplacements.TryGetValue(trimmed.Replace("_", " "), out var value))
					{
						value = new Dictionary<string, Texture2D>();
						unprocessedReplacements.Add(trimmed.Replace("_", " "), value);
					}
					if (!unprocessedJsons.TryGetValue(trimmed.Replace("_", " "), out var value2))
					{
						value2 = new Dictionary<string, AssetSpriteData>();
						unprocessedJsons.Add(trimmed.Replace("_", " "), value2);
					}
					string[] files3 = Directory.GetFiles(text2, "*.png");
					foreach (string text8 in files3)
					{
						string text9 = text8.Substring(0, text8.LastIndexOf("."));
						string key2 = text9.Substring(text9.LastIndexOf(Path.DirectorySeparatorChar) + 1);
						Texture2D val11 = new Texture2D(1, 1, (TextureFormat)4, false);
						try
						{
							ImageConversion.LoadImage(val11, File.ReadAllBytes(text8));
						}
						catch
						{
						}
						value[key2] = val11;
					}
					IEnumerable<string> enumerable2 = Directory.GetFiles(text2, "*.json").Concat(Directory.GetFiles(text2, ".jtk2d"));
					foreach (string item4 in enumerable2)
					{
						string text10 = item4.Substring(0, item4.LastIndexOf("."));
						string key3 = text10.Substring(text10.LastIndexOf(Path.DirectorySeparatorChar) + 1);
						using FileStream stream4 = File.OpenRead(item4);
						AssetSpriteData assetSpriteData4 = default(AssetSpriteData);
						try
						{
							assetSpriteData4 = JSONHelper.ReadJSON<AssetSpriteData>(stream4);
						}
						catch
						{
							ETGModConsole.Log("Error: invalid json at path " + item4);
							goto end_IL_0d2d;
						}
						value2[key3] = assetSpriteData4;
						end_IL_0d2d:;
					}
				}
			}
			processedFolders.Add(folder);
		}

		public static void SetupSpritesFromAssembly(Assembly asmb, string path)
		{
			//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b94: Expected O, but got Unknown
			//IL_0c05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_0e61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e68: Expected O, but got Unknown
			//IL_0ac9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Expected O, but got Unknown
			if ((object)asmb == null)
			{
				return;
			}
			path = path.Replace("/", ".").Replace("\\", ".");
			if (!path.EndsWith("."))
			{
				path += ".";
			}
			string text = null;
			tk2dSpriteCollectionData val = null;
			List<tk2dSpriteDefinition> list = null;
			List<tk2dSpriteDefinition> list2 = null;
			List<string> list3 = new List<string>();
			List<string> list4 = new List<string>();
			List<string> list5 = new List<string>();
			string[] manifestResourceNames = asmb.GetManifestResourceNames();
			string[] array = manifestResourceNames;
			foreach (string text2 in array)
			{
				if (!text2.StartsWith(path) || text2.Length <= path.Length)
				{
					continue;
				}
				string[] array2 = text2.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				if (array2.Length == 3)
				{
					string text3 = array2[2];
					if (text3.ToLowerInvariant() == "png")
					{
						list4.Add(text2);
					}
					else if (text3.ToLowerInvariant() == "json" || text3.ToLowerInvariant() == "jtk2d")
					{
						list5.Add(text2);
					}
				}
				else if (array2.Length == 2)
				{
					string text4 = array2[1];
					if (text4.ToLowerInvariant() == "png")
					{
						list3.Add(text2);
					}
				}
			}
			foreach (string item in list3)
			{
				Texture2D val2 = new Texture2D(1, 1, (TextureFormat)4, false);
				using (Stream stream = asmb.GetManifestResourceStream(item))
				{
					try
					{
						byte[] array3 = new byte[stream.Length];
						stream.Read(array3, 0, array3.Length);
						ImageConversion.LoadImage(val2, array3);
					}
					catch
					{
					}
				}
				((Texture)val2).filterMode = (FilterMode)0;
				string[] array4 = item.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				string collection3 = array4[0];
				tk2dSpriteCollectionData val3 = Collections.Find((tk2dSpriteCollectionData x) => x != null && x.spriteCollectionName != null && x.spriteCollectionName.Replace(" ", "_").ToLowerInvariant() == collection3.ToLowerInvariant());
				if ((Object)(object)val3 == (Object)null || val3.materials == null || val3.materials.Length == 0)
				{
					if ((Object)(object)val3 == (Object)null)
					{
						string key = collection3.Replace("_", " ");
						if (!unprocessedSingleTextureReplacements.ContainsKey(key) || (Object)(object)unprocessedSingleTextureReplacements[key] == (Object)null)
						{
							unprocessedSingleTextureReplacements[key] = val2;
						}
					}
					continue;
				}
				Material val4 = val3.materials[0];
				if (!Object.op_Implicit((Object)(object)val4))
				{
					continue;
				}
				Texture mainTexture = val4.mainTexture;
				if (!Object.op_Implicit((Object)(object)mainTexture))
				{
					continue;
				}
				string name = ((Object)mainTexture).name;
				if (string.IsNullOrEmpty(name) || name[0] == '~')
				{
					continue;
				}
				Dictionary<int, Texture> dictionary = new Dictionary<int, Texture>();
				if (val3.spriteDefinitions != null)
				{
					for (int j = 0; j < val3.spriteDefinitions.Length; j++)
					{
						tk2dSpriteDefinition val5 = val3.spriteDefinitions[j];
						bool flag = (Object)(object)val5.materialInst != (Object)null;
						Material[] materials = val3.materials;
						foreach (Material val6 in materials)
						{
							if ((Object)(object)val5.materialInst == (Object)null || (Object)(object)val5.materialInst.mainTexture == (Object)(object)val6.mainTexture)
							{
								flag = false;
							}
						}
						if (flag)
						{
							dictionary[j] = val5.materialInst.mainTexture;
						}
					}
				}
				((Object)val2).name = "~" + name;
				for (int l = 0; l < val3.materials.Length; l++)
				{
					Material obj2 = val3.materials[l];
					if (!((Object)(object)((obj2 != null) ? obj2.mainTexture : null) == (Object)null))
					{
						val3.materials[l].mainTexture = (Texture)(object)val2;
					}
				}
				val3.inst.materialInsts = null;
				val3.inst.Init();
				bool flag2 = (Object)(object)val3.inst != (Object)(object)val3;
				foreach (KeyValuePair<int, Texture> item2 in dictionary)
				{
					if (item2.Key < val3.Count)
					{
						tk2dSpriteDefinition val7 = val3.spriteDefinitions[item2.Key];
						if (val7 != null && (Object)(object)val7.materialInst != (Object)null)
						{
							val7.materialInst.mainTexture = item2.Value;
						}
					}
				}
				if (!flag2)
				{
					continue;
				}
				if (val3.inst?.materials != null)
				{
					for (int m = 0; m < val3.inst.materials.Length; m++)
					{
						Material obj3 = val3.inst.materials[m];
						if (!((Object)(object)((obj3 != null) ? obj3.mainTexture : null) == (Object)null))
						{
							val3.inst.materials[m].mainTexture = (Texture)(object)val2;
						}
					}
				}
				foreach (KeyValuePair<int, Texture> item3 in dictionary)
				{
					if (item3.Key < val3.inst.Count)
					{
						tk2dSpriteDefinition val8 = val3.inst.spriteDefinitions[item3.Key];
						if (val8 != null && (Object)(object)val8.materialInst != (Object)null)
						{
							val8.materialInst.mainTexture = item3.Value;
						}
					}
				}
			}
			foreach (string item4 in list5)
			{
				string[] array5 = item4.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				string collection2 = array5[0];
				string text5 = array5[1];
				if (collection2 != text)
				{
					if ((Object)(object)val != (Object)null && list != null)
					{
						val.spriteDefinitions = list.ToArray();
						list = null;
						if ((Object)(object)val.inst != (Object)(object)val && list2 != null)
						{
							val.inst.spriteDefinitions = list2.ToArray();
							list2 = null;
							val.inst.spriteNameLookupDict = null;
						}
						val.spriteNameLookupDict = null;
					}
					val = Collections.Find((tk2dSpriteCollectionData x) => x != null && x.spriteCollectionName != null && x.spriteCollectionName.Replace(" ", "_").ToLowerInvariant() == collection2.ToLowerInvariant());
					if (val?.spriteDefinitions != null)
					{
						list = new List<tk2dSpriteDefinition>(val.spriteDefinitions);
						list2 = new List<tk2dSpriteDefinition>(val.inst.spriteDefinitions);
					}
					text = collection2;
				}
				if (val?.spriteDefinitions != null && val.Count > 0)
				{
					int spriteIdByName = val.GetSpriteIdByName(text5, -1);
					if (spriteIdByName < 0)
					{
						continue;
					}
					using Stream stream2 = asmb.GetManifestResourceStream(item4);
					AssetSpriteData assetSpriteData = default(AssetSpriteData);
					try
					{
						assetSpriteData = JSONHelper.ReadJSON<AssetSpriteData>(stream2);
					}
					catch
					{
						ETGModConsole.Log("Error: invalid json at project path " + item4);
						goto end_IL_0812;
					}
					val.SetAttachPoints(spriteIdByName, assetSpriteData.attachPoints);
					if ((Object)(object)val.inst != (Object)(object)val)
					{
						val.inst.SetAttachPoints(spriteIdByName, assetSpriteData.attachPoints);
					}
					end_IL_0812:;
				}
				else
				{
					if (!((Object)(object)val == (Object)null))
					{
						continue;
					}
					using Stream stream3 = asmb.GetManifestResourceStream(item4);
					AssetSpriteData assetSpriteData2 = default(AssetSpriteData);
					try
					{
						assetSpriteData2 = JSONHelper.ReadJSON<AssetSpriteData>(stream3);
					}
					catch
					{
						ETGModConsole.Log("Error: invalid json at project path " + item4);
						goto end_IL_08aa;
					}
					if (!unprocessedJsons.TryGetValue(collection2.Replace("_", " "), out var value))
					{
						value = new Dictionary<string, AssetSpriteData>();
						unprocessedJsons.Add(collection2.Replace("_", " "), value);
					}
					value.Add(text5, assetSpriteData2);
					end_IL_08aa:;
				}
			}
			foreach (string item5 in list4)
			{
				string[] array6 = item5.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				string collection = array6[0];
				string text6 = array6[1];
				if (collection != text)
				{
					if ((Object)(object)val != (Object)null && list != null)
					{
						val.spriteDefinitions = list.ToArray();
						list = null;
						if ((Object)(object)val.inst != (Object)(object)val && list2 != null)
						{
							val.inst.spriteDefinitions = list2.ToArray();
							list2 = null;
							val.inst.spriteNameLookupDict = null;
						}
						val.spriteNameLookupDict = null;
					}
					val = Collections.Find((tk2dSpriteCollectionData x) => x != null && x.spriteCollectionName != null && x.spriteCollectionName.Replace(" ", "_").ToLowerInvariant() == collection.ToLowerInvariant());
					if (val?.spriteDefinitions != null)
					{
						list = new List<tk2dSpriteDefinition>(val.spriteDefinitions);
						list2 = new List<tk2dSpriteDefinition>(val.inst.spriteDefinitions);
					}
					text = collection;
				}
				if (val?.spriteDefinitions != null && val.Count > 0)
				{
					bool flag3 = (Object)(object)val.inst != (Object)(object)val;
					Texture2D val9 = new Texture2D(1, 1, (TextureFormat)4, false);
					using (Stream stream4 = asmb.GetManifestResourceStream(item5))
					{
						try
						{
							byte[] array7 = new byte[stream4.Length];
							stream4.Read(array7, 0, array7.Length);
							ImageConversion.LoadImage(val9, array7);
						}
						catch
						{
						}
					}
					int num = -1;
					int spriteIdByName2 = val.GetSpriteIdByName(text6, -1);
					if (spriteIdByName2 >= 0)
					{
						val.spriteDefinitions[spriteIdByName2].ReplaceTexture(val9, pack: true);
						if (flag3)
						{
							val.inst.spriteDefinitions[spriteIdByName2].ReplaceTexture(val9, pack: true);
						}
						num = spriteIdByName2;
					}
					else
					{
						tk2dSpriteDefinition val10 = new tk2dSpriteDefinition
						{
							name = text6,
							material = val.materials[0]
						};
						val10.ReplaceTexture(val9, pack: true);
						val10.normals = (Vector3[])(object)new Vector3[0];
						val10.tangents = (Vector4[])(object)new Vector4[0];
						val10.indices = new int[6] { 0, 3, 1, 2, 3, 0 };
						float num2 = (float)((Texture)val9).width * 0.0625f;
						float num3 = (float)((Texture)val9).height * 0.0625f;
						val10.position0 = new Vector3(0f, 0f, 0f);
						val10.position1 = new Vector3(num2, 0f, 0f);
						val10.position2 = new Vector3(0f, num3, 0f);
						val10.position3 = new Vector3(num2, num3, 0f);
						val10.boundsDataCenter = (val10.untrimmedBoundsDataCenter = new Vector3(num2 / 2f, num3 / 2f, 0f));
						val10.boundsDataExtents = (val10.untrimmedBoundsDataExtents = new Vector3(num2, num3, 0f));
						num = list.Count;
						list.Add(val10);
						list2.Add(val10);
					}
					TextureMap["sprites/" + val.spriteCollectionName + "/" + text6] = val9;
					string text7 = path + collection + "." + text6 + ".json";
					string text8 = path + collection + "." + text6 + ".json";
					if (manifestResourceNames.Contains(text7))
					{
						using Stream stream5 = asmb.GetManifestResourceStream(text7);
						AssetSpriteData assetSpriteData3 = default(AssetSpriteData);
						try
						{
							assetSpriteData3 = JSONHelper.ReadJSON<AssetSpriteData>(stream5);
						}
						catch
						{
							ETGModConsole.Log("Error: invalid json at project path " + text7);
							goto end_IL_0d5b;
						}
						val.SetAttachPoints(num, assetSpriteData3.attachPoints);
						if (flag3)
						{
							val.inst.SetAttachPoints(num, assetSpriteData3.attachPoints);
						}
						end_IL_0d5b:;
					}
					else
					{
						if (!manifestResourceNames.Contains(text8))
						{
							continue;
						}
						using Stream stream6 = asmb.GetManifestResourceStream(text8);
						AssetSpriteData assetSpriteData4 = default(AssetSpriteData);
						try
						{
							assetSpriteData4 = JSONHelper.ReadJSON<AssetSpriteData>(stream6);
						}
						catch
						{
							ETGModConsole.Log("Error: invalid json at project path " + text8);
							goto end_IL_0de8;
						}
						val.SetAttachPoints(num, assetSpriteData4.attachPoints);
						if (flag3)
						{
							val.inst.SetAttachPoints(num, assetSpriteData4.attachPoints);
						}
						end_IL_0de8:;
					}
					continue;
				}
				Texture2D val11 = new Texture2D(1, 1, (TextureFormat)4, false);
				using (Stream stream7 = asmb.GetManifestResourceStream(item5))
				{
					try
					{
						byte[] array8 = new byte[stream7.Length];
						stream7.Read(array8, 0, array8.Length);
						ImageConversion.LoadImage(val11, array8);
					}
					catch
					{
					}
				}
				if (!unprocessedReplacements.TryGetValue(collection.Replace("_", " "), out var value2))
				{
					value2 = new Dictionary<string, Texture2D>();
					unprocessedReplacements.Add(collection.Replace("_", " "), value2);
				}
				value2.Add(text6, val11);
			}
			if ((Object)(object)val != (Object)null && list != null)
			{
				val.spriteDefinitions = list.ToArray();
				list = null;
				if ((Object)(object)val.inst != (Object)(object)val && list2 != null)
				{
					val.inst.spriteDefinitions = list2.ToArray();
					list2 = null;
				}
				val.spriteNameLookupDict = null;
			}
		}

		public static void ReplaceTexture(tk2dSpriteDefinition frame, Texture2D replacement, bool pack = true)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			frame.flipped = (FlipMode)0;
			frame.materialInst = new Material(frame.material);
			frame.texelSize = ((Texture)replacement).texelSize;
			frame.extractRegion = true;
			RuntimeAtlasSegment runtimeAtlasSegment = Packer.Pack(replacement);
			frame.materialInst.mainTexture = (Texture)(object)runtimeAtlasSegment.texture;
			frame.uvs = runtimeAtlasSegment.uvs;
		}
	}

	internal class GlobalCRRunner : MonoBehaviour
	{
	}

	public static class Databases
	{
		public static readonly ItemDB Items = new ItemDB();

		public static readonly StringDB Strings = new StringDB();
	}

	public static class AIActor
	{
		public static Action<AIActor> OnPreStart;

		public static Action<AIActor> OnPostStart;

		public static Action<AIActor> OnBlackPhantomnessCheck;
	}

	public static class Chest
	{
		public delegate bool DOnPreOpen(bool shouldOpen, Chest chest, PlayerController player);

		public static Action<Chest> OnPostSpawn;

		public static DOnPreOpen OnPreOpen;

		public static Action<Chest, PlayerController> OnPostOpen;
	}

	public static readonly Action<Coroutine> StopGlobalCoroutine = delegate(Coroutine x)
	{
		((MonoBehaviour)GameObjectExtensions.GetOrAddComponent<GlobalCRRunner>(Chainloader.ManagerObject)).StopCoroutine(x);
	};

	public static readonly Func<IEnumerator, Coroutine> StartGlobalCoroutine = (IEnumerator x) => ((MonoBehaviour)GameObjectExtensions.GetOrAddComponent<GlobalCRRunner>(Chainloader.ManagerObject)).StartCoroutine(x);

	private static readonly long _DoubleNegativeZero = BitConverter.DoubleToInt64Bits(-0.0);

	public static string ResourcesDirectory
	{
		get
		{
			string text = Path.Combine(Paths.GameRootPath, "Resources");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			return text;
		}
	}

	public static string SpriteReplacementDirectory
	{
		get
		{
			string text = Path.Combine(ResourcesDirectory, "SpriteReplacement");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			return text;
		}
	}

	public static string FolderPath(this BaseUnityPlugin plug)
	{
		if ((Object)(object)plug == (Object)null || plug.Info == null || plug.Info.Location == null)
		{
			return "";
		}
		return Path.GetDirectoryName(plug.Info.Location);
	}

	public static void ReplaceTexture(this tk2dSpriteDefinition frame, Texture2D replacement, bool pack = true)
	{
		Assets.ReplaceTexture(frame, replacement);
	}

	public static T RunHook<T>(this MulticastDelegate md, T val, params object[] args)
	{
		if ((object)md == null)
		{
			return val;
		}
		object[] array = new object[args.Length + 1];
		array[0] = val;
		Array.Copy(args, 0, array, 1, args.Length);
		Delegate[] invocationList = md.GetInvocationList();
		for (int i = 0; i < invocationList.Length; i++)
		{
			array[0] = invocationList[i].DynamicInvoke(array);
		}
		return (T)array[0];
	}

	public static string ToStringSafe(this object o)
	{
		return (o == null) ? string.Empty : ((o is string text) ? text : o.ToString());
	}

	public static string RemoveUnacceptableCharactersForEnum(this string str)
	{
		return str?.Replace("\"", "").Replace("\\", "").Replace(" ", "")
			.Replace("-", "_")
			.Replace("\n", "");
	}

	public static string RemoveUnacceptableCharactersForGUID(this string str)
	{
		return str?.Replace("\"", "").Replace("\\", "").Replace("\n", "");
	}

	public static string ToID(this string str)
	{
		return str.ToLowerInvariant().Replace("\n", "").Replace("\\", "")
			.Replace("\"", "")
			.Replace(" ", "_")
			.Replace(".", "")
			.Replace("-", "");
	}

	public static bool IsNegativeZero(this double d)
	{
		return BitConverter.DoubleToInt64Bits(d) == _DoubleNegativeZero;
	}

	public static bool IsNegativeZero(this float f)
	{
		return BitConverter.DoubleToInt64Bits(f) == _DoubleNegativeZero;
	}

	public static int Count(this string @in, char c)
	{
		int num = 0;
		for (int i = 0; i < @in.Length; i++)
		{
			if (@in[i] == c)
			{
				num++;
			}
		}
		return num;
	}

	internal static bool ContainsWhitespace(this string s)
	{
		if (string.IsNullOrEmpty(s))
		{
			return false;
		}
		foreach (char c in s)
		{
			if (char.IsWhiteSpace(c))
			{
				return true;
			}
		}
		return false;
	}

	public static T GetFirst<T>(this IEnumerable<T> e)
	{
		using (IEnumerator<T> enumerator = e.GetEnumerator())
		{
			if (enumerator.MoveNext())
			{
				return enumerator.Current;
			}
		}
		return default(T);
	}

	public static string ToTitleCaseInvariant(this string s)
	{
		return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(s);
	}

	public static string ToStringInvariant(this float o)
	{
		return o.ToString(CultureInfo.InvariantCulture);
	}

	public static string RemovePrefix(this string str, string prefix)
	{
		return str.StartsWithInvariant(prefix) ? str.Substring(prefix.Length) : str;
	}

	public static string RemoveSuffix(this string str, string suffix)
	{
		return str.StartsWithInvariant(suffix) ? str.Substring(0, suffix.Length - suffix.Length) : str;
	}

	public static int IndexOfInvariant(this string s, string a)
	{
		return s.IndexOf(a, StringComparison.InvariantCulture);
	}

	public static int IndexOfInvariant(this string s, string a, int i)
	{
		return s.IndexOf(a, i, StringComparison.InvariantCulture);
	}

	public static int LastIndexOfInvariant(this string s, string a)
	{
		return s.LastIndexOf(a, StringComparison.InvariantCulture);
	}

	public static int LastIndexOfInvariant(this string s, string a, int i)
	{
		return s.LastIndexOf(a, i, StringComparison.InvariantCulture);
	}

	public static bool StartsWithInvariant(this string s, string a)
	{
		return s.StartsWith(a, StringComparison.InvariantCulture);
	}

	public static bool EndsWithInvariant(this string s, string a)
	{
		return s.EndsWith(a, StringComparison.InvariantCulture);
	}

	public static string Combine(this IList<string> sa, string c)
	{
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 0; i < sa.Count; i++)
		{
			stringBuilder.Append(sa[i]);
			if (i < sa.Count - 1)
			{
				stringBuilder.Append(c);
			}
		}
		return stringBuilder.ToString();
	}

	public static string CombineReversed(this IList<string> sa, string c)
	{
		StringBuilder stringBuilder = new StringBuilder();
		int num = sa.Count - 1;
		while (0 <= num)
		{
			stringBuilder.Append(sa[num]);
			if (0 < num)
			{
				stringBuilder.Append(c);
			}
			num--;
		}
		return stringBuilder.ToString();
	}

	public static Type GetValueType(this MemberInfo info)
	{
		if (info is FieldInfo)
		{
			return ((FieldInfo)info).FieldType;
		}
		if (info is PropertyInfo)
		{
			return ((PropertyInfo)info).PropertyType;
		}
		if (info is MethodInfo)
		{
			return ((MethodInfo)info).ReturnType;
		}
		return null;
	}

	public static T AtOr<T>(this T[] a, int i, T or)
	{
		if (i < 0 || a.Length <= i)
		{
			return or;
		}
		return a[i];
	}

	public static void AddRange(this IDictionary to, IDictionary from)
	{
		foreach (DictionaryEntry item in from)
		{
			to.Add(item.Key, item.Value);
		}
	}

	public static void ForEach<T>(this BindingList<T> list, Action<T> a)
	{
		for (int i = 0; i < list.Count; i++)
		{
			a(list[i]);
		}
	}

	public static void AddRange<T>(this BindingList<T> list, BindingList<T> other)
	{
		for (int i = 0; i < other.Count; i++)
		{
			list.Add(other[i]);
		}
	}

	public static int IndexOf(this object[] array, object elem)
	{
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] == elem)
			{
				return i;
			}
		}
		return -1;
	}

	public static Texture2D Copy(this Texture2D texture, TextureFormat? format = 5)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_0072: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)texture == (Object)null)
		{
			return null;
		}
		RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)0);
		Graphics.Blit((Texture)(object)texture, temporary);
		RenderTexture active = RenderTexture.active;
		RenderTexture.active = temporary;
		Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, format.HasValue ? format.Value : texture.format, 1 < texture.mipmapCount);
		((Object)val).name = ((Object)texture).name;
		val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
		val.Apply(true, false);
		RenderTexture.active = active;
		RenderTexture.ReleaseTemporary(temporary);
		return val;
	}

	public static Texture2D GetRW(this Texture2D texture)
	{
		if ((Object)(object)texture == (Object)null)
		{
			return null;
		}
		if (texture.IsReadable())
		{
			return texture;
		}
		return texture.Copy((TextureFormat)5);
	}

	public static bool IsReadable(this Texture2D texture)
	{
		try
		{
			texture.GetPixels();
			return true;
		}
		catch
		{
			return false;
		}
	}

	public static Type GetListType(this Type list)
	{
		if (list.IsArray)
		{
			return list.GetElementType();
		}
		Type[] interfaces = list.GetInterfaces();
		foreach (Type type in interfaces)
		{
			if (type.IsGenericType && (object)type.GetGenericTypeDefinition() == typeof(IList<>))
			{
				return list.GetGenericArguments()[0];
			}
		}
		return null;
	}

	public static string GetPath(this Transform t)
	{
		List<string> list = new List<string>();
		do
		{
			list.Add(((Object)t).name);
		}
		while ((Object)(object)(t = t.parent) != (Object)null);
		return list.CombineReversed("/");
	}

	public static GameObject AddChild(this GameObject go, string name, params Type[] components)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Expected O, but got Unknown
		GameObject val = new GameObject(name, components);
		val.transform.SetParent(go.transform);
		val.transform.SetAsLastSibling();
		return val;
	}

	public static tk2dBaseSprite GetAnySprite(this BraveBehaviour b)
	{
		return ((Component)b).GetComponent<tk2dBaseSprite>() ?? ((Component)b.transform).GetComponentInChildren<tk2dBaseSprite>() ?? ((Component)b.transform).GetComponentInParent<tk2dBaseSprite>();
	}

	public static Coroutine StartGlobal(this IEnumerator c)
	{
		if (c == null)
		{
			return null;
		}
		return StartGlobalCoroutine(c);
	}

	public static void StopGlobal(this Coroutine c)
	{
		if (c != null)
		{
			StopGlobalCoroutine(c);
		}
	}
}
public class AssetDirectory
{
	private AssetDirectory()
	{
	}
}
public struct AssetSpriteData
{
	public string name;

	public int x;

	public int y;

	public int width;

	public int height;

	public int flip;

	public AttachPoint[] attachPoints;

	public static void ToTK2D(List<AssetSpriteData> list, out string[] names, out Rect[] regions, out Vector2[] anchors, out AttachPoint[][] attachPoints)
	{
		//IL_006c: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		names = new string[list.Count];
		regions = (Rect[])(object)new Rect[list.Count];
		anchors = (Vector2[])(object)new Vector2[list.Count];
		attachPoints = new AttachPoint[list.Count][];
		for (int i = 0; i < list.Count; i++)
		{
			AssetSpriteData assetSpriteData = list[i];
			names[i] = assetSpriteData.name;
			regions[i] = new Rect((float)assetSpriteData.x, (float)assetSpriteData.y, (float)assetSpriteData.width, (float)assetSpriteData.height);
			anchors[i] = new Vector2((float)assetSpriteData.width / 2f, (float)assetSpriteData.height / 2f);
			attachPoints[i] = assetSpriteData.attachPoints;
		}
	}

	public static List<AssetSpriteData> FromTK2D(tk2dSpriteCollectionData sprites)
	{
		List<AssetSpriteData> list = new List<AssetSpriteData>(sprites.spriteDefinitions.Length);
		for (int i = 0; i < sprites.spriteDefinitions.Length; i++)
		{
			tk2dSpriteDefinition frame = sprites.spriteDefinitions[i];
			list.Add(FromTK2D(sprites, frame));
		}
		return list;
	}

	public static AssetSpriteData FromTK2D(tk2dSpriteCollectionData sprites, tk2dSpriteDefinition frame, bool separate = false)
	{
		Material obj = sprites.materials[0];
		AssetSpriteData result;
		if ((Object)(object)((obj != null) ? obj.mainTexture : null) == (Object)null)
		{
			result = default(AssetSpriteData);
			result.name = (separate ? "INCOMPLETE" : (frame.name + "_INCOMPLETE"));
			return result;
		}
		int num = sprites.materials[0].mainTexture.width;
		int num2 = sprites.materials[0].mainTexture.height;
		result = default(AssetSpriteData);
		result.name = (separate ? null : frame.name);
		result.x = ((!separate) ? ((int)Math.Floor((float)num * frame.uvs[0].x)) : 0);
		result.y = ((!separate) ? ((int)Math.Floor((float)num2 * frame.uvs[0].y)) : 0);
		result.width = (int)Math.Ceiling((float)num * (frame.uvs[3].x - frame.uvs[0].x));
		result.height = (int)Math.Ceiling((float)num2 * (frame.uvs[3].y - frame.uvs[0].y));
		result.flip = ((frame.uvs[0].x == frame.uvs[1].x) ? 1 : 0);
		object[] spriteDefinitions = sprites.spriteDefinitions;
		result.attachPoints = (AttachPoint[])(((object)sprites.GetAttachPoints(spriteDefinitions.IndexOf(frame))) ?? ((object)new AttachPoint[0]));
		return result;
	}
}
public class JSONAttachPointRule : JSONValueTypeBaseRule<AttachPoint>
{
}
public class RuntimeAtlasPacker
{
	public List<RuntimeAtlasPage> Pages = new List<RuntimeAtlasPage>();

	public int Width;

	public int Height;

	public TextureFormat Format;

	public int Padding;

	public Action<RuntimeAtlasPage> OnNewPage;

	public RuntimeAtlasPacker(int width = 0, int height = 0, TextureFormat format = 4, int padding = 2)
	{
		//IL_0040: 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)
		if (width == 0)
		{
			width = RuntimeAtlasPage.DefaultSize;
		}
		if (height == 0)
		{
			height = RuntimeAtlasPage.DefaultSize;
		}
		Width = width;
		Height = height;
		Format = format;
		Padding = padding;
	}

	public RuntimeAtlasSegment Pack(Texture2D tex, bool apply = false)
	{
		for (int i = 0; i < Pages.Count; i++)
		{
			RuntimeAtlasSegment result;
			if ((result = Pages[i].Pack(tex, apply)) != null)
			{
				return result;
			}
		}
		return NewPage().Pack(tex, apply);
	}

	public RuntimeAtlasPage NewPage()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		RuntimeAtlasPage runtimeAtlasPage = new RuntimeAtlasPage(Width, Height, Format, Padding);
		Pages.Add(runtimeAtlasPage);
		OnNewPage?.Invoke(runtimeAtlasPage);
		return runtimeAtlasPage;
	}

	public void Apply()
	{
		for (int i = 0; i < Pages.Count; i++)
		{
			Pages[i].Apply();
		}
	}

	public bool IsPageTexture(Texture2D tex)
	{
		return IsPageTexture((Texture)(object)tex);
	}

	internal bool IsPageTexture(Texture tex)
	{
		for (int i = 0; i < Pages.Count; i++)
		{
			if (Pages[i].Texture == tex)
			{
				return true;
			}
		}
		return false;
	}
}
public class RuntimeAtlasPage
{
	public static int DefaultSize = Math.Min(SystemInfo.maxTextureSize, 1024);

	public List<RuntimeAtlasSegment> Segments = new List<RuntimeAtlasSegment>();

	public Texture2D Texture;

	public int Padding;

	protected Rect _MainRect;

	protected List<Rect> _Rects = new List<Rect>();

	protected int _Changes;

	private static readonly int BlockSize = 128;

	private static readonly Color32[] DefaultBlock = CreateDefaultBlock();

	private static readonly Color32 Default = new Color32((byte)0, (byte)0, (byte)0, (byte)0);

	private float _startingX;

	private float _currentY;

	private float _nextYLine;

	public RuntimeAtlasPage(int width = 0, int height = 0, TextureFormat format = 4, int padding = 2)
	{
		//IL_003f: 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_004b: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		if (width == 0)
		{
			width = DefaultSize;
		}
		if (height == 0)
		{
			height = DefaultSize;
		}
		Texture = new Texture2D(width, height, format, false);
		((Texture)Texture).wrapMode = (TextureWrapMode)1;
		((Texture)Texture).filterMode = (FilterMode)0;
		((Texture)Texture).anisoLevel = 0;
		for (int i = 0; i < height; i += BlockSize)
		{
			for (int j = 0; j < width; j += BlockSize)
			{
				Texture.SetPixels32(j, i, BlockSize, BlockSize, DefaultBlock);
			}
		}
		_MainRect = new Rect(0f, 0f, (float)width, (float)height);
		Padding = padding;
	}

	public RuntimeAtlasSegment Pack(Texture2D tex, bool apply = false)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		Rect val = default(Rect);
		((Rect)(ref val)).Set(_startingX + (float)Padding, _currentY + (float)Padding, (float)(((Texture)tex).width + Padding), (float)(((Texture)tex).height + Padding));
		if (dfRectExtensions.Contains(_MainRect, val))
		{
			_startingX = ((Rect)(ref val)).xMax;
			_nextYLine = Math.Max(((Rect)(ref val)).yMax, _nextYLine);
		}
		else
		{
			_startingX = 0f;
			_currentY = _nextYLine;
			((Rect)(ref val)).Set(_startingX + (float)Padding, _currentY + (float)Padding, (float)(((Texture)tex).width + Padding), (float)(((Texture)tex).height + Padding));
			if (!dfRectExtensions.Contains(_MainRect, val))
			{
				return null;
			}
			_startingX = ((Rect)(ref val)).xMax;
			_nextYLine = Math.Max(((Rect)(ref val)).yMax, _nextYLine);
		}
		_Rects.Add(val);
		RuntimeAtlasSegment runtimeAtlasSegment = new RuntimeAtlasSegment
		{
			texture = Texture,
			x = Mathf.RoundToInt(((Rect)(ref val)).x),
			y = Mathf.RoundToInt(((Rect)(ref val)).y),
			width = ((Texture)tex).width,
			height = ((Texture)tex).height
		};
		Segments.Add(runtimeAtlasSegment);
		Texture.SetPixels32(runtimeAtlasSegment.x, runtimeAtlasSegment.y, runtimeAtlasSegment.width, runtimeAtlasSegment.height, tex.GetPixels32());
		_Changes++;
		if (apply)
		{
			Apply();
		}
		return runtimeAtlasSegment;
	}

	public void Apply()
	{
		if (_Changes != 0)
		{
			_Changes = 0;
			Texture.Apply(false, false);
		}
	}

	private static Color32[] CreateDefaultBlock()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		Color32[] array = (Color32[])(object)new Color32[BlockSize * BlockSize];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = Default;
		}
		return array;
	}
}
public class RuntimeAtlasSegment
{
	public Texture2D texture;

	public int x;

	public int y;

	public int width;

	public int height;

	public Vector2[] uvs => ETGMod.Assets.GenerateUVs(texture, x, y, width, height);
}
[HarmonyPatch]
public static class ETGModCompatibility
{
	private static readonly Dictionary<Type, Dictionary<GuidInfo, int>> extendedEnums = new Dictionary<Type, Dictionary<GuidInfo, int>>();

	private static readonly Dictionary<string, Dictionary<string, object>> sharedData = new Dictionary<string, Dictionary<string, object>>();

	public static T ExtendEnum<T>(string guid, string name) where T : Enum
	{
		return (T)ExtendEnum(guid, name, typeof(T));
	}

	public static object ExtendEnum(string guid, string name, Type t)
	{
		if (!t.IsEnum)
		{
			return 0;
		}
		ETGModMainBehaviour.EnsureHarmonyInitialized();
		Dictionary<GuidInfo, int> dictionary;
		if (!extendedEnums.ContainsKey(t))
		{
			dictionary = new Dictionary<GuidInfo, int>();
			extendedEnums.Add(t, dictionary);
		}
		else
		{
			dictionary = extendedEnums[t];
		}
		name = name.RemoveUnacceptableCharactersForEnum().Replace(".", "");
		guid = guid.RemoveUnacceptableCharactersForEnum();
		GuidInfo ginfo = new GuidInfo(guid, name);
		IEnumerable<KeyValuePair<GuidInfo, int>> source = dictionary.Where((KeyValuePair<GuidInfo, int> x) => x.Key.guid == ginfo.guid && x.Key.info == ginfo.info);
		KeyValuePair<GuidInfo, int>? keyValuePair = null;
		if (source.Count() > 0)
		{
			keyValuePair = source.FirstOrDefault();
		}
		if (keyValuePair.HasValue)
		{
			return keyValuePair.GetValueOrDefault().Value;
		}
		int num = 0;
		try
		{
			num = Enum.GetValues(t).Cast<int>().Max();
		}
		catch
		{
		}
		int num2 = 0;
		num2 = ((!t.IsDefined(typeof(FlagsAttribute), inherit: false)) ? (num + 1) : ((num == 0) ? 1 : (num * 2)));
		dictionary.Add(ginfo, num2);
		return num2;
	}

	[HarmonyPatch(typeof(GameStatsManager), "GetPlayerStatValue")]
	[HarmonyPrefix]
	private static bool FixCharacterCountTracked(GameStatsManager __instance, out float __result, TrackedStats stat)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		__result = 0f;
		if (__instance.m_sessionStats != null)
		{
			__result += __instance.m_sessionStats.GetStatValue(stat);
		}
		foreach (GameStats value in __instance.m_characterStats.Values)
		{
			__result += value.GetStatValue(stat);
		}
		return false;
	}

	[HarmonyPatch(typeof(GameStatsManager), "GetPlayerMaximum")]
	[HarmonyPrefix]
	private static bool FixCharacterCountMaximum(GameStatsManager __instance, out float __result, TrackedMaximums stat)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		__result = 0f;
		if (__instance.m_sessionStats != null)
		{
			__result = Mathf.Max(new float[3]
			{
				__result,
				__instance.m_sessionStats.GetMaximumValue(stat),
				__instance.m_savedSessionStats.GetMaximumValue(stat)
			});
		}
		foreach (GameStats value in __instance.m_characterStats.Values)
		{
			__result = Mathf.Max(__result, value.GetMaximumValue(stat));
		}
		return false;
	}

	[HarmonyPatch(typeof(GameStatsManager), "Save")]
	[HarmonyPrefix]
	private static void RemoveAndSaveExtendedEnums()
	{
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Expected I4, but got Unknown
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		if (extendedEnums != null && GameStatsManager.m_instance != null)
		{
			ExtendedEnumCache instance2 = ExtendedEnumCache.Instance;
			GameStatsManager instance = GameStatsManager.m_instance;
			instance2.extendedFlags.Clear();
			instance2.extendedValidTilesets.Clear();
			instance2.extendedPlayersTrackedStats.Clear();
			instance2.extendedPlayersTrackedMaximums.Clear();
			instance2.extendedPlayersCharacterFlags.Clear();
			if (extendedEnums.ContainsKey(typeof(GungeonFlags)) && extendedEnums[typeof(GungeonFlags)] != null)
			{
				(instance2.extendedFlags = instance.m_flags.Where((GungeonFlags x) => extendedEnums[typeof(GungeonFlags)].ContainsValue((int)x)).ToList()).ForEach(delegate(GungeonFlags x)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					instance.m_flags.Remove(x);
				});
			}
			bool flag = extendedEnums.ContainsKey(typeof(PlayableCharacters)) && extendedEnums[typeof(PlayableCharacters)] != null;
			bool flag2 = extendedEnums.ContainsKey(typeof(TrackedStats)) && extendedEnums[typeof(TrackedStats)] != null;
			bool flag3 = extendedEnums.ContainsKey(typeof(TrackedMaximums)) && extendedEnums[typeof(TrackedMaximums)] != null;
			bool flag4 = extendedEnums.ContainsKey(typeof(CharacterSpecificGungeonFlags)) && extendedEnums[typeof(CharacterSpecificGungeonFlags)] != null;
			if (flag || flag2 || flag3 || flag4)
			{
				List<PlayableCharacters> list = new List<PlayableCharacters>();
				foreach (KeyValuePair<PlayableCharacters, GameStats> kvp in instance.m_characterStats)
				{
					if (kvp.Value != null && extendedEnums[typeof(PlayableCharacters)].ContainsValue((int)kvp.Key))
					{
						list.Add(kvp.Key);
						instance2.extendedPlayersTrackedStats[kvp.Key] = new List<KeyValuePair<TrackedStats, float>>(kvp.Value.stats);
						instance2.extendedPlayersTrackedMaximums[kvp.Key] = new List<KeyValuePair<TrackedMaximums, float>>(kvp.Value.maxima);
						instance2.extendedPlayersCharacterFlags[kvp.Key] = new List<CharacterSpecificGungeonFlags>(kvp.Value.m_flags);
						continue;
					}
					if (flag2)
					{
						List<KeyValuePair<TrackedStats, float>> list3 = (instance2.extendedPlayersTrackedStats[kvp.Key] = kvp.Value.stats.Where((KeyValuePair<TrackedStats, float> x) => extendedEnums[typeof(TrackedStats)].ContainsValue((int)x.Key)).ToList());
						CollectionExtensions.Do<KeyValuePair<TrackedStats, float>>((IEnumerable<KeyValuePair<TrackedStats, float>>)list3, (Action<KeyValuePair<TrackedStats, float>>)delegate(KeyValuePair<TrackedStats, float> x)
						{
							//IL_0012: Unknown result type (might be due to invalid IL or missing references)
							kvp.Value.stats.Remove(x.Key);
						});
					}
					if (flag3)
					{
						List<KeyValuePair<TrackedMaximums, float>> list5 = (instance2.extendedPlayersTrackedMaximums[kvp.Key] = kvp.Value.maxima.Where((KeyValuePair<TrackedMaximums, float> x) => extendedEnums[typeof(TrackedMaximums)].ContainsValue((int)x.Key)).ToList());
						CollectionExtensions.Do<KeyValuePair<TrackedMaximums, float>>((IEnumerable<KeyValuePair<TrackedMaximums, float>>)list5, (Action<KeyValuePair<TrackedMaximums, float>>)delegate(KeyValuePair<TrackedMaximums, float> x)
						{
							//IL_0012: Unknown result type (might be due to invalid IL or missing references)
							kvp.Value.maxima.Remove(x.Key);
						});
					}
					if (flag4)
					{
						List<CharacterSpecificGungeonFlags> list7 = (instance2.extendedPlayersCharacterFlags[kvp.Key] = kvp.Value.m_flags.Where((CharacterSpecificGungeonFlags x) => extendedEnums[typeof(CharacterSpecificGungeonFlags)].ContainsValue((int)x)).ToList());
						CollectionExtensions.Do<CharacterSpecificGungeonFlags>((IEnumerable<CharacterSpecificGungeonFlags>)list7, (Action<CharacterSpecificGungeonFlags>)delegate(CharacterSpecificGungeonFlags x)
						{
							//IL_0010: Unknown result type (might be due to invalid IL or missing references)
							kvp.Value.m_flags.Remove(x);
						});
					}
				}
				CollectionExtensions.Do<PlayableCharacters>((IEnumerable<PlayableCharacters>)list, (Action<PlayableCharacters>)delegate(PlayableCharacters x)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					instance.m_characterStats.Remove(x);
				});
			}
			if (extendedEnums.ContainsKey(typeof(ValidTilesets)) && extendedEnums[typeof(ValidTilesets)] != null)
			{
				(instance2.extendedValidTilesets = instance.LastBossEncounteredMap.Where((KeyValuePair<ValidTilesets, string> x) => extendedEnums[typeof(ValidTilesets)].ContainsValue((int)x.Key)).ToList()).ForEach(delegate(KeyValuePair<ValidTilesets, string> x)
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					instance.LastBossEncounteredMap.Remove(x.Key);
				});
			}
			ExtendedEnumCache.Save();
		}
		SaveManager.GameSave.encrypted = false;
	}

	[HarmonyPatch(typeof(GameStatsManager), "Save")]
	[HarmonyPatch(typeof(GameStatsManager), "Load")]
	[HarmonyPostfix]
	private static void AddBackExtendedEnums()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Expected O, but got Unknown
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Expected O, but got Unknown
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		if (GameStatsManager.m_instance == null)
		{
			return;
		}
		ExtendedEnumCache instance2 = ExtendedEnumCache.Instance;
		GameStatsManager instance = GameStatsManager.m_instance;
		instance2.extendedFlags.ForEach(delegate(GungeonFlags x)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			instance.m_flags.Add(x);
		});
		foreach (KeyValuePair<PlayableCharacters, List<KeyValuePair<TrackedStats, float>>> extendedPlayersTrackedStat in instance2.extendedPlayersTrackedStats)
		{
			if (!instance.m_characterStats.ContainsKey(extendedPlayersTrackedStat.Key) || instance.m_characterStats[extendedPlayersTrackedStat.Key] == null)
			{
				instance.m_characterStats[extendedPlayersTrackedStat.Key] = new GameStats();
			}
			foreach (KeyValuePair<TrackedStats, float> item in extendedPlayersTrackedStat.Value)
			{
				instance.m_characterStats[extendedPlayersTrackedStat.Key].stats[item.Key] = item.Value;
			}
		}
		foreach (KeyValuePair<PlayableCharacters, List<KeyValuePair<TrackedMaximums, float>>> extendedPlayersTrackedMaximum in instance2.extendedPlayersTrackedMaximums)
		{
			if (!instance.m_characterStats.ContainsKey(extendedPlayersTrackedMaximum.Key) || instance.m_characterStats[extendedPlayersTrackedMaximum.Key] == null)
			{
				instance.m_characterStats[extendedPlayersTrackedMaximum.Key] = new GameStats();
			}
			foreach (KeyValuePair<TrackedMaximums, float> item2 in extendedPlayersTrackedMaximum.Value)
			{
				instance.m_characterStats[extendedPlayersTrackedMaximum.Key].maxima[item2.Key] = item2.Value;
			}
		}
		foreach (KeyValuePair<PlayableCharacters, List<CharacterSpecificGungeonFlags>> extendedPlayersCharacterFlag in instance2.extendedPlayersCharacterFlags)
		{
			if (!instance.m_characterStats.ContainsKey(extendedPlayersCharacterFlag.Key) || instance.m_characterStats[extendedPlayersCharacterFlag.Key] == null)
			{
				instance.m_characterStats[extendedPlayersCharacterFlag.Key] = new GameStats();
			}
			foreach (CharacterSpecificGungeonFlags item3 in extendedPlayersCharacterFlag.Value)
			{
				instance.m_characterStats[extendedPlayersCharacterFlag.Key].m_flags.Add(item3);
			}
		}
		foreach (KeyValuePair<ValidTilesets, string> extendedValidTileset in instance2.extendedValidTilesets)
		{
			instance.LastBossEncounteredMap[extendedValidTileset.Key] = extendedValidTileset.Value;
		}
	}

	[HarmonyPatch(typeof(fsEnumConverter), "TryDeserialize")]
	[HarmonyPostfix]
	private static void FixEnumConverter(ref fsResult __result, fsData data, ref object instance, Type storageType)
	{
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		if (__result._success || !data.IsString)
		{
			return;
		}
		string[] array = data.AsString.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
		long num = 0L;
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (!fsEnumConverter.ArrayContains<string>(Enum.GetNames(storageType), text))
			{
				string[] source = text.Split(new char[1] { '.' });
				if (source.Count() <= 3)
				{
					return;
				}
				string guid = string.Join(".", source.Take(3).ToArray());
				string name = string.Join(".", source.Skip(3).ToArray());
				ExtendEnum(guid, name, storageType);
			}
			long num2 = (long)Convert.ChangeType(Enum.Parse(storageType, text), typeof(long));
			num |= num2;
		}
		instance = Enum.ToObject(storageType, num);
		__result = fsResult.Success;
	}

	[HarmonyPatch(typeof(Enum), "GetValues")]
	[HarmonyPostfix]
	private static void AddNewValues(ref Array __result, Type enumType)
	{
		if (__result == null || extendedEnums == null || !extendedEnums.ContainsKey(enumType))
		{
			return;
		}
		List<object> list = new List<object>();
		foreach (object item in __result)
		{
			list.Add(item);
		}
		list.AddRange(extendedEnums[enumType].Values.Select((int x) => Enum.ToObject(enumType, x)));
		__result = Array.CreateInstance(enumType, list.Count);
		for (int i = 0; i < __result.Length; i++)
		{
			__result.SetValue(list[i], i);
		}
	}

	[HarmonyPatch(typeof(Enum), "GetNames")]
	[HarmonyPostfix]
	private static void AddNewNames(ref string[] __result, Type enumType)
	{
		if (__result != null && extendedEnums != null && extendedEnums.ContainsKey(enumType))
		{
			__result = __result.Concat(extendedEnums[enumType].Keys.Select((GuidInfo x) => x.ToString())).ToArray();
		}
	}

	[HarmonyPatch(typeof(Enum), "GetName")]
	[HarmonyPostfix]
	private static void AddName(ref string __result, Type enumType, object value)
	{
		if (__result != null || extendedEnums == null || !extendedEnums.ContainsKey(enumType))
		{
			return;
		}
		try
		{
			int val = (int)value;
			IEnumerable<KeyValuePair<GuidInfo, int>> source = extendedEnums[enumType].Where((KeyValuePair<GuidInfo, int> x) => x.Value == val);
			if (source.Count() > 0)
			{
				__result = source.FirstOrDefault().Key.ToString();
			}
		}
		catch
		{
		}
	}

	[HarmonyPatch(typeof(Enum), "IsDefined")]
	[HarmonyPostfix]
	private static void AddDefined(ref bool __result, Type enumType, object value)
	{
		if (extendedEnums != null && extendedEnums.ContainsKey(enumType) && !__result)
		{
			Type type = value.GetType();
			if ((object)type == typeof(string))
			{
				__result = Enum.GetNames(enumType).Contains(value);
				return;
			}
			__result = (int)typeof(Enum).GetMethod("FindPosition", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[2]
			{
				value,
				Enum.GetValues(enumType)
			}) >= 0;
		}
	}

	[HarmonyPatch(typeof(Enum), "Parse", new Type[]
	{
		typeof(Type),
		typeof(string),
		typeof(bool)
	})]
	[HarmonyFinalizer]
	private static Exception AddParse(Exception __exception, ref object __result, Type enumType, string value, bool ignoreCase)
	{
		if (__exception != null)
		{
			if (__result != null || extendedEnums == null || !extendedEnums.ContainsKey(enumType))
			{
				return __exception;
			}
			if (__exception is ArgumentException)
			{
				if ((object)enumType == null)
				{
					return __exception;
				}
				if (value == null)
				{
					return __exception;
				}
				if (!enumType.IsEnum)
				{
					return __exception;
				}
				value = value.Trim();
				if (value.Length == 0)
				{
					return __exception;
				}
				Array values = Enum.GetValues(enumType);
				string[] names = Enum.GetNames(enumType);
				int num = FindName(names, value, ignoreCase);
				if (num >= 0)
				{
					__result = values.GetValue(num);
					return null;
				}
				TypeCode typeCode = ((Enum)values.GetValue(0)).GetTypeCode();
				if (value.IndexOf(',') != -1)
				{
					string[] array = value.Split(new char[1] { ',' });
					ulong num2 = 0uL;
					for (int i = 0; i < array.Length; i++)
					{
						num = FindName(names, array[i].Trim(), ignoreCase);
						if (num < 0)
						{
							throw new ArgumentException("The requested value was not found.");
						}
						num2 |= GetValue(values.GetValue(num), typeCode);
					}
					__result = Enum.ToObject(enumType, num2);
					return null;
				}
			}
			return __exception;
		}
		return null;
	}

	private static int FindName(string[] names, string name, bool ignoreCase)
	{
		if (!ignoreCase)
		{
			for (int i = 0; i < names.Length; i++)
			{
				if (name == names[i])
				{
					return i;
				}
			}
		}
		else
		{
			for (int j = 0; j < names.Length; j++)
			{
				if (string.Compare(name, names[j], ignoreCase, CultureInfo.InvariantCulture) == 0)
				{
					return j;
				}
			}
		}
		return -1;
	}

	private static ulong GetValue(object value, TypeCode typeCode)
	{
		if (1 == 0)
		{
		}
		ulong result = typeCode switch
		{
			TypeCode.SByte => (byte)(sbyte)value, 
			TypeCode.Byte => (byte)value, 
			TypeCode.Int16 => (ushort)(short)value, 
			TypeCode.UInt16 => (ushort)value, 
			TypeCode.Int32 => (ulong)(int)value, 
			TypeCode.UInt32 => (uint)value, 
			TypeCode.Int64 => (ulong)(long)value, 
			TypeCode.UInt64 => (ulong)value, 
			_ => throw new ArgumentException("typeCode is not a valid type code for an Enum"), 
		};
		if (1 == 0)
		{
		}
		return result;
	}

	[HarmonyPatch(typeof(Enum), "FormatFlags")]
	[HarmonyPostfix]
	private static void FixFlagFormatting(ref string __result, Type enumType, object value)
	{
		if (extendedEnums == null || !extendedEnums.ContainsKey(enumType))
		{
			return;
		}
		string text = string.Empty;
		Array values = Enum.GetValues(enumType);
		string[] names = Enum.GetNames(enumType);
		string text2 = value.ToString();
		if (text2 == "0")
		{
			text = Enum.GetName(enumType, value);
			if (text == null)
			{
				text = text2;
			}
			__result = text;
			return;
		}
		switch (((Enum)values.GetValue(0)).GetTypeCode())
		{
		case TypeCode.SByte:
		{
			sbyte b = (sbyte)value;
			for (int num7 = values.Length - 1; num7 >= 0; num7--)
			{
				sbyte b2 = (sbyte)values.GetValue(num7);
				if (b2 != 0 && (b & b2) == b2)
				{
					text = names[num7] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					b -= b2;
				}
			}
			if (b != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.Byte:
		{
			byte b3 = (byte)value;
			for (int num8 = values.Length - 1; num8 >= 0; num8--)
			{
				byte b4 = (byte)values.GetValue(num8);
				if (b4 != 0 && (b3 & b4) == b4)
				{
					text = names[num8] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					b3 -= b4;
				}
			}
			if (b3 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.Int16:
		{
			short num18 = (short)value;
			for (int num19 = values.Length - 1; num19 >= 0; num19--)
			{
				short num20 = (short)values.GetValue(num19);
				if (num20 != 0 && (num18 & num20) == num20)
				{
					text = names[num19] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num18 -= num20;
				}
			}
			if (num18 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.UInt16:
		{
			ushort num12 = (ushort)value;
			for (int num13 = values.Length - 1; num13 >= 0; num13--)
			{
				ushort num14 = (ushort)values.GetValue(num13);
				if (num14 != 0 && (num12 & num14) == num14)
				{
					text = names[num13] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num12 -= num14;
				}
			}
			if (num12 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.Int32:
		{
			int num15 = (int)value;
			for (int num16 = values.Length - 1; num16 >= 0; num16--)
			{
				int num17 = (int)values.GetValue(num16);
				if (num17 != 0 && (num15 & num17) == num17)
				{
					text = names[num16] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num15 -= num17;
				}
			}
			if (num15 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.UInt32:
		{
			uint num4 = (uint)value;
			for (int num5 = values.Length - 1; num5 >= 0; num5--)
			{
				uint num6 = (uint)values.GetValue(num5);
				if (num6 != 0 && (num4 & num6) == num6)
				{
					text = names[num5] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num4 -= num6;
				}
			}
			if (num4 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.Int64:
		{
			long num9 = (long)value;
			for (int num10 = values.Length - 1; num10 >= 0; num10--)
			{
				long num11 = (long)values.GetValue(num10);
				if (num11 != 0 && (num9 & num11) == num11)
				{
					text = names[num10] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num9 -= num11;
				}
			}
			if (num9 != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		case TypeCode.UInt64:
		{
			ulong num = (ulong)value;
			for (int num2 = values.Length - 1; num2 >= 0; num2--)
			{
				ulong num3 = (ulong)values.GetValue(num2);
				if (num3 != 0 && (num & num3) == num3)
				{
					text = names[num2] + ((!(text == string.Empty)) ? ", " : string.Empty) + text;
					num -= num3;
				}
			}
			if (num != 0)
			{
				__result = text2;
				return;
			}
			break;
		}
		}
		if (text == string.Empty)
		{
			__result = text2;
		}
		else
		{
			__result = text;
		}
	}

	public static void SetSharedData(string guid, string name, object value)
	{
		if (!sharedData.TryGetValue(guid, out var value2))
		{
			value2 = new Dictionary<string, object>();
			sharedData.Add(guid, value2);
		}
		if (value2.ContainsKey(name))
		{
			value2[name] = value;
		}
		else
		{
			value2.Add(name, value);
		}
	}

	public static bool TryGetSharedData<T>(string guid, string name, out T value)
	{
		if (!TryGetSharedData(guid, name, out var value2))
		{
			value = default(T);
			return false;
		}
		if (value2 is T val)
		{
			value = val;
			return true;
		}
		value = default(T);
		return false;
	}

	public static bool TryGetSharedData(string guid, string name, out object value)
	{
		if (sharedData.TryGetValue(guid, out var value2) && value2.TryGetValue(name, out value))
		{
			return true;
		}
		value = null;
		return false;
	}

	public static T GetSharedData<T>(string guid, string name)
	{
		TryGetSharedData(guid, name, out T value);
		return value;
	}

	public static object GetSharedData(string guid, string name)
	{
		TryGetSharedData(guid, name, out var value);
		return value;
	}
}
[fsObject]
internal class ExtendedEnumCache
{
	private static ExtendedEnumCache _instance;

	[fsProperty]
	public List<GungeonFlags> extendedFlags = new List<GungeonFlags>();

	[fsProperty]
	public List<KeyValuePair<ValidTilesets, string>> extendedValidTilesets = new List<KeyValuePair<ValidTilesets, string>>();

	[fsProperty]
	public Dictionary<PlayableCharacters, List<KeyValuePair<TrackedStats, float>>> extendedPlayersTrackedStats = new Dictionary<PlayableCharacters, List<KeyValuePair<TrackedStats, float>>>();

	[fsProperty]
	public Dictionary<PlayableCharacters, List<KeyValuePair<TrackedMaximums, float>>> extendedPlayersTrackedMaximums = new Dictionary<PlayableCharacters, List<KeyValuePair<TrackedMaximums, float>>>();

	[fsProperty]
	public Dictionary<PlayableCharacters, List<CharacterSpecificGungeonFlags>> extendedPlayersCharacterFlags = new Dictionary<PlayableCharacters, List<CharacterSpecificGungeonFlags>>();

	public static SaveType EnumCacheSave = new SaveType
	{
		filePattern = "Slot{0}.enumCache",
		backupCount = 3,
		backupPattern = "Slot{0}.enumCacheBackup.{1}",
		backupMinTimeMin = 45
	};

	public static ExtendedEnumCache Instance => _instance ?? (_instance = Load());

	public static ExtendedEnumCache Load()
	{
		SaveManager.Init();
		if (!SaveManager.Load<ExtendedEnumCache>(EnumCacheSave, ref _instance, true, 0u, (Func<string, uint, string>)null, (SaveSlot?)null))
		{
			_instance = new ExtendedEnumCache();
		}
		return _instance;
	}

	public static void Save()
	{
		SaveManager.Init();
		try
		{
			SaveManager.Save<ExtendedEnumCache>(Instance, EnumCacheSave, (GameStatsManager.Instance != null) ? GameStatsManager.Instance.PlaytimeMin : 0, 0u, (SaveSlot?)null);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("Failed saving enum cache: " + ex));
		}
	}
}
public struct GuidInfo
{
	public string guid;

	public string info;

	public GuidInfo(string guid, string info)
	{
		this.guid = guid;
		this.info = info;
	}

	public override string ToString()
	{
		return guid + "." + info;
	}
}
[HarmonyPatch]
public class ItemDB
{
	public List<PickupObject> ModItems = new List<PickupObject>();

	public Dictionary<string, PickupObject> ModItemMap = new Dictionary<string, PickupObject>();

	public Dictionary<string, List<WeightedGameObject>> ModLootPerFloor = new Dictionary<string, List<WeightedGameObject>>();

	public tk2dSpriteCollectionData WeaponCollection = ETGMod.Assets.Collections.Find((tk2dSpriteCollectionData x) => x.spriteCollectionName == "WeaponCollection");

	public tk2dSpriteCollectionData WeaponCollection02 = ETGMod.Assets.Collections.Find((tk2dSpriteCollectionData x) => x.spriteCollectionName == "WeaponCollection02");

	public tk2dSpriteCollectionData ProjectileCollection = ETGMod.Assets.Collections.Find((tk2dSpriteCollectionData x) => x.spriteCollectionName == "ProjectileCollection");

	public tk2dSpriteCollectionData ItemCollection = ETGMod.Assets.Collections.Find((tk2dSpriteCollectionData x) => x.spriteCollectionName == "ItemCollection");

	private Gun _GunGivenPrototype;

	public PickupObject this[int id] => ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).InternalGetById(id);

	public PickupObject this[string name] => ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).InternalGetByName(name);

	public int Count => ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects.Count;

	public int AddSpecific(bool proxy, PickupObject value, bool dontDestroyOnLoad = false, string floor = "ANY")
	{
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		int count = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects.Count;
		((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects.Add(value);
		ModItems.Add(value);
		if ((Object)(object)value != (Object)null)
		{
			if (dontDestroyOnLoad)
			{
				Object.DontDestroyOnLoad((Object)(object)((Component)value).gameObject);
			}
			ModItemMap[((Object)value).name] = value;
			value.PickupObjectId = count;
			if ((Object)(object)((BraveBehaviour)value).encounterTrackable != (Object)null)
			{
				((BraveBehaviour)value).encounterTrackable.EncounterGuid = ((BraveBehaviour)value).encounterTrackable.EncounterGuid.RemoveUnacceptableCharactersForGUID();
				EncounterDatabaseEntry val = new EncounterDatabaseEntry(((BraveBehaviour)value).encounterTrackable);
				((AssetBundleDatabaseEntry)val).myGuid = ((BraveBehaviour)value).encounterTrackable.EncounterGuid;
				if (proxy)
				{
					val.ProxyEncounterGuid = ((AssetBundleDatabaseEntry)val).myGuid;
				}
				((AssetBundleDatabaseEntry)val).path = "Assets/Resources/ITEMDB:" + ((Object)value).name + ".prefab";
				((AssetBundleDatabase<EncounterTrackable, EncounterDatabaseEntry>)(object)EncounterDatabase.Instance).Entries.Add(val);
			}
			WeightedGameObject val2 = new WeightedGameObject();
			val2.weight = 1f;
			val2.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val3 = val2;
			val3.SetGameObject(((Component)value).gameObject);
			if (value is Gun)
			{
				GameManager.Instance.RewardManager.GunsLootTable.defaultItemDrops.Add(val3);
			}
			else
			{
				GameManager.Instance.RewardManager.ItemsLootTable.defaultItemDrops.Add(val3);
			}
			if (!ModLootPerFloor.TryGetValue(floor, out var value2))
			{
				value2 = new List<WeightedGameObject>();
			}
			value2.Add(val3);
			ModLootPerFloor[floor] = value2;
		}
		return count;
	}

	public int AddSpecific(PickupObject value, bool dontDestroyOnLoad = false, string floor = "ANY")
	{
		return AddSpecific(proxy: true, value, dontDestroyOnLoad, floor);
	}

	public int Add(PickupObject value, bool updateSpriteCollections = false, string floor = "ANY")
	{
		return AddSpecific(value, dontDestroyOnLoad: true, floor);
	}

	public int Add(Gun value, tk2dSpriteCollectionData collection = null, string floor = "ANY")
	{
		return Add((PickupObject)(object)value, updateSpriteCollections: false, floor);
	}

	[HarmonyPatch(typeof(Dungeon), "Start")]
	[HarmonyPrefix]
	private static void DungeonStart()
	{
		if (ETGMod.Databases.Items?.ModLootPerFloor == null || !GameManager.HasInstance || !((Object)(object)GameManager.Instance.Dungeon != (Object)null) || !((Object)(object)GameManager.Instance.Dungeon.baseChestContents != (Object)null) || GameManager.Instance.Dungeon.baseChestContents.defaultItemDrops == null || GameManager.Instance.Dungeon.baseChestContents.defaultItemDrops.elements == null)
		{
			return;
		}
		if (ETGMod.Databases.Items.ModLootPerFloor.TryGetValue("ANY", out var value))
		{
			GameManager.Instance.Dungeon.baseChestContents.defaultItemDrops.elements.AddRange(value);
		}
		string dungeonFloorName = GameManager.Instance.Dungeon.DungeonFloorName;
		if (!string.IsNullOrEmpty(dungeonFloorName))
		{
			string text = null;
			int num = 0;
			if (dungeonFloorName.StartsWith("#"))
			{
				num = 1;
			}
			if (dungeonFloorName.Contains("_") && dungeonFloorName.IndexOf('_') - num > 0)
			{
				text = dungeonFloorName.Substring(num, dungeonFloorName.IndexOf('_') - num);
			}
			else if (dungeonFloorName.Length - num > 0)
			{
				text = dungeonFloorName.Substring(num);
			}
			if (!string.IsNullOrEmpty(text) && ETGMod.Databases.Items.ModLootPerFloor.TryGetValue(text, out value))
			{
				GameManager.Instance.Dungeon.baseChestContents.defaultItemDrops.elements.AddRange(value);
			}
		}
	}

	public Gun NewGun(string gunName, string gunNameShort = null)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		if ((Object)(object)_GunGivenPrototype == (Object)null)
		{
			_GunGivenPrototype = (Gun)ETGMod.Databases.Items["Pea_Shooter"];
			ProjectileCollection = ((Component)_GunGivenPrototype.DefaultModule.projectiles[0]).GetComponentInChildren<tk2dBaseSprite>().Collection;
		}
		return NewGun(gunName, _GunGivenPrototype, gunNameShort);
	}

	public Gun NewGun(string gunName, Gun baseGun, string gunNameShort = null)
	{
		if (gunNameShort == null)
		{
			gunNameShort = gunName.Replace(' ', '_');
		}
		GameObject val = Object.Instantiate<GameObject>(((Component)baseGun).gameObject);
		((Object)val).name = gunNameShort;
		Gun component = val.GetComponent<Gun>();
		SetupItem((PickupObject)(object)component, gunName);
		component.gunName = gunName;
		component.gunSwitchGroup = gunNameShort;
		component.modifiedVolley = null;
		component.singleModule = null;
		component.RawSourceVolley = ScriptableObject.CreateInstance<ProjectileVolleyData>();
		component.Volley.projectiles = new List<ProjectileModule>();
		component.SetBaseMaxAmmo(300);
		component.reloadTime = 0.625f;
		Game.Items.Add("outdated_gun_mods:" + gunName.ToID(), (PickupObject)(object)component);
		return component;
	}

	public void SetupItem(PickupObject item, string name)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		if ((Object)(object)((BraveBehaviour)item).encounterTrackable == (Object)null)
		{
			((BraveBehaviour)item).encounterTrackable = ((Component)item).gameObject.AddComponent<EncounterTrackable>();
		}
		if (((BraveBehaviour)item).encounterTrackable.journalData == null)
		{
			((BraveBehaviour)item).encounterTrackable.journalData = new JournalEntry();
		}
		((BraveBehaviour)item).encounterTrackable.EncounterGuid = ((Object)item).name;
		((BraveBehaviour)item).encounterTrackable.prerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
		((BraveBehaviour)item).encounterTrackable.journalData.SuppressKnownState = false;
		string text = "#" + ((Object)item).name.Replace(" ", "").ToUpperInvariant();
		((BraveBehaviour)item).encounterTrackable.journalData.PrimaryDisplayName = text + "_ENCNAME";
		((BraveBehaviour)item).encounterTrackable.journalData.NotificationPanelDescription = text + "_SHORTDESC";
		((BraveBehaviour)item).encounterTrackable.journalData.AmmonomiconFullEntry = text + "_LONGDESC";
		((BraveBehaviour)item).encounterTrackable.journalData.AmmonomiconSprite = ((Object)item).name.Replace(' ', '_') + "_idle_001";
		item.SetName(name);
	}

	public PickupObject GetModItemByName(string name)
	{
		if (ModItemMap.TryGetValue(name, out var value))
		{
			return value;
		}
		return null;
	}
}
[HarmonyPatch]
public class StringDB
{
	public readonly StringDBTable Core = new StringDBTable(() => StringTableManager.CoreTable);

	public readonly StringDBTable Items = new StringDBTable(() => StringTableManager.ItemTable);

	public readonly StringDBTable Enemies = new StringDBTable(() => StringTableManager.EnemyTable);

	public readonly StringDBTable Intro = new StringDBTable(() => StringTableManager.IntroTable);

	public readonly StringDBTable Synergy = new StringDBTable(() => SynergyTable);

	public readonly UIStringDBTable UI = new UIStringDBTable();

	public Action<GungeonSupportedLanguages> OnLanguageChanged;

	public Action<dfLanguageManager, dfLanguageCode> OnUILanguageChanged;

	public GungeonSupportedLanguages CurrentLanguage
	{
		get
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			return GameManager.Options.CurrentLanguage;
		}
		set
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			StringTableManager.SetNewLanguage(value, true);
		}
	}

	public static Dictionary<string, StringCollection> SynergyTable
	{
		get
		{
			if (StringTableManager.m_synergyTable == null)
			{
				StringTableManager.m_synergyTable = StringTableManager.LoadSynergyTable(StringTableManager.m_currentSubDirectory);
			}
			if (StringTableManager.m_backupSynergyTable == null)
			{
				StringTableManager.m_backupSynergyTable = StringTableManager.LoadSynergyTable("english_items");
			}
			return StringTableManager.m_synergyTable;
		}
	}

	[HarmonyPatch(typeof(StringTableManager), "SetNewLanguage")]
	[HarmonyPostfix]
	private static void LanguageChanged()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		ETGMod.Databases.Strings.Core.LanguageChanged();
		ETGMod.Databases.Strings.Items.LanguageChanged();
		ETGMod.Databases.Strings.Enemies.LanguageChanged();
		ETGMod.Databases.Strings.Intro.LanguageChanged();
		ETGMod.Databases.Strings.OnLanguageChanged?.Invoke(ETGMod.Databases.Strings.CurrentLanguage);
	}

	[HarmonyPatch(typeof(dfLanguageManager), "LoadLanguage")]
	[HarmonyPostfix]
	private static void UILanguageChanged(dfLanguageManager __instance, dfLanguageCode language, bool forceReload)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		ETGMod.Databases.Strings.UI.LanguageChanged(__instance);
		ETGMod.Databases.Strings.OnUILanguageChanged?.Invoke(__instance, language);
		if (forceReload)
		{
			dfControl[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<dfControl>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].Localize();
			}
			for (int j = 0; j < componentsInChildren.Length; j++)
			{
				componentsInChildren[j].PerformLayout();
				componentsInChildren[j].LanguageChanged?.Invoke(componentsInChildren[j]);
			}
		}
	}
}
public sealed class StringDBTable
{
	private readonly Func<Dictionary<string, StringCollection>> _getTable;

	private readonly Dictionary<string, StringCollection> _changes;

	private Dictionary<string, StringCollection> _cachedTable;

	public Dictionary<string, StringCollection> Table => _cachedTable ?? (_cachedTable = _getTable());

	public StringCollection this[string key]
	{
		get
		{
			return Table[key];
		}
		set
		{
			Table[key] = value;
			_changes[key] = value;
			JournalEntry.ReloadDataSemaphore += 1;
		}
	}

	public StringDBTable(Func<Dictionary<string, StringCollection>> getTable)
	{
		_getTable = getTable;
		_changes = new Dictionary<string, StringCollection>();
	}

	public bool ContainsKey(string key)
	{
		return Table.ContainsKey(key);
	}

	public void Set(string key, string value)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		SimpleStringCollection val = new SimpleStringCollection();
		((StringCollection)val).AddString(value, 1f);
		this[key] = (StringCollection)(object)val;
	}

	public void SetComplex(string key, params string[] values)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		ComplexStringCollection collection = new ComplexStringCollection();
		CollectionExtensions.Do<string>((IEnumerable<string>)values, (Action<string>)delegate(string x)
		{
			((StringCollection)collection).AddString(x, 1f);
		});
		this[key] = (StringCollection)(object)collection;
	}

	public void SetComplex(string key, params Tuple<string, float>[] values)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		ComplexStringCollection collection = new ComplexStringCollection();
		CollectionExtensions.Do<Tuple<string, float>>((IEnumerable<Tuple<string, float>>)values, (Action<Tuple<string, float>>)delegate(Tuple<string, float> x)
		{
			((StringCollection)collection).AddString(x.First, x.Second);
		});
		this[key] = (StringCollection)(object)collection;
	}

	public void LanguageChanged()
	{
		_cachedTable = null;
		Dictionary<string, StringCollection> table = Table;
		foreach (KeyValuePair<string, StringCollection> change in _changes)
		{
			table[change.Key] = change.Value;
		}
	}
}
public sealed class UIStringDBTable
{
	private readonly Dictionary<string, string> _changes = new Dictionary<string, string>();

	public void LanguageChanged(dfLanguageManager man)
	{
		foreach (KeyValuePair<string, string> change in _changes)
		{
			man.strings[change.Key] = change.Value;
		}
	}

	public void Set(string key, string value)
	{
		if (dfGUIManager.activeInstances != null)
		{
			foreach (dfGUIManager activeManager in dfGUIManager.ActiveManagers)
			{
				if ((Object)(object)activeManager != (Object)null)
				{
					dfLanguageManager component = ((Component)activeManager).GetComponent<dfLanguageManager>();
					if ((Object)(object)component != (Object)null)
					{
						component.strings[key] = value;
					}
				}
			}
		}
		_changes[key] = value;
	}
}
public class AutocompletionSettings
{
	public Func<int, string, string[]> Match;

	public static bool MatchContains = true;

	public AutocompletionSettings(Func<string, string[]> match)
	{
		Match = (int index, string key) => (index == 0) ? match(key) : new string[0];
	}

	public AutocompletionSettings(Func<int, string, string[]> match)
	{
		Match = match;
	}
}
public static class StringAutocompletionExtensions
{
	public static bool AutocompletionMatch(this string text, string match)
	{
		if (AutocompletionSettings.MatchContains)
		{
			return text.Contains(match);
		}
		return text.StartsWith(match);
	}
}
public class ConsoleCommand : ConsoleCommandUnit
{
	private string[] _EmptyStringArray = new string[0];

	public ConsoleCommand(Action<string[]> cmdref, AutocompletionSettings autocompletion)
	{
		CommandReference = cmdref;
		Autocompletion = autocompletion;
	}

	public ConsoleCommand(Action<string[]> cmdref)
	{
		CommandReference = cmdref;
		Autocompletion = new AutocompletionSettings((string input) => _EmptyStringArray);
	}
}
public class ConsoleCommandGroup : ConsoleCommandUnit
{
	public class UnitSearchResult
	{
		public int index = -1;

		public ConsoleCommandUnit unit;

		public UnitSearchResult(int index, ConsoleCommandUnit unit)
		{
			this.index = index;
			this.unit = unit;
		}

		public UnitSearchResult()
		{
		}
	}

	private Dictionary<string, ConsoleCommand> _Commands = new Dictionary<string, ConsoleCommand>();

	private Dictionary<string, ConsoleCommandGroup> _Groups = new Dictionary<string, ConsoleCommandGroup>();

	public AutocompletionSettings additionalAutocompletion;

	private AutocompletionSettings _CreateDefaultAutocompletion()
	{
		return new AutocompletionSettings(delegate(string input)
		{
			string[] allUnitNames = GetAllUnitNames();
			List<string> list = new List<string>();
			foreach (string text in allUnitNames)
			{
				if (text.StartsWith(input))
				{
					list.Add(text);
				}
			}
			return list.ToArray();
		});
	}

	public ConsoleCommandGroup(Action<string[]> cmdref)
	{
		Autocompletion = _CreateDefaultAutocompletion();
		CommandReference = cmdref;
	}

	public ConsoleCommandGroup(Action<string[]> cmdref, AutocompletionSettings additionalautocompletion)
	{
		ConsoleCommandGroup consoleCommandGroup = this;
		Autocompletion = new AutocompletionSettings(delegate(int index, string keyword)
		{
			string[] array = additionalautocompletion.Match(index, keyword);
			string[] array2 = consoleCommandGroup._CreateDefaultAutocompletion().Match(index, keyword);
			return (array != null) ? array2.Concat(array).ToArray() : array2;
		});
		additionalAutocompletion = additionalautocompletion;
		CommandReference = cmdref;
	}

	public ConsoleCommandGroup()
		: this(delegate
		{
			ETGModConsole.Log("Command group does not have an assigned action");
		})
	{
	}

	public ConsoleCommandGroup AddUnit(string name, ConsoleCommand command)
	{
		command.Name = name;
		_Commands[name] = command;
		return this;
	}

	public ConsoleCommandGroup AddUnit(string name, Action<string[]> action)
	{
		ConsoleCommand consoleCommand = new ConsoleCommand(action);
		consoleCommand.Name = name;
		_Commands[name] = consoleCommand;
		return this;
	}

	public ConsoleCommandGroup AddUnit(string name, Action<string[]> action, AutocompletionSettings autocompletion)
	{
		ConsoleCommand consoleCommand = new ConsoleCommand(action, autocompletion);
		consoleCommand.Name = name;
		_Commands[name] = consoleCommand;
		return this;
	}

	public ConsoleCommandGroup AddUnit(string name, ConsoleCommandGroup group)
	{
		group.Name = name;
		_Groups[name] = group;
		return this;
	}

	public ConsoleCommandGroup AddGroup(string name)
	{
		AddUnit(name, new ConsoleCommandGroup());
		return this;
	}

	public ConsoleCommandGroup AddGroup(string name, Action<string[]> action)
	{
		AddUnit(name, new ConsoleCommandGroup(action));
		return this;
	}

	public ConsoleCommandGroup AddGroup(string name, Action<string[]> action, AutocompletionSettings autocompletion)
	{
		AddUnit(name, new ConsoleCommandGroup(action, autocompletion));
		return this;
	}

	public UnitSearchResult SearchUnit(string[] path)
	{
		ConsoleCommandGroup consoleCommandGroup = this;
		UnitSearchResult unitSearchResult = new UnitSearchResult();
		for (int i = 0; i < path.Length; i++)
		{
			ConsoleCommandGroup group = consoleCommandGroup.GetGroup(path[i]);
			ConsoleCommand command = consoleCommandGroup.GetCommand(path[i]);
			if (group != null)
			{
				consoleCommandGroup = group;
				unitSearchResult.index++;
			}
			else if (command != null)
			{
				unitSearchResult.index++;
				unitSearchResult.unit = command;
				return unitSearchResult;
			}
		}
		UnitSearchResult unitSearchResult2 = unitSearchResult;
		if (unitSearchResult2.unit == null)
		{
			unitSearchResult2.unit = consoleCommandGroup;
		}
		return unitSearchResult;
	}

	public List<List<string>> ConstructPaths()
	{
		List<List<string>> list = new List<List<string>>();
		foreach (string key in _Commands.Keys)
		{
			List<string> list2 = new List<string>();
			list2.Add(key);
			list.Add(list2);
		}
		foreach (string key2 in _Groups.Keys)
		{
			List<string> list3 = new List<string>();
			list3.Add(key2);
			list.Add(list3);
			List<List<string>> list4 = _Groups[key2].ConstructPaths();
			for (int i = 0; i < list4.Count; i++)
			{
				List<string> list5 = new List<string>();
				list5.Add(key2);
				for (int j = 0; j < list4[i].Count; j++)
				{
					list5.Add(list4[i][j]);
				}
				list.Add(list5);
			}
		}
		return list;
	}

	public string[] GetAllUnitNames()
	{
		List<string> list = new List<string>();
		foreach (string key in _Groups.Keys)
		{
			list.Add(key);
		}
		foreach (string key2 in _Commands.Keys)
		{
			list.Add(key2);
		}
		return list.ToArray();
	}

	public ConsoleCommandUnit GetUnit(string[] unit)
	{
		return SearchUnit(unit).unit;
	}

	public ConsoleCommandGroup GetGroup(string[] unit)
	{
		return SearchUnit(unit).unit as ConsoleCommandGroup;
	}

	public ConsoleCommandGroup GetGroup(string unit)
	{
		if (!_Groups.ContainsKey(unit))
		{
			return null;
		}
		return _Groups[unit];
	}

	public ConsoleCommand GetCommand(string[] unit)
	{
		return SearchUnit(unit).unit as ConsoleCommand;
	}

	public ConsoleCommand GetCommand(string name)
	{
		if (!_Commands.ContainsKey(name))
		{
			return null;
		}
		return _Commands[name];
	}

	public int GetFirstNonUnitIndexInPath(string[] path)
	{
		return SearchUnit(path).index + 1;
	}
}
public class ConsoleCommandUnit
{
	public string Name;

	public Action<string[]> CommandReference;

	public AutocompletionSettings Autocompletion;

	public void RunCommand(string[] args)
	{
		CommandReference(args);
	}
}
public static class PlayerControllerExt
{
	public static bool IsPlaying(this PlayerController player)
	{
		return (Object)(object)GameManager.Instance.PrimaryPlayer == (Object)(object)player || (Object)(object)GameManager.Instance.SecondaryPlayer == (Object)(object)player;
	}

	public static bool GiveItem(this PlayerController player, string id)
	{
		if (!player.IsPlaying())
		{
			throw new Exception("Tried to give item to inactive player controller");
		}
		LootEngine.TryGivePrefabToPlayer(((Component)Game.Items[id]).gameObject, 

plugins/MtGAPI/Newtonsoft.Json.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
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.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
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: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyTitle("Json.NET .NET 3.5")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests")]
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
[assembly: AssemblyProduct("Json.NET")]
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("6.0.1.16919")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("4.5.0.0")]
namespace Newtonsoft.Json.Bson
{
	internal enum BsonBinaryType : byte
	{
		Binary = 0,
		Function = 1,
		[Obsolete("This type has been deprecated in the BSON specification. Use Binary instead.")]
		BinaryOld = 2,
		[Obsolete("This type has been deprecated in the BSON specification. Use Uuid instead.")]
		UuidOld = 3,
		Uuid = 4,
		Md5 = 5,
		UserDefined = 128
	}
	internal class BsonBinaryWriter
	{
		private static readonly Encoding Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

		private readonly BinaryWriter _writer;

		private byte[] _largeByteBuffer;

		public DateTimeKind DateTimeKindHandling { get; set; }

		public BsonBinaryWriter(BinaryWriter writer)
		{
			DateTimeKindHandling = DateTimeKind.Utc;
			_writer = writer;
		}

		public void Flush()
		{
			_writer.Flush();
		}

		public void Close()
		{
			_writer.Close();
		}

		public void WriteToken(BsonToken t)
		{
			CalculateSize(t);
			WriteTokenInternal(t);
		}

		private void WriteTokenInternal(BsonToken t)
		{
			switch (t.Type)
			{
			case BsonType.Object:
			{
				BsonObject bsonObject = (BsonObject)t;
				_writer.Write(bsonObject.CalculatedSize);
				foreach (BsonProperty item in bsonObject)
				{
					_writer.Write((sbyte)item.Value.Type);
					WriteString((string)item.Name.Value, item.Name.ByteCount, null);
					WriteTokenInternal(item.Value);
				}
				_writer.Write((byte)0);
				break;
			}
			case BsonType.Array:
			{
				BsonArray bsonArray = (BsonArray)t;
				_writer.Write(bsonArray.CalculatedSize);
				ulong num2 = 0uL;
				foreach (BsonToken item2 in bsonArray)
				{
					_writer.Write((sbyte)item2.Type);
					WriteString(num2.ToString(CultureInfo.InvariantCulture), MathUtils.IntLength(num2), null);
					WriteTokenInternal(item2);
					num2++;
				}
				_writer.Write((byte)0);
				break;
			}
			case BsonType.Integer:
			{
				BsonValue bsonValue3 = (BsonValue)t;
				_writer.Write(Convert.ToInt32(bsonValue3.Value, CultureInfo.InvariantCulture));
				break;
			}
			case BsonType.Long:
			{
				BsonValue bsonValue4 = (BsonValue)t;
				_writer.Write(Convert.ToInt64(bsonValue4.Value, CultureInfo.InvariantCulture));
				break;
			}
			case BsonType.Number:
			{
				BsonValue bsonValue5 = (BsonValue)t;
				_writer.Write(Convert.ToDouble(bsonValue5.Value, CultureInfo.InvariantCulture));
				break;
			}
			case BsonType.String:
			{
				BsonString bsonString = (BsonString)t;
				WriteString((string)bsonString.Value, bsonString.ByteCount, bsonString.CalculatedSize - 4);
				break;
			}
			case BsonType.Boolean:
			{
				BsonValue bsonValue6 = (BsonValue)t;
				_writer.Write((bool)bsonValue6.Value);
				break;
			}
			case BsonType.Date:
			{
				BsonValue bsonValue2 = (BsonValue)t;
				long num = 0L;
				if (bsonValue2.Value is DateTime)
				{
					DateTime dateTime = (DateTime)bsonValue2.Value;
					if (DateTimeKindHandling == DateTimeKind.Utc)
					{
						dateTime = dateTime.ToUniversalTime();
					}
					else if (DateTimeKindHandling == DateTimeKind.Local)
					{
						dateTime = dateTime.ToLocalTime();
					}
					num = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(dateTime, convertToUtc: false);
				}
				else
				{
					DateTimeOffset dateTimeOffset = (DateTimeOffset)bsonValue2.Value;
					num = DateTimeUtils.ConvertDateTimeToJavaScriptTicks(dateTimeOffset.UtcDateTime, dateTimeOffset.Offset);
				}
				_writer.Write(num);
				break;
			}
			case BsonType.Binary:
			{
				BsonBinary bsonBinary = (BsonBinary)t;
				byte[] array = (byte[])bsonBinary.Value;
				_writer.Write(array.Length);
				_writer.Write((byte)bsonBinary.BinaryType);
				_writer.Write(array);
				break;
			}
			case BsonType.Oid:
			{
				BsonValue bsonValue = (BsonValue)t;
				byte[] buffer = (byte[])bsonValue.Value;
				_writer.Write(buffer);
				break;
			}
			case BsonType.Regex:
			{
				BsonRegex bsonRegex = (BsonRegex)t;
				WriteString((string)bsonRegex.Pattern.Value, bsonRegex.Pattern.ByteCount, null);
				WriteString((string)bsonRegex.Options.Value, bsonRegex.Options.ByteCount, null);
				break;
			}
			default:
				throw new ArgumentOutOfRangeException("t", "Unexpected token when writing BSON: {0}".FormatWith(CultureInfo.InvariantCulture, t.Type));
			case BsonType.Undefined:
			case BsonType.Null:
				break;
			}
		}

		private void WriteString(string s, int byteCount, int? calculatedlengthPrefix)
		{
			if (calculatedlengthPrefix.HasValue)
			{
				_writer.Write(calculatedlengthPrefix.Value);
			}
			WriteUtf8Bytes(s, byteCount);
			_writer.Write((byte)0);
		}

		public void WriteUtf8Bytes(string s, int byteCount)
		{
			if (s != null)
			{
				if (_largeByteBuffer == null)
				{
					_largeByteBuffer = new byte[256];
				}
				if (byteCount <= 256)
				{
					Encoding.GetBytes(s, 0, s.Length, _largeByteBuffer, 0);
					_writer.Write(_largeByteBuffer, 0, byteCount);
				}
				else
				{
					byte[] bytes = Encoding.GetBytes(s);
					_writer.Write(bytes);
				}
			}
		}

		private int CalculateSize(int stringByteCount)
		{
			return stringByteCount + 1;
		}

		private int CalculateSizeWithLength(int stringByteCount, bool includeSize)
		{
			int num = ((!includeSize) ? 1 : 5);
			return num + stringByteCount;
		}

		private int CalculateSize(BsonToken t)
		{
			switch (t.Type)
			{
			case BsonType.Object:
			{
				BsonObject bsonObject = (BsonObject)t;
				int num4 = 4;
				foreach (BsonProperty item in bsonObject)
				{
					int num5 = 1;
					num5 += CalculateSize(item.Name);
					num5 += CalculateSize(item.Value);
					num4 += num5;
				}
				return bsonObject.CalculatedSize = num4 + 1;
			}
			case BsonType.Array:
			{
				BsonArray bsonArray = (BsonArray)t;
				int num2 = 4;
				ulong num3 = 0uL;
				foreach (BsonToken item2 in bsonArray)
				{
					num2++;
					num2 += CalculateSize(MathUtils.IntLength(num3));
					num2 += CalculateSize(item2);
					num3++;
				}
				num2++;
				bsonArray.CalculatedSize = num2;
				return bsonArray.CalculatedSize;
			}
			case BsonType.Integer:
				return 4;
			case BsonType.Long:
				return 8;
			case BsonType.Number:
				return 8;
			case BsonType.String:
			{
				BsonString bsonString = (BsonString)t;
				string text = (string)bsonString.Value;
				bsonString.ByteCount = ((text != null) ? Encoding.GetByteCount(text) : 0);
				bsonString.CalculatedSize = CalculateSizeWithLength(bsonString.ByteCount, bsonString.IncludeLength);
				return bsonString.CalculatedSize;
			}
			case BsonType.Boolean:
				return 1;
			case BsonType.Undefined:
			case BsonType.Null:
				return 0;
			case BsonType.Date:
				return 8;
			case BsonType.Binary:
			{
				BsonBinary bsonBinary = (BsonBinary)t;
				byte[] array = (byte[])bsonBinary.Value;
				bsonBinary.CalculatedSize = 5 + array.Length;
				return bsonBinary.CalculatedSize;
			}
			case BsonType.Oid:
				return 12;
			case BsonType.Regex:
			{
				BsonRegex bsonRegex = (BsonRegex)t;
				int num = 0;
				num += CalculateSize(bsonRegex.Pattern);
				num += CalculateSize(bsonRegex.Options);
				bsonRegex.CalculatedSize = num;
				return bsonRegex.CalculatedSize;
			}
			default:
				throw new ArgumentOutOfRangeException("t", "Unexpected token when writing BSON: {0}".FormatWith(CultureInfo.InvariantCulture, t.Type));
			}
		}
	}
}
namespace Newtonsoft.Json
{
	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;

		internal ReadType _readType;

		private JsonPosition _currentPosition;

		private CultureInfo _culture;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private int? _maxDepth;

		private bool _hasExceededMaxDepth;

		internal DateParseHandling _dateParseHandling;

		internal FloatParseHandling _floatParseHandling;

		private readonly 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
			{
				_dateTimeZoneHandling = value;
			}
		}

		public DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling;
			}
			set
			{
				_dateParseHandling = value;
			}
		}

		public FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling;
			}
			set
			{
				_floatParseHandling = 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
		{
			get
			{
				if (_value == null)
				{
					return null;
				}
				return _value.GetType();
			}
		}

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

		public virtual string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				IEnumerable<JsonPosition> positions = ((_currentState == State.ArrayStart || _currentState == State.ConstructorStart || _currentState == State.ObjectStart) ? _stack : _stack.Concat(new JsonPosition[1] { _currentPosition }));
				return JsonPosition.BuildPath(positions);
			}
		}

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

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

		protected JsonReader()
		{
			_currentState = State.Start;
			_stack = new List<JsonPosition>(4);
			_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
			_dateParseHandling = DateParseHandling.DateTime;
			_floatParseHandling = FloatParseHandling.Double;
			CloseInput = true;
		}

		private void Push(JsonContainerType value)
		{
			UpdateScopeWithFinishedValue();
			if (_currentPosition.Type == JsonContainerType.None)
			{
				_currentPosition = new JsonPosition(value);
				return;
			}
			_stack.Add(_currentPosition);
			_currentPosition = new JsonPosition(value);
			if (_maxDepth.HasValue)
			{
				int num = Depth + 1;
				int? maxDepth = _maxDepth;
				if (num > maxDepth.GetValueOrDefault() && maxDepth.HasValue && !_hasExceededMaxDepth)
				{
					_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.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 abstract int? ReadAsInt32();

		public abstract string ReadAsString();

		public abstract byte[] ReadAsBytes();

		public abstract decimal? ReadAsDecimal();

		public abstract DateTime? ReadAsDateTime();

		public abstract DateTimeOffset? ReadAsDateTimeOffset();

		internal virtual bool ReadInternal()
		{
			throw new NotImplementedException();
		}

		internal DateTimeOffset? ReadAsDateTimeOffsetInternal()
		{
			_readType = ReadType.ReadAsDateTimeOffset;
			while (ReadInternal())
			{
				JsonToken tokenType = TokenType;
				switch (tokenType)
				{
				case JsonToken.Comment:
					break;
				case JsonToken.Date:
					if (Value is DateTime)
					{
						SetToken(JsonToken.Date, new DateTimeOffset((DateTime)Value));
					}
					return (DateTimeOffset)Value;
				case JsonToken.Null:
					return null;
				case JsonToken.String:
				{
					string text = (string)Value;
					if (string.IsNullOrEmpty(text))
					{
						SetToken(JsonToken.Null);
						return null;
					}
					if (DateTimeOffset.TryParse(text, Culture, DateTimeStyles.RoundtripKind, out var result))
					{
						SetToken(JsonToken.Date, result);
						return result;
					}
					throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
				}
				case JsonToken.EndArray:
					return null;
				default:
					throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, tokenType));
				}
			}
			SetToken(JsonToken.None);
			return null;
		}

		internal byte[] ReadAsBytesInternal()
		{
			_readType = ReadType.ReadAsBytes;
			JsonToken tokenType;
			do
			{
				if (!ReadInternal())
				{
					SetToken(JsonToken.None);
					return null;
				}
				tokenType = TokenType;
			}
			while (tokenType == JsonToken.Comment);
			if (IsWrappedInTypeObject())
			{
				byte[] array = ReadAsBytes();
				ReadInternal();
				SetToken(JsonToken.Bytes, array);
				return array;
			}
			switch (tokenType)
			{
			case JsonToken.String:
			{
				string text = (string)Value;
				byte[] array3 = ((text.Length == 0) ? new byte[0] : Convert.FromBase64String(text));
				SetToken(JsonToken.Bytes, array3);
				return array3;
			}
			case JsonToken.Null:
				return null;
			case JsonToken.Bytes:
				return (byte[])Value;
			case JsonToken.StartArray:
			{
				List<byte> list = new List<byte>();
				while (ReadInternal())
				{
					tokenType = TokenType;
					switch (tokenType)
					{
					case JsonToken.Integer:
						list.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
						break;
					case JsonToken.EndArray:
					{
						byte[] array2 = list.ToArray();
						SetToken(JsonToken.Bytes, array2);
						return array2;
					}
					default:
						throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, tokenType));
					case JsonToken.Comment:
						break;
					}
				}
				throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
			}
			case JsonToken.EndArray:
				return null;
			default:
				throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, tokenType));
			}
		}

		internal decimal? ReadAsDecimalInternal()
		{
			_readType = ReadType.ReadAsDecimal;
			while (ReadInternal())
			{
				JsonToken tokenType = TokenType;
				switch (tokenType)
				{
				case JsonToken.Comment:
					break;
				case JsonToken.Integer:
				case JsonToken.Float:
					if (!(Value is decimal))
					{
						SetToken(JsonToken.Float, Convert.ToDecimal(Value, CultureInfo.InvariantCulture));
					}
					return (decimal)Value;
				case JsonToken.Null:
					return null;
				case JsonToken.String:
				{
					string text = (string)Value;
					if (string.IsNullOrEmpty(text))
					{
						SetToken(JsonToken.Null);
						return null;
					}
					if (decimal.TryParse(text, NumberStyles.Number, Culture, out var result))
					{
						SetToken(JsonToken.Float, result);
						return result;
					}
					throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
				}
				case JsonToken.EndArray:
					return null;
				default:
					throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, tokenType));
				}
			}
			SetToken(JsonToken.None);
			return null;
		}

		internal int? ReadAsInt32Internal()
		{
			_readType = ReadType.ReadAsInt32;
			while (ReadInternal())
			{
				switch (TokenType)
				{
				case JsonToken.Comment:
					break;
				case JsonToken.Integer:
				case JsonToken.Float:
					if (!(Value is int))
					{
						SetToken(JsonToken.Integer, Convert.ToInt32(Value, CultureInfo.InvariantCulture));
					}
					return (int)Value;
				case JsonToken.Null:
					return null;
				case JsonToken.String:
				{
					string text = (string)Value;
					if (string.IsNullOrEmpty(text))
					{
						SetToken(JsonToken.Null);
						return null;
					}
					if (int.TryParse(text, NumberStyles.Integer, Culture, out var result))
					{
						SetToken(JsonToken.Integer, result);
						return result;
					}
					throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
				}
				case JsonToken.EndArray:
					return null;
				default:
					throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
				}
			}
			SetToken(JsonToken.None);
			return null;
		}

		internal string ReadAsStringInternal()
		{
			_readType = ReadType.ReadAsString;
			while (ReadInternal())
			{
				JsonToken tokenType = TokenType;
				switch (tokenType)
				{
				case JsonToken.Comment:
					continue;
				case JsonToken.String:
					return (string)Value;
				case JsonToken.Null:
					return null;
				}
				if (IsPrimitiveToken(tokenType) && Value != null)
				{
					string text = ((!(Value is IFormattable)) ? Value.ToString() : ((IFormattable)Value).ToString(null, Culture));
					SetToken(JsonToken.String, text);
					return text;
				}
				if (tokenType == JsonToken.EndArray)
				{
					return null;
				}
				throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, tokenType));
			}
			SetToken(JsonToken.None);
			return null;
		}

		internal DateTime? ReadAsDateTimeInternal()
		{
			_readType = ReadType.ReadAsDateTime;
			do
			{
				if (!ReadInternal())
				{
					SetToken(JsonToken.None);
					return null;
				}
			}
			while (TokenType == JsonToken.Comment);
			if (TokenType == JsonToken.Date)
			{
				return (DateTime)Value;
			}
			if (TokenType == JsonToken.Null)
			{
				return null;
			}
			if (TokenType == JsonToken.String)
			{
				string text = (string)Value;
				if (string.IsNullOrEmpty(text))
				{
					SetToken(JsonToken.Null);
					return null;
				}
				if (DateTime.TryParse(text, Culture, DateTimeStyles.RoundtripKind, out var result))
				{
					result = DateTimeUtils.EnsureDateTime(result, DateTimeZoneHandling);
					SetToken(JsonToken.Date, result);
					return result;
				}
				throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
			}
			if (TokenType == JsonToken.EndArray)
			{
				return null;
			}
			throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
		}

		private bool IsWrappedInTypeObject()
		{
			_readType = ReadType.Read;
			if (TokenType == JsonToken.StartObject)
			{
				if (!ReadInternal())
				{
					throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
				}
				if (Value.ToString() == "$type")
				{
					ReadInternal();
					if (Value != null && Value.ToString().StartsWith("System.Byte[]"))
					{
						ReadInternal();
						if (Value.ToString() == "$value")
						{
							return true;
						}
					}
				}
				throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject));
			}
			return false;
		}

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

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

		protected void SetToken(JsonToken newToken, object value)
		{
			_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:
				if (Peek() != 0)
				{
					_currentState = State.PostValue;
				}
				else
				{
					SetFinished();
				}
				UpdateScopeWithFinishedValue();
				break;
			case JsonToken.Comment:
				break;
			}
		}

		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)
			{
				_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()
		{
			if (SupportMultipleContent)
			{
				_currentState = State.Start;
			}
			else
			{
				_currentState = State.Finished;
			}
		}

		internal static bool IsPrimitiveToken(JsonToken token)
		{
			switch (token)
			{
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				return true;
			default:
				return false;
			}
		}

		internal static bool IsStartToken(JsonToken token)
		{
			switch (token)
			{
			case JsonToken.StartObject:
			case JsonToken.StartArray:
			case JsonToken.StartConstructor:
				return true;
			default:
				return false;
			}
		}

		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);
		}

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

		public virtual void Close()
		{
			_currentState = State.Closed;
			_tokenType = JsonToken.None;
			_value = null;
		}
	}
}
namespace Newtonsoft.Json.Bson
{
	public class BsonReader : JsonReader
	{
		private enum BsonReaderState
		{
			Normal,
			ReferenceStart,
			ReferenceRef,
			ReferenceId,
			CodeWScopeStart,
			CodeWScopeCode,
			CodeWScopeScope,
			CodeWScopeScopeObject,
			CodeWScopeScopeEnd
		}

		private class ContainerContext
		{
			public readonly BsonType Type;

			public int Length;

			public int Position;

			public ContainerContext(BsonType type)
			{
				Type = type;
			}
		}

		private const int MaxCharBytesSize = 128;

		private static readonly byte[] SeqRange1 = new byte[2] { 0, 127 };

		private static readonly byte[] SeqRange2 = new byte[2] { 194, 223 };

		private static readonly byte[] SeqRange3 = new byte[2] { 224, 239 };

		private static readonly byte[] SeqRange4 = new byte[2] { 240, 244 };

		private readonly BinaryReader _reader;

		private readonly List<ContainerContext> _stack;

		private byte[] _byteBuffer;

		private char[] _charBuffer;

		private BsonType _currentElementType;

		private BsonReaderState _bsonReaderState;

		private ContainerContext _currentContext;

		private bool _readRootValueAsArray;

		private bool _jsonNet35BinaryCompatibility;

		private DateTimeKind _dateTimeKindHandling;

		[Obsolete("JsonNet35BinaryCompatibility will be removed in a future version of Json.NET.")]
		public bool JsonNet35BinaryCompatibility
		{
			get
			{
				return _jsonNet35BinaryCompatibility;
			}
			set
			{
				_jsonNet35BinaryCompatibility = value;
			}
		}

		public bool ReadRootValueAsArray
		{
			get
			{
				return _readRootValueAsArray;
			}
			set
			{
				_readRootValueAsArray = value;
			}
		}

		public DateTimeKind DateTimeKindHandling
		{
			get
			{
				return _dateTimeKindHandling;
			}
			set
			{
				_dateTimeKindHandling = value;
			}
		}

		public BsonReader(Stream stream)
			: this(stream, readRootValueAsArray: false, DateTimeKind.Local)
		{
		}

		public BsonReader(BinaryReader reader)
			: this(reader, readRootValueAsArray: false, DateTimeKind.Local)
		{
		}

		public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
		{
			ValidationUtils.ArgumentNotNull(stream, "stream");
			_reader = new BinaryReader(stream);
			_stack = new List<ContainerContext>();
			_readRootValueAsArray = readRootValueAsArray;
			_dateTimeKindHandling = dateTimeKindHandling;
		}

		public BsonReader(BinaryReader reader, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			_reader = reader;
			_stack = new List<ContainerContext>();
			_readRootValueAsArray = readRootValueAsArray;
			_dateTimeKindHandling = dateTimeKindHandling;
		}

		private string ReadElement()
		{
			_currentElementType = ReadType();
			return ReadString();
		}

		public override byte[] ReadAsBytes()
		{
			return ReadAsBytesInternal();
		}

		public override decimal? ReadAsDecimal()
		{
			return ReadAsDecimalInternal();
		}

		public override int? ReadAsInt32()
		{
			return ReadAsInt32Internal();
		}

		public override string ReadAsString()
		{
			return ReadAsStringInternal();
		}

		public override DateTime? ReadAsDateTime()
		{
			return ReadAsDateTimeInternal();
		}

		public override DateTimeOffset? ReadAsDateTimeOffset()
		{
			return ReadAsDateTimeOffsetInternal();
		}

		public override bool Read()
		{
			_readType = Newtonsoft.Json.ReadType.Read;
			return ReadInternal();
		}

		internal override bool ReadInternal()
		{
			try
			{
				bool flag;
				switch (_bsonReaderState)
				{
				case BsonReaderState.Normal:
					flag = ReadNormal();
					break;
				case BsonReaderState.ReferenceStart:
				case BsonReaderState.ReferenceRef:
				case BsonReaderState.ReferenceId:
					flag = ReadReference();
					break;
				case BsonReaderState.CodeWScopeStart:
				case BsonReaderState.CodeWScopeCode:
				case BsonReaderState.CodeWScopeScope:
				case BsonReaderState.CodeWScopeScopeObject:
				case BsonReaderState.CodeWScopeScopeEnd:
					flag = ReadCodeWScope();
					break;
				default:
					throw JsonReaderException.Create(this, "Unexpected state: {0}".FormatWith(CultureInfo.InvariantCulture, _bsonReaderState));
				}
				if (!flag)
				{
					SetToken(JsonToken.None);
					return false;
				}
				return true;
			}
			catch (EndOfStreamException)
			{
				SetToken(JsonToken.None);
				return false;
			}
		}

		public override void Close()
		{
			base.Close();
			if (base.CloseInput && _reader != null)
			{
				_reader.Close();
			}
		}

		private bool ReadCodeWScope()
		{
			switch (_bsonReaderState)
			{
			case BsonReaderState.CodeWScopeStart:
				SetToken(JsonToken.PropertyName, "$code");
				_bsonReaderState = BsonReaderState.CodeWScopeCode;
				return true;
			case BsonReaderState.CodeWScopeCode:
				ReadInt32();
				SetToken(JsonToken.String, ReadLengthString());
				_bsonReaderState = BsonReaderState.CodeWScopeScope;
				return true;
			case BsonReaderState.CodeWScopeScope:
			{
				if (base.CurrentState == State.PostValue)
				{
					SetToken(JsonToken.PropertyName, "$scope");
					return true;
				}
				SetToken(JsonToken.StartObject);
				_bsonReaderState = BsonReaderState.CodeWScopeScopeObject;
				ContainerContext containerContext = new ContainerContext(BsonType.Object);
				PushContext(containerContext);
				containerContext.Length = ReadInt32();
				return true;
			}
			case BsonReaderState.CodeWScopeScopeObject:
			{
				bool flag = ReadNormal();
				if (flag && TokenType == JsonToken.EndObject)
				{
					_bsonReaderState = BsonReaderState.CodeWScopeScopeEnd;
				}
				return flag;
			}
			case BsonReaderState.CodeWScopeScopeEnd:
				SetToken(JsonToken.EndObject);
				_bsonReaderState = BsonReaderState.Normal;
				return true;
			default:
				throw new ArgumentOutOfRangeException();
			}
		}

		private bool ReadReference()
		{
			switch (base.CurrentState)
			{
			case State.ObjectStart:
				SetToken(JsonToken.PropertyName, "$ref");
				_bsonReaderState = BsonReaderState.ReferenceRef;
				return true;
			case State.Property:
				if (_bsonReaderState == BsonReaderState.ReferenceRef)
				{
					SetToken(JsonToken.String, ReadLengthString());
					return true;
				}
				if (_bsonReaderState == BsonReaderState.ReferenceId)
				{
					SetToken(JsonToken.Bytes, ReadBytes(12));
					return true;
				}
				throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + _bsonReaderState);
			case State.PostValue:
				if (_bsonReaderState == BsonReaderState.ReferenceRef)
				{
					SetToken(JsonToken.PropertyName, "$id");
					_bsonReaderState = BsonReaderState.ReferenceId;
					return true;
				}
				if (_bsonReaderState == BsonReaderState.ReferenceId)
				{
					SetToken(JsonToken.EndObject);
					_bsonReaderState = BsonReaderState.Normal;
					return true;
				}
				throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + _bsonReaderState);
			default:
				throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + base.CurrentState);
			}
		}

		private bool ReadNormal()
		{
			switch (base.CurrentState)
			{
			case State.Start:
			{
				JsonToken token2 = ((!_readRootValueAsArray) ? JsonToken.StartObject : JsonToken.StartArray);
				BsonType type = ((!_readRootValueAsArray) ? BsonType.Object : BsonType.Array);
				SetToken(token2);
				ContainerContext containerContext = new ContainerContext(type);
				PushContext(containerContext);
				containerContext.Length = ReadInt32();
				return true;
			}
			case State.Complete:
			case State.Closed:
				return false;
			case State.Property:
				ReadType(_currentElementType);
				return true;
			case State.ObjectStart:
			case State.ArrayStart:
			case State.PostValue:
			{
				ContainerContext currentContext = _currentContext;
				if (currentContext == null)
				{
					return false;
				}
				int num = currentContext.Length - 1;
				if (currentContext.Position < num)
				{
					if (currentContext.Type == BsonType.Array)
					{
						ReadElement();
						ReadType(_currentElementType);
						return true;
					}
					SetToken(JsonToken.PropertyName, ReadElement());
					return true;
				}
				if (currentContext.Position == num)
				{
					if (ReadByte() != 0)
					{
						throw JsonReaderException.Create(this, "Unexpected end of object byte value.");
					}
					PopContext();
					if (_currentContext != null)
					{
						MovePosition(currentContext.Length);
					}
					JsonToken token = ((currentContext.Type == BsonType.Object) ? JsonToken.EndObject : JsonToken.EndArray);
					SetToken(token);
					return true;
				}
				throw JsonReaderException.Create(this, "Read past end of current container context.");
			}
			default:
				throw new ArgumentOutOfRangeException();
			case State.ConstructorStart:
			case State.Constructor:
			case State.Error:
			case State.Finished:
				return false;
			}
		}

		private void PopContext()
		{
			_stack.RemoveAt(_stack.Count - 1);
			if (_stack.Count == 0)
			{
				_currentContext = null;
			}
			else
			{
				_currentContext = _stack[_stack.Count - 1];
			}
		}

		private void PushContext(ContainerContext newContext)
		{
			_stack.Add(newContext);
			_currentContext = newContext;
		}

		private byte ReadByte()
		{
			MovePosition(1);
			return _reader.ReadByte();
		}

		private void ReadType(BsonType type)
		{
			switch (type)
			{
			case BsonType.Number:
			{
				double num = ReadDouble();
				if (_floatParseHandling == FloatParseHandling.Decimal)
				{
					SetToken(JsonToken.Float, Convert.ToDecimal(num, CultureInfo.InvariantCulture));
				}
				else
				{
					SetToken(JsonToken.Float, num);
				}
				break;
			}
			case BsonType.String:
			case BsonType.Symbol:
				SetToken(JsonToken.String, ReadLengthString());
				break;
			case BsonType.Object:
			{
				SetToken(JsonToken.StartObject);
				ContainerContext containerContext2 = new ContainerContext(BsonType.Object);
				PushContext(containerContext2);
				containerContext2.Length = ReadInt32();
				break;
			}
			case BsonType.Array:
			{
				SetToken(JsonToken.StartArray);
				ContainerContext containerContext = new ContainerContext(BsonType.Array);
				PushContext(containerContext);
				containerContext.Length = ReadInt32();
				break;
			}
			case BsonType.Binary:
				SetToken(JsonToken.Bytes, ReadBinary());
				break;
			case BsonType.Undefined:
				SetToken(JsonToken.Undefined);
				break;
			case BsonType.Oid:
			{
				byte[] value2 = ReadBytes(12);
				SetToken(JsonToken.Bytes, value2);
				break;
			}
			case BsonType.Boolean:
			{
				bool flag = Convert.ToBoolean(ReadByte());
				SetToken(JsonToken.Boolean, flag);
				break;
			}
			case BsonType.Date:
			{
				long javaScriptTicks = ReadInt64();
				DateTime dateTime = DateTimeUtils.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
				SetToken(JsonToken.Date, DateTimeKindHandling switch
				{
					DateTimeKind.Unspecified => DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified), 
					DateTimeKind.Local => dateTime.ToLocalTime(), 
					_ => dateTime, 
				});
				break;
			}
			case BsonType.Null:
				SetToken(JsonToken.Null);
				break;
			case BsonType.Regex:
			{
				string text = ReadString();
				string text2 = ReadString();
				string value = "/" + text + "/" + text2;
				SetToken(JsonToken.String, value);
				break;
			}
			case BsonType.Reference:
				SetToken(JsonToken.StartObject);
				_bsonReaderState = BsonReaderState.ReferenceStart;
				break;
			case BsonType.Code:
				SetToken(JsonToken.String, ReadLengthString());
				break;
			case BsonType.CodeWScope:
				SetToken(JsonToken.StartObject);
				_bsonReaderState = BsonReaderState.CodeWScopeStart;
				break;
			case BsonType.Integer:
				SetToken(JsonToken.Integer, (long)ReadInt32());
				break;
			case BsonType.TimeStamp:
			case BsonType.Long:
				SetToken(JsonToken.Integer, ReadInt64());
				break;
			default:
				throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
			}
		}

		private byte[] ReadBinary()
		{
			int count = ReadInt32();
			BsonBinaryType bsonBinaryType = (BsonBinaryType)ReadByte();
			if (bsonBinaryType == BsonBinaryType.BinaryOld && !_jsonNet35BinaryCompatibility)
			{
				count = ReadInt32();
			}
			return ReadBytes(count);
		}

		private string ReadString()
		{
			EnsureBuffers();
			StringBuilder stringBuilder = null;
			int num = 0;
			int num2 = 0;
			while (true)
			{
				int num3 = num2;
				byte b;
				while (num3 < 128 && (b = _reader.ReadByte()) > 0)
				{
					_byteBuffer[num3++] = b;
				}
				int num4 = num3 - num2;
				num += num4;
				if (num3 < 128 && stringBuilder == null)
				{
					int chars = Encoding.UTF8.GetChars(_byteBuffer, 0, num4, _charBuffer, 0);
					MovePosition(num + 1);
					return new string(_charBuffer, 0, chars);
				}
				int lastFullCharStop = GetLastFullCharStop(num3 - 1);
				int chars2 = Encoding.UTF8.GetChars(_byteBuffer, 0, lastFullCharStop + 1, _charBuffer, 0);
				if (stringBuilder == null)
				{
					stringBuilder = new StringBuilder(256);
				}
				stringBuilder.Append(_charBuffer, 0, chars2);
				if (lastFullCharStop < num4 - 1)
				{
					num2 = num4 - lastFullCharStop - 1;
					Array.Copy(_byteBuffer, lastFullCharStop + 1, _byteBuffer, 0, num2);
					continue;
				}
				if (num3 < 128)
				{
					break;
				}
				num2 = 0;
			}
			MovePosition(num + 1);
			return stringBuilder.ToString();
		}

		private string ReadLengthString()
		{
			int num = ReadInt32();
			MovePosition(num);
			string @string = GetString(num - 1);
			_reader.ReadByte();
			return @string;
		}

		private string GetString(int length)
		{
			if (length == 0)
			{
				return string.Empty;
			}
			EnsureBuffers();
			StringBuilder stringBuilder = null;
			int num = 0;
			int num2 = 0;
			do
			{
				int count = ((length - num > 128 - num2) ? (128 - num2) : (length - num));
				int num3 = _reader.Read(_byteBuffer, num2, count);
				if (num3 == 0)
				{
					throw new EndOfStreamException("Unable to read beyond the end of the stream.");
				}
				num += num3;
				num3 += num2;
				if (num3 == length)
				{
					int chars = Encoding.UTF8.GetChars(_byteBuffer, 0, num3, _charBuffer, 0);
					return new string(_charBuffer, 0, chars);
				}
				int lastFullCharStop = GetLastFullCharStop(num3 - 1);
				if (stringBuilder == null)
				{
					stringBuilder = new StringBuilder(length);
				}
				int chars2 = Encoding.UTF8.GetChars(_byteBuffer, 0, lastFullCharStop + 1, _charBuffer, 0);
				stringBuilder.Append(_charBuffer, 0, chars2);
				if (lastFullCharStop < num3 - 1)
				{
					num2 = num3 - lastFullCharStop - 1;
					Array.Copy(_byteBuffer, lastFullCharStop + 1, _byteBuffer, 0, num2);
				}
				else
				{
					num2 = 0;
				}
			}
			while (num < length);
			return stringBuilder.ToString();
		}

		private int GetLastFullCharStop(int start)
		{
			int num = start;
			int num2 = 0;
			for (; num >= 0; num--)
			{
				num2 = BytesInSequence(_byteBuffer[num]);
				switch (num2)
				{
				case 0:
					continue;
				default:
					num--;
					break;
				case 1:
					break;
				}
				break;
			}
			if (num2 == start - num)
			{
				return start;
			}
			return num;
		}

		private int BytesInSequence(byte b)
		{
			if (b <= SeqRange1[1])
			{
				return 1;
			}
			if (b >= SeqRange2[0] && b <= SeqRange2[1])
			{
				return 2;
			}
			if (b >= SeqRange3[0] && b <= SeqRange3[1])
			{
				return 3;
			}
			if (b >= SeqRange4[0] && b <= SeqRange4[1])
			{
				return 4;
			}
			return 0;
		}

		private void EnsureBuffers()
		{
			if (_byteBuffer == null)
			{
				_byteBuffer = new byte[128];
			}
			if (_charBuffer == null)
			{
				int maxCharCount = Encoding.UTF8.GetMaxCharCount(128);
				_charBuffer = new char[maxCharCount];
			}
		}

		private double ReadDouble()
		{
			MovePosition(8);
			return _reader.ReadDouble();
		}

		private int ReadInt32()
		{
			MovePosition(4);
			return _reader.ReadInt32();
		}

		private long ReadInt64()
		{
			MovePosition(8);
			return _reader.ReadInt64();
		}

		private BsonType ReadType()
		{
			MovePosition(1);
			return (BsonType)_reader.ReadSByte();
		}

		private void MovePosition(int count)
		{
			_currentContext.Position += count;
		}

		private byte[] ReadBytes(int count)
		{
			MovePosition(count);
			return _reader.ReadBytes(count);
		}
	}
	internal abstract class BsonToken
	{
		public abstract BsonType Type { get; }

		public BsonToken Parent { get; set; }

		public int CalculatedSize { get; set; }
	}
	internal class BsonObject : BsonToken, IEnumerable<BsonProperty>, IEnumerable
	{
		private readonly List<BsonProperty> _children = new List<BsonProperty>();

		public override BsonType Type => BsonType.Object;

		public void Add(string name, BsonToken token)
		{
			_children.Add(new BsonProperty
			{
				Name = new BsonString(name, includeLength: false),
				Value = token
			});
			token.Parent = this;
		}

		public IEnumerator<BsonProperty> GetEnumerator()
		{
			return _children.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	internal class BsonArray : BsonToken, IEnumerable<BsonToken>, IEnumerable
	{
		private readonly List<BsonToken> _children = new List<BsonToken>();

		public override BsonType Type => BsonType.Array;

		public void Add(BsonToken token)
		{
			_children.Add(token);
			token.Parent = this;
		}

		public IEnumerator<BsonToken> GetEnumerator()
		{
			return _children.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	internal class BsonValue : BsonToken
	{
		private readonly object _value;

		private readonly BsonType _type;

		public object Value => _value;

		public override BsonType Type => _type;

		public BsonValue(object value, BsonType type)
		{
			_value = value;
			_type = type;
		}
	}
	internal class BsonString : BsonValue
	{
		public int ByteCount { get; set; }

		public bool IncludeLength { get; set; }

		public BsonString(object value, bool includeLength)
			: base(value, BsonType.String)
		{
			IncludeLength = includeLength;
		}
	}
	internal class BsonBinary : BsonValue
	{
		public BsonBinaryType BinaryType { get; set; }

		public BsonBinary(byte[] value, BsonBinaryType binaryType)
			: base(value, BsonType.Binary)
		{
			BinaryType = binaryType;
		}
	}
	internal class BsonRegex : BsonToken
	{
		public BsonString Pattern { get; set; }

		public BsonString Options { get; set; }

		public override BsonType Type => BsonType.Regex;

		public BsonRegex(string pattern, string options)
		{
			Pattern = new BsonString(pattern, includeLength: false);
			Options = new BsonString(options, includeLength: false);
		}
	}
	internal class BsonProperty
	{
		public BsonString Name { get; set; }

		public BsonToken Value { get; set; }
	}
	internal enum BsonType : sbyte
	{
		Number = 1,
		String = 2,
		Object = 3,
		Array = 4,
		Binary = 5,
		Undefined = 6,
		Oid = 7,
		Boolean = 8,
		Date = 9,
		Null = 10,
		Regex = 11,
		Reference = 12,
		Code = 13,
		Symbol = 14,
		CodeWScope = 15,
		Integer = 16,
		TimeStamp = 17,
		Long = 18,
		MinKey = -1,
		MaxKey = sbyte.MaxValue
	}
}
namespace Newtonsoft.Json
{
	public abstract class JsonWriter : IDisposable
	{
		internal enum State
		{
			Start,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			ConstructorStart,
			Constructor,
			Closed,
			Error
		}

		private static readonly State[][] StateArray;

		internal static readonly State[][] StateArrayTempate;

		private readonly List<JsonPosition> _stack;

		private JsonPosition _currentPosition;

		private State _currentState;

		private Formatting _formatting;

		private DateFormatHandling _dateFormatHandling;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private StringEscapeHandling _stringEscapeHandling;

		private FloatFormatHandling _floatFormatHandling;

		private string _dateFormatString;

		private CultureInfo _culture;

		public bool CloseOutput { get; set; }

		protected internal int Top
		{
			get
			{
				int num = _stack.Count;
				if (Peek() != 0)
				{
					num++;
				}
				return num;
			}
		}

		public WriteState WriteState
		{
			get
			{
				switch (_currentState)
				{
				case State.Error:
					return WriteState.Error;
				case State.Closed:
					return WriteState.Closed;
				case State.ObjectStart:
				case State.Object:
					return WriteState.Object;
				case State.ArrayStart:
				case State.Array:
					return WriteState.Array;
				case State.ConstructorStart:
				case State.Constructor:
					return WriteState.Constructor;
				case State.Property:
					return WriteState.Property;
				case State.Start:
					return WriteState.Start;
				default:
					throw JsonWriterException.Create(this, "Invalid state: " + _currentState, null);
				}
			}
		}

		internal string ContainerPath
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				return JsonPosition.BuildPath(_stack);
			}
		}

		public string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				IEnumerable<JsonPosition> positions = ((_currentState == State.ArrayStart || _currentState == State.ConstructorStart || _currentState == State.ObjectStart) ? _stack : _stack.Concat(new JsonPosition[1] { _currentPosition }));
				return JsonPosition.BuildPath(positions);
			}
		}

		public Formatting Formatting
		{
			get
			{
				return _formatting;
			}
			set
			{
				_formatting = value;
			}
		}

		public DateFormatHandling DateFormatHandling
		{
			get
			{
				return _dateFormatHandling;
			}
			set
			{
				_dateFormatHandling = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling;
			}
			set
			{
				_dateTimeZoneHandling = value;
			}
		}

		public StringEscapeHandling StringEscapeHandling
		{
			get
			{
				return _stringEscapeHandling;
			}
			set
			{
				_stringEscapeHandling = value;
				OnStringEscapeHandlingChanged();
			}
		}

		public FloatFormatHandling FloatFormatHandling
		{
			get
			{
				return _floatFormatHandling;
			}
			set
			{
				_floatFormatHandling = value;
			}
		}

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

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

		internal static State[][] BuildStateArray()
		{
			List<State[]> list = StateArrayTempate.ToList();
			State[] item = StateArrayTempate[0];
			State[] item2 = StateArrayTempate[7];
			foreach (JsonToken value in EnumUtils.GetValues(typeof(JsonToken)))
			{
				if (list.Count <= (int)value)
				{
					switch (value)
					{
					case JsonToken.Integer:
					case JsonToken.Float:
					case JsonToken.String:
					case JsonToken.Boolean:
					case JsonToken.Null:
					case JsonToken.Undefined:
					case JsonToken.Date:
					case JsonToken.Bytes:
						list.Add(item2);
						break;
					default:
						list.Add(item);
						break;
					}
				}
			}
			return list.ToArray();
		}

		static JsonWriter()
		{
			StateArrayTempate = new State[8][]
			{
				new State[10]
				{
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ObjectStart,
					State.ObjectStart,
					State.Error,
					State.Error,
					State.ObjectStart,
					State.ObjectStart,
					State.ObjectStart,
					State.ObjectStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ArrayStart,
					State.ArrayStart,
					State.Error,
					State.Error,
					State.ArrayStart,
					State.ArrayStart,
					State.ArrayStart,
					State.ArrayStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ConstructorStart,
					State.ConstructorStart,
					State.Error,
					State.Error,
					State.ConstructorStart,
					State.ConstructorStart,
					State.ConstructorStart,
					State.ConstructorStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Property,
					State.Error,
					State.Property,
					State.Property,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Property,
					State.ObjectStart,
					State.Object,
					State.ArrayStart,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Property,
					State.ObjectStart,
					State.Object,
					State.ArrayStart,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Object,
					State.Error,
					State.Error,
					State.Array,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				}
			};
			StateArray = BuildStateArray();
		}

		internal virtual void OnStringEscapeHandlingChanged()
		{
		}

		protected JsonWriter()
		{
			_stack = new List<JsonPosition>(4);
			_currentState = State.Start;
			_formatting = Formatting.None;
			_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
			CloseOutput = true;
		}

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

		private void Push(JsonContainerType value)
		{
			if (_currentPosition.Type != 0)
			{
				_stack.Add(_currentPosition);
			}
			_currentPosition = new JsonPosition(value);
		}

		private JsonContainerType Pop()
		{
			JsonPosition currentPosition = _currentPosition;
			if (_stack.Count > 0)
			{
				_currentPosition = _stack[_stack.Count - 1];
				_stack.RemoveAt(_stack.Count - 1);
			}
			else
			{
				_currentPosition = default(JsonPosition);
			}
			return currentPosition.Type;
		}

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

		public abstract void Flush();

		public virtual void Close()
		{
			AutoCompleteAll();
		}

		public virtual void WriteStartObject()
		{
			InternalWriteStart(JsonToken.StartObject, JsonContainerType.Object);
		}

		public virtual void WriteEndObject()
		{
			InternalWriteEnd(JsonContainerType.Object);
		}

		public virtual void WriteStartArray()
		{
			InternalWriteStart(JsonToken.StartArray, JsonContainerType.Array);
		}

		public virtual void WriteEndArray()
		{
			InternalWriteEnd(JsonContainerType.Array);
		}

		public virtual void WriteStartConstructor(string name)
		{
			InternalWriteStart(JsonToken.StartConstructor, JsonContainerType.Constructor);
		}

		public virtual void WriteEndConstructor()
		{
			InternalWriteEnd(JsonContainerType.Constructor);
		}

		public virtual void WritePropertyName(string name)
		{
			InternalWritePropertyName(name);
		}

		public virtual void WritePropertyName(string name, bool escape)
		{
			WritePropertyName(name);
		}

		public virtual void WriteEnd()
		{
			WriteEnd(Peek());
		}

		public void WriteToken(JsonReader reader)
		{
			WriteToken(reader, writeChildren: true, writeDateConstructorAsDate: true);
		}

		public void WriteToken(JsonReader reader, bool writeChildren)
		{
			ValidationUtils.ArgumentNotNull(reader, "reader");
			WriteToken(reader, writeChildren, writeDateConstructorAsDate: true);
		}

		internal void WriteToken(JsonReader reader, bool writeChildren, bool writeDateConstructorAsDate)
		{
			int initialDepth = ((reader.TokenType == JsonToken.None) ? (-1) : (IsStartToken(reader.TokenType) ? reader.Depth : (reader.Depth + 1)));
			WriteToken(reader, initialDepth, writeChildren, writeDateConstructorAsDate);
		}

		internal void WriteToken(JsonReader reader, int initialDepth, bool writeChildren, bool writeDateConstructorAsDate)
		{
			do
			{
				switch (reader.TokenType)
				{
				case JsonToken.StartObject:
					WriteStartObject();
					break;
				case JsonToken.StartArray:
					WriteStartArray();
					break;
				case JsonToken.StartConstructor:
				{
					string a = reader.Value.ToString();
					if (writeDateConstructorAsDate && string.Equals(a, "Date", StringComparison.Ordinal))
					{
						WriteConstructorDate(reader);
					}
					else
					{
						WriteStartConstructor(reader.Value.ToString());
					}
					break;
				}
				case JsonToken.PropertyName:
					WritePropertyName(reader.Value.ToString());
					break;
				case JsonToken.Comment:
					WriteComment((reader.Value != null) ? reader.Value.ToString() : null);
					break;
				case JsonToken.Integer:
					WriteValue(Convert.ToInt64(reader.Value, CultureInfo.InvariantCulture));
					break;
				case JsonToken.Float:
				{
					object value = reader.Value;
					if (value is decimal)
					{
						WriteValue((decimal)value);
					}
					else if (value is double)
					{
						WriteValue((double)value);
					}
					else if (value is float)
					{
						WriteValue((float)value);
					}
					else
					{
						WriteValue(Convert.ToDouble(value, CultureInfo.InvariantCulture));
					}
					break;
				}
				case JsonToken.String:
					WriteValue(reader.Value.ToString());
					break;
				case JsonToken.Boolean:
					WriteValue(Convert.ToBoolean(reader.Value, CultureInfo.InvariantCulture));
					break;
				case JsonToken.Null:
					WriteNull();
					break;
				case JsonToken.Undefined:
					WriteUndefined();
					break;
				case JsonToken.EndObject:
					WriteEndObject();
					break;
				case JsonToken.EndArray:
					WriteEndArray();
					break;
				case JsonToken.EndConstructor:
					WriteEndConstructor();
					break;
				case JsonToken.Date:
					if (reader.Value is DateTimeOffset)
					{
						WriteValue((DateTimeOffset)reader.Value);
					}
					else
					{
						WriteValue(Convert.ToDateTime(reader.Value, CultureInfo.InvariantCulture));
					}
					break;
				case JsonToken.Raw:
					WriteRawValue((reader.Value != null) ? reader.Value.ToString() : null);
					break;
				case JsonToken.Bytes:
					WriteValue((byte[])reader.Value);
					break;
				default:
					throw MiscellaneousUtils.CreateArgumentOutOfRangeException("TokenType", reader.TokenType, "Unexpected token type.");
				case JsonToken.None:
					break;
				}
			}
			while (initialDepth - 1 < reader.Depth - (IsEndToken(reader.TokenType) ? 1 : 0) && writeChildren && reader.Read());
		}

		private void WriteConstructorDate(JsonReader reader)
		{
			if (!reader.Read())
			{
				throw JsonWriterException.Create(this, "Unexpected end when reading date constructor.", null);
			}
			if (reader.TokenType != JsonToken.Integer)
			{
				throw JsonWriterException.Create(this, "Unexpected token when reading date constructor. Expected Integer, got " + reader.TokenType, null);
			}
			long javaScriptTicks = (long)reader.Value;
			DateTime value = DateTimeUtils.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
			if (!reader.Read())
			{
				throw JsonWriterException.Create(this, "Unexpected end when reading date constructor.", null);
			}
			if (reader.TokenType != JsonToken.EndConstructor)
			{
				throw JsonWriterException.Create(this, "Unexpected token when reading date constructor. Expected EndConstructor, got " + reader.TokenType, null);
			}
			WriteValue(value);
		}

		internal static bool IsEndToken(JsonToken token)
		{
			switch (token)
			{
			case JsonToken.EndObject:
			case JsonToken.EndArray:
			case JsonToken.EndConstructor:
				return true;
			default:
				return false;
			}
		}

		internal static bool IsStartToken(JsonToken token)
		{
			switch (token)
			{
			case JsonToken.StartObject:
			case JsonToken.StartArray:
			case JsonToken.StartConstructor:
				return true;
			default:
				return false;
			}
		}

		private void WriteEnd(JsonContainerType type)
		{
			switch (type)
			{
			case JsonContainerType.Object:
				WriteEndObject();
				break;
			case JsonContainerType.Array:
				WriteEndArray();
				break;
			case JsonContainerType.Constructor:
				WriteEndConstructor();
				break;
			default:
				throw JsonWriterException.Create(this, "Unexpected type when writing end: " + type, null);
			}
		}

		private void AutoCompleteAll()
		{
			while (Top > 0)
			{
				WriteEnd();
			}
		}

		private JsonToken GetCloseTokenForType(JsonContainerType type)
		{
			return type switch
			{
				JsonContainerType.Object => JsonToken.EndObject, 
				JsonContainerType.Array => JsonToken.EndArray, 
				JsonContainerType.Constructor => JsonToken.EndConstructor, 
				_ => throw JsonWriterException.Create(this, "No close token for type: " + type, null), 
			};
		}

		private void AutoCompleteClose(JsonContainerType type)
		{
			int num = 0;
			if (_currentPosition.Type == type)
			{
				num = 1;
			}
			else
			{
				int num2 = Top - 2;
				for (int num3 = num2; num3 >= 0; num3--)
				{
					int index = num2 - num3;
					if (_stack[index].Type == type)
					{
						num = num3 + 2;
						break;
					}
				}
			}
			if (num == 0)
			{
				throw JsonWriterException.Create(this, "No token to close.", null);
			}
			for (int i = 0; i < num; i++)
			{
				JsonToken closeTokenForType = GetCloseTokenForType(Pop());
				if (_currentState == State.Property)
				{
					WriteNull();
				}
				if (_formatting == Formatting.Indented && _currentState != State.ObjectStart && _currentState != State.ArrayStart)
				{
					WriteIndent();
				}
				WriteEnd(closeTokenForType);
				JsonContainerType jsonContainerType = Peek();
				switch (jsonContainerType)
				{
				case JsonContainerType.Object:
					_currentState = State.Object;
					break;
				case JsonContainerType.Array:
					_currentState = State.Array;
					break;
				case JsonContainerType.Constructor:
					_currentState = State.Array;
					break;
				case JsonContainerType.None:
					_currentState = State.Start;
					break;
				default:
					throw JsonWriterException.Create(this, "Unknown JsonType: " + jsonContainerType, null);
				}
			}
		}

		protected virtual void WriteEnd(JsonToken token)
		{
		}

		protected virtual void WriteIndent()
		{
		}

		protected virtual void WriteValueDelimiter()
		{
		}

		protected virtual void WriteIndentSpace()
		{
		}

		internal void AutoComplete(JsonToken tokenBeingWritten)
		{
			State state = StateArray[(int)tokenBeingWritten][(int)_currentState];
			if (state == State.Error)
			{
				throw JsonWriterException.Create(this, "Token {0} in state {1} would result in an invalid JSON object.".FormatWith(CultureInfo.InvariantCulture, tokenBeingWritten.ToString(), _currentState.ToString()), null);
			}
			if ((_currentState == State.Object || _currentState == State.Array || _currentState == State.Constructor) && tokenBeingWritten != JsonToken.Comment)
			{
				WriteValueDelimiter();
			}
			if (_formatting == Formatting.Indented)
			{
				if (_currentState == State.Property)
				{
					WriteIndentSpace();
				}
				if (_currentState == State.Array || _currentState == State.ArrayStart || _currentState == State.Constructor || _currentState == State.ConstructorStart || (tokenBeingWritten == JsonToken.PropertyName && _currentState != 0))
				{
					WriteIndent();
				}
			}
			_currentState = state;
		}

		public virtual void WriteNull()
		{
			InternalWriteValue(JsonToken.Null);
		}

		public virtual void WriteUndefined()
		{
			InternalWriteValue(JsonToken.Undefined);
		}

		public virtual void WriteRaw(string json)
		{
			InternalWriteRaw();
		}

		public virtual void WriteRawValue(string json)
		{
			UpdateScopeWithFinishedValue();
			AutoComplete(JsonToken.Undefined);
			WriteRaw(json);
		}

		public virtual void WriteValue(string value)
		{
			InternalWriteValue(JsonToken.String);
		}

		public virtual void WriteValue(int value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(uint value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		public virtual void WriteValue(long value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ulong value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		public virtual void WriteValue(float value)
		{
			InternalWriteValue(JsonToken.Float);
		}

		public virtual void WriteValue(double value)
		{
			InternalWriteValue(JsonToken.Float);
		}

		public virtual void WriteValue(bool value)
		{
			InternalWriteValue(JsonToken.Boolean);
		}

		public virtual void WriteValue(short value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ushort value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		public virtual void WriteValue(char value)
		{
			InternalWriteValue(JsonToken.String);
		}

		public virtual void WriteValue(byte value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(sbyte value)
		{
			InternalWriteValue(JsonToken.Integer);
		}

		public virtual void WriteValue(decimal value)
		{
			InternalWriteValue(JsonToken.Float);
		}

		public virtual void WriteValue(DateTime value)
		{
			InternalWriteValue(JsonToken.Date);
		}

		public virtual void WriteValue(DateTimeOffset value)
		{
			InternalWriteValue(JsonToken.Date);
		}

		public virtual void WriteValue(Guid value)
		{
			InternalWriteValue(JsonToken.String);
		}

		public virtual void WriteValue(TimeSpan value)
		{
			InternalWriteValue(JsonToken.String);
		}

		public virtual void WriteValue(int? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(uint? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(long? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ulong? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(float? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(double? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(bool? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(short? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ushort? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(char? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(byte? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(sbyte? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(decimal? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(DateTime? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(DateTimeOffset? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(Guid? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(TimeSpan? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(byte[] value)
		{
			if (value == null)
			{
				WriteNull();
			}
			else
			{
				InternalWriteValue(JsonToken.Bytes);
			}
		}

		public virtual void WriteValue(Uri value)
		{
			if (value == null)
			{
				WriteNull();
			}
			else
			{
				InternalWriteValue(JsonToken.String);
			}
		}

		public virtual void WriteValue(object value)
		{
			if (value == null)
			{
				WriteNull();
			}
			else
			{
				WriteValue(this, ConvertUtils.GetTypeCode(value), value);
			}
		}

		public virtual void WriteComment(string text)
		{
			InternalWriteComment();
		}

		public virtual void WriteWhitespace(string ws)
		{
			InternalWriteWhitespace(ws);
		}

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

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

		internal static void WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, object value)
		{
			switch (typeCode)
			{
			case PrimitiveTypeCode.Char:
				writer.WriteValue((char)value);
				return;
			case PrimitiveTypeCode.CharNullable:
				writer.WriteValue((value == null) ? null : new char?((char)value));
				return;
			case PrimitiveTypeCode.Boolean:
				writer.WriteValue((bool)value);
				return;
			case PrimitiveTypeCode.BooleanNullable:
				writer.WriteValue((value == null) ? null : new bool?((bool)value));
				return;
			case PrimitiveTypeCode.SByte:
				writer.WriteValue((sbyte)value);
				return;
			case PrimitiveTypeCode.SByteNullable:
				writer.WriteValue((value == null) ? null : new sbyte?((sbyte)value));
				return;
			case PrimitiveTypeCode.Int16:
				writer.WriteValue((short)value);
				return;
			case PrimitiveTypeCode.Int16Nullable:
				writer.WriteValue((value == null) ? null : new short?((short)value));
				return;
			case PrimitiveTypeCode.UInt16:
				writer.WriteValue((ushort)value);
				return;
			case PrimitiveTypeCode.UInt16Nullable:
				writer.WriteValue((value == null) ? null : new ushort?((ushort)value));
				return;
			case PrimitiveTypeCode.Int32:
				writer.WriteValue((int)value);
				return;
			case PrimitiveTypeCode.Int32Nullable:
				writer.WriteValue((value == null) ? null : new int?((int)value));
				return;
			case PrimitiveTypeCode.Byte:
				writer.WriteValue((byte)value);
				return;
			case PrimitiveTypeCode.ByteNullable:
				writer.WriteValue((value == null) ? null : new byte?((byte)value));
				return;
			case PrimitiveTypeCode.UInt32:
				writer.WriteValue((uint)value);
				return;
			case PrimitiveTypeCode.UInt32Nullable:
				writer.WriteValue((value == null) ? null : new uint?((uint)value));
				return;
			case PrimitiveTypeCode.Int64:
				writer.WriteValue((long)value);
				return;
			case PrimitiveTypeCode.Int64Nullable:
				writer.WriteValue((value == null) ? null : new long?((long)value));
				return;
			case PrimitiveTypeCode.UInt64:
				writer.WriteValue((ulong)value);
				return;
			case PrimitiveTypeCode.UInt64Nullable:
				writer.WriteValue((value == null) ? null : new ulong?((ulong)value));
				return;
			case PrimitiveTypeCode.Single:
				writer.WriteValue((float)value);
				return;
			case PrimitiveTypeCode.SingleNullable:
				writer.WriteValue((value == null) ? null : new float?((float)value));
				return;
			case PrimitiveTypeCode.Double:
				writer.WriteValue((double)value);
				return;
			case PrimitiveTypeCode.DoubleNullable:
				writer.WriteValue((value == null) ? null : new double?((double)value));
				return;
			case PrimitiveTypeCode.DateTime:
				writer.WriteValue((DateTime)value);
				return;
			case PrimitiveTypeCode.DateTimeNullable:
				writer.WriteValue((value == null) ? null : new DateTime?((DateTime)value));
				return;
			case PrimitiveTypeCode.DateTimeOffset:
				writer.WriteValue((DateTimeOffset)value);
				return;
			case PrimitiveTypeCode.DateTimeOffsetNullable:
				writer.WriteValue((value == null) ? null : new DateTimeOffset?((DateTimeOffset)value));
				return;
			case PrimitiveTypeCode.Decimal:
				writer.WriteValue((decimal)value);
				return;
			case PrimitiveTypeCode.DecimalNullable:
				writer.WriteValue((value == null) ? null : new decimal?((decimal)value));
				return;
			case PrimitiveTypeCode.Guid:
				writer.WriteValue((Guid)value);
				return;
			case PrimitiveTypeCode.GuidNullable:
				writer.WriteValue((value == null) ? null : new Guid?((Guid)value));
				return;
			case PrimitiveTypeCode.TimeSpan:
				writer.WriteValue((TimeSpan)value);
				return;
			case PrimitiveTypeCode.TimeSpanNullable:
				writer.WriteValue((value == null) ? null : new TimeSpan?((TimeSpan)value));
				return;
			case PrimitiveTypeCode.Uri:
				writer.WriteValue((Uri)value);
				return;
			case PrimitiveTypeCode.String:
				writer.WriteValue((string)value);
				return;
			case PrimitiveTypeCode.Bytes:
				writer.WriteValue((byte[])value);
				return;
			case PrimitiveTypeCode.DBNull:
				writer.WriteNull();
				return;
			}
			if (value is IConvertible)
			{
				IConvertible convertible = (IConvertible)value;
				TypeInformation typeInformation = ConvertUtils.GetTypeInformation(convertible);
				PrimitiveTypeCode typeCode2 = ((typeInformation.TypeCode == PrimitiveTypeCode.Object) ? PrimitiveTypeCode.String : typeInformation.TypeCode);
				Type conversionType = ((typeInformation.TypeCode == PrimitiveTypeCode.Object) ? typeof(string) : typeInformation.Type);
				object value2 = convertible.ToType(conversionType, CultureInfo.InvariantCulture);
				WriteValue(writer, typeCode2, value2);
				return;
			}
			throw CreateUnsupportedTypeException(writer, value);
		}

		private static JsonWriterException CreateUnsupportedTypeException(JsonWriter writer, object value)
		{
			return JsonWriterException.Create(writer, "Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType()), null);
		}

		protected void SetWriteState(JsonToken token, object value)
		{
			switch (token)
			{
			case JsonToken.StartObject:
				InternalWriteStart(token, JsonContainerType.Object);
				break;
			case JsonToken.StartArray:
				InternalWriteStart(token, JsonContainerType.Array);
				break;
			case JsonToken.StartConstructor:
				InternalWriteStart(token, JsonContainerType.Constructor);
				break;
			case JsonToken.PropertyName:
				if (!(value is string))
				{
					throw new ArgumentException("A name is required when setting property name state.", "value");
				}
				InternalWritePropertyName((string)value);
				break;
			case JsonToken.Comment:
				InternalWriteComment();
				break;
			case JsonToken.Raw:
				InternalWriteRaw();
				break;
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				InternalWriteValue(token);
				break;
			case JsonToken.EndObject:
				InternalWriteEnd(JsonContainerType.Object);
				break;
			case JsonToken.EndArray:
				InternalWriteEnd(JsonContainerType.Array);
				break;
			case JsonToken.EndConstructor:
				InternalWriteEnd(JsonContainerType.Constructor);
				break;
			default:
				throw new ArgumentOutOfRangeException("token");
			}
		}

		internal void InternalWriteEnd(JsonContainerType container)
		{
			AutoCompleteClose(container);
		}

		internal void InternalWritePropertyName(string name)
		{
			_currentPosition.PropertyName = name;
			AutoComplete(JsonToken.PropertyName);
		}

		internal void InternalWriteRaw()
		{
		}

		internal void InternalWriteStart(JsonToken token, JsonContainerType container)
		{
			UpdateScopeWithFinishedValue();
			AutoComplete(token);
			Push(container);
		}

		internal void InternalWriteValue(JsonToken token)
		{
			UpdateScopeWithFinishedValue();
			AutoComplete(token);
		}

		internal void InternalWriteWhitespace(string ws)
		{
			if (ws != null && !StringUtils.IsWhiteSpace(ws))
			{
				throw JsonWriterException.Create(this, "Only white space characters should be used.", null);
			}
		}

		internal void InternalWriteComment()
		{
			AutoComplete(JsonToken.Comment);
		}
	}
}
namespace Newtonsoft.Json.Bson
{
	public class BsonWriter : JsonWriter
	{
		private readonly BsonBinaryWriter _writer;

		private BsonToken _root;

		private BsonToken _parent;

		private string _propertyName;

		public DateTimeKind DateTimeKindHandling
		{
			get
			{
				return _writer.DateTimeKindHandling;
			}
			set
			{
				_writer.DateTimeKindHandling = value;
			}
		}

		public BsonWriter(Stream stream)
		{
			ValidationUtils.ArgumentNotNull(stream, "stream");
			_writer = new BsonBinaryWriter(new BinaryWriter(stream));
		}

		public BsonWriter(BinaryWriter writer)
		{
			ValidationUtils.ArgumentNotNull(writer, "writer");
			_writer = new BsonBinaryWriter(writer);
		}

		public override void Flush()
		{
			_writer.Flush();
		}

		protected override void WriteEnd(JsonToken token)
		{
			base.WriteEnd(token);
			RemoveParent();
			if (base.Top == 0)
			{
				_writer.WriteToken(_root);
			}
		}

		public override void WriteComment(string text)
		{
			throw JsonWriterException.Create(this, "Cannot write JSON comment as BSON.", null);
		}

		public override void WriteStartConstructor(string name)
		{
			throw JsonWriterException.Create(this, "Cannot write JSON constructor as BSON.", null);
		}

		public override void WriteRaw(string json)
		{
			throw JsonWriterException.Create(this, "Cannot write raw JSON as BSON.", null);
		}

		public override void WriteRawValue(string json)
		{
			throw JsonWriterException.Create(this, "Cannot write raw JSON as BSON.", null);
		}

		public override void WriteStartArray()
		{
			base.WriteStartArray();
			AddParent(new BsonArray());
		}

		public override void WriteStartObject()
		{
			base.WriteStartObject();
			AddParent(new BsonObject());
		}

		public override void WritePropertyName(string name)
		{
			base.WritePropertyName(name);
			_propertyName = name;
		}

		public override void Close()
		{
			base.Close();
			if (base.CloseOutput && _writer != null)
			{
				_writer.Close();
			}
		}

		private void AddParent(BsonToken container)
		{
			AddToken(container);
			_parent = container;
		}

		private void RemoveParent()
		{
			_parent = _parent.Parent;
		}

		private void AddValue(object value, BsonType type)
		{
			AddToken(new BsonValue(value, type));
		}

		internal void AddToken(BsonToken token)
		{
			if (_parent != null)
			{
				if (_parent is BsonObject)
				{
					((BsonObject)_parent).Add(_propertyName, token);
					_propertyName = null;
				}
				else
				{
					((BsonArray)_parent).Add(token);
				}
				return;
			}
			if (token.Type != BsonType.Object && token.Type != BsonType.Array)
			{
				throw JsonWriterException.Create(this, "Error writing {0} value. BSON must start with an Object or Array.".FormatWith(CultureInfo.InvariantCulture, token.Type), null);
			}
			_parent = token;
			_root = token;
		}

		public override void WriteValue(object value)
		{
			base.WriteValue(value);
		}

		public override void WriteNull()
		{
			base.WriteNull();
			AddValue(null, BsonType.Null);
		}

		public override void WriteUndefined()
		{
			base.WriteUndefined();
			AddValue(null, BsonType.Undefined);
		}

		public override void WriteValue(string value)
		{
			base.WriteValue(value);
			if (value == null)
			{
				AddValue(null, BsonType.Null);
			}
			else
			{
				AddToken(new BsonString(value, includeLength: true));
			}
		}

		public override void WriteValue(int value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		[CLSCompliant(false)]
		public override void WriteValue(uint value)
		{
			if (value > int.MaxValue)
			{
				throw JsonWriterException.Create(this, "Value is too large to fit in a signed 32 bit integer. BSON does not support unsigned values.", null);
			}
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		public override void WriteValue(long value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Long);
		}

		[CLSCompliant(false)]
		public override void WriteValue(ulong value)
		{
			if (value > long.MaxValue)
			{
				throw JsonWriterException.Create(this, "Value is too large to fit in a signed 64 bit integer. BSON does not support unsigned values.", null);
			}
			base.WriteValue(value);
			AddValue(value, BsonType.Long);
		}

		public override void WriteValue(float value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Number);
		}

		public override void WriteValue(double value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Number);
		}

		public override void WriteValue(bool value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Boolean);
		}

		public override void WriteValue(short value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		[CLSCompliant(false)]
		public override void WriteValue(ushort value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		public override void WriteValue(char value)
		{
			base.WriteValue(value);
			string text = null;
			text = value.ToString(CultureInfo.InvariantCulture);
			AddToken(new BsonString(text, includeLength: true));
		}

		public override void WriteValue(byte value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		[CLSCompliant(false)]
		public override void WriteValue(sbyte value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Integer);
		}

		public override void WriteValue(decimal value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Number);
		}

		public override void WriteValue(DateTime value)
		{
			base.WriteValue(value);
			value = DateTimeUtils.EnsureDateTime(value, base.DateTimeZoneHandling);
			AddValue(value, BsonType.Date);
		}

		public override void WriteValue(DateTimeOffset value)
		{
			base.WriteValue(value);
			AddValue(value, BsonType.Date);
		}

		public override void WriteValue(byte[] value)
		{
			base.WriteValue(value);
			AddToken(new BsonBinary(value, BsonBinaryType.Binary));
		}

		public override void WriteValue(Guid value)
		{
			base.WriteValue(value);
			AddToken(new BsonBinary(value.ToByteArray(), BsonBinaryType.Uuid));
		}

		public override void WriteValue(TimeSpan value)
		{
			base.WriteValue(value);
			AddToken(new BsonString(value.ToString(), includeLength: true));
		}

		public override void WriteValue(Uri value)
		{
			base.WriteValue(value);
			AddToken(new BsonString(value.ToString(), includeLength: true));
		}

		public void WriteObjectId(byte[] value)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			if (value.Length != 12)
			{
				throw JsonWriterException.Create(this, "An object id must be 12 bytes", null);
			}
			UpdateScopeWithFinishedValue();
			AutoComplete(JsonToken.Undefined);
			AddValue(value, BsonType.Oid);
		}

		public void WriteRegex(string pattern, string options)
		{
			ValidationUtils.ArgumentNotNull(pattern, "pattern");
			UpdateScopeWithFinishedValue();
			AutoComplete(JsonToken.Undefined);
			AddToken(new BsonRegex(pattern, options));
		}
	}
	public class BsonObjectId
	{
		public byte[] Value { get; private set; }

		public BsonObjectId(byte[] value)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			if (value.Length != 12)
			{
				throw new ArgumentException("An ObjectId must be 12 bytes", "value");
			}
			Value = value;
		}
	}
}
namespace Newtonsoft.Json.Converters
{
	internal interface IBinary
	{
		byte[] ToArray();
	}
}
namespace Newtonsoft.Json
{
	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 virtual JsonSchema GetSchema()
		{
			return null;
		}
	}
}
namespace Newtonsoft.Json.Converters
{
	public class BinaryConverter : JsonConverter
	{
		private const string BinaryTypeName = "System.Data.Linq.Binary";

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if (value == null)
			{
				writer.WriteNull();
				return;
			}
			byte[] byteArray = GetByteArray(value);
			writer.WriteValue(byteArray);
		}

		private byte[] GetByteArray(object value)
		{
			if (value.GetType().AssignableToTypeName("System.Data.Linq.Binary"))
			{
				IBinary binary = DynamicWrapper.CreateWrapper<IBinary>(value);
				return binary.ToArray();
			}
			throw new JsonSerializationException("Unexpected value type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			Type type = (ReflectionUtils.IsNullableType(objectType) ? Nullable.GetUnderlyingType(objectType) : objectType);
			if (reader.TokenType == JsonToken.Null)
			{
				if (!ReflectionUtils.IsNullable(objectType))
				{
					throw JsonSerializationException.Create(reader, "Cannot convert null value to {0}.".FormatWith(CultureInfo.InvariantCulture, objectType));
				}
				return null;
			}
			byte[] array;
			if (reader.TokenType == JsonToken.StartArray)
			{
				array = ReadByteArray(reader);
			}
			else
			{
				if (reader.TokenType != JsonToken.String)
				{
					throw JsonSerializationException.Create(reader, "Unexpected token parsing binary. Expected String or StartArray, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
				}
				string s = reader.Value.ToString();
				array = Convert.FromBase64String(s);
			}
			if (type.AssignableToTypeName("System.Data.Linq.Binary"))
			{
				return Activator.CreateInstance(type, array);
			}
			throw JsonSerializationException.Create(reader, "Unexpected object type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, objectType));
		}

		private byte[] ReadByteArray(JsonReader reader)
		{
			List<byte> list = new List<byte>();
			while (reader.Read())
			{
				switch (reader.TokenType)
				{
				case JsonToken.Integer:
					list.Add(Convert.ToByte(reader.Value, CultureInfo.InvariantCulture));
					break;
				case JsonToken.EndArray:
					return list.ToArray();
				default:
					throw JsonSerializationException.Create(reader, "Unexpected token when reading bytes: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
				case JsonToken.Comment:
					break;
				}
			}
			throw JsonSerializationException.Create(reader, "Unexpected end when reading bytes.");
		}

		public override bool CanConvert(Type objectType)
		{
			if (objectType.AssignableToTypeName("System.Data.Linq.Binary"))
			{
				return true;
			}
			return false;
		}
	}
	public abstract class CustomCreationConverter<T> : JsonConverter
	{
		public override bool CanWrite => false;

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			throw new NotSupportedException("CustomCreationConverter should only be used while deserializing.");
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.TokenType == JsonToken.Null)
			{
				return null;
			}
			T val = Create(objectType);
			if (val == null)
			{
				throw new JsonSerializationException("No object created.");
			}
			serializer.Populate(reader, val);
			return val;
		}

		public abstract T Create(Type objectType);

		public override bool CanConvert(Type objectType)
		{
			return typeof(T).IsAssignableFrom(objectType);
		}
	}
	public abstract class DateTimeConverterBase : JsonConverter
	{
		public override bool CanConvert(Type objectType)
		{
			if ((object)objectType == typeof(DateTime) || (object)objectType == typeof(DateTime?))
			{
				return true;
			}
			if ((object)objectType == typeof(DateTimeOffset) || (object)objectType == typeof(DateTimeOffset?))
			{
				return true;
			}
			return false;
		}
	}
	public class DiscriminatedUnionConverter : JsonConverter
	{
		private const string CasePropertyName = "Case";

		private const string FieldsPropertyName = "Fields";

		private static bool _initialized;

		private static MethodCall<object, object> _isUnion;

		private static MethodCall<object, object> _getUnionFields;

		private static MethodCall<object, object> _getUnionCases;

		private static MethodCall<object, object> _makeUnion;

		private static Func<object, object> _getUnionCaseInfoName;

		private static Func<object, object> _getUnionCaseInfo;

		private static Func<object, object> _getUnionCaseFields;

		private static MethodCall<object, object> _getUnionCaseInfoFields;

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver;
			Type type = value.GetType();
			object arg = _getUnionFields(null, value, type, null);
			object arg2 = _getUnionCaseInfo(arg);
			object value2 = _getUnionCaseFields(arg);
			object obj = _getUnionCaseInfoName(arg2);
			writer.WriteStartObject();
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Case") : "Case");
			writer.WriteValue((string)obj);
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Fields") : "Fields");
			serializer.Serialize(writer, value2);
			writer.WriteEndObject();
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.TokenType == JsonToken.Null)
			{
				return null;
			}
			IEnumerable enumerable = (IEnumerable)_getUnionCases(null, objectType, null);
			ReadAndAssertProperty(reader, "Case");
			ReadAndAssert(reader);
			string text = reader.Value.ToString();
			object obj = null;
			foreach (object item in enumerable)
			{
				if ((string)_getUnionCaseInfoName(item) == text)
				{
					obj = item;
					break;
				}
			}
			if (obj == null)
			{
				throw new JsonSerializationException("No union type found with the name '{0}'.".FormatWith(CultureInfo.InvariantCulture, text));
			}
			ReadAndAssertProperty(reader, "Fields");
			ReadAndAssert(reader);
			ReadAndAssert(reader);
			PropertyInfo[] array = (PropertyInfo[])_getUnionCaseInfoFields(obj);
			List<object> list = new List<object>();
			PropertyInfo[] array2 = array;
			foreach (PropertyInfo propertyInfo in array2)
			{
				list.Add(serializer.Deserialize(reader, propertyInfo.PropertyType));
				ReadAndAssert(reader);
			}
			ReadAndAssert(reader);
			return _makeUnion(null, obj, list.ToArray(), null);
		}

		public override bool CanConvert(Type objectType)
		{
			if (typeof(IEnumerable).IsAssignableFrom(objectType))
			{
				return false;
			}
			object[] customAttributes = objectType.GetCustomAttributes(inherit: true);
			bool flag = false;
			object[] array = customAttributes;
			foreach (object obj in array)
			{
				Type type = obj.GetType();
				if (type.Name == "CompilationMappingAttribute")
				{
					EnsureInitialized(type);
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return false;
			}
			return (bool)_isUnion(null, objectType, null);
		}

		private static void EnsureInitialized(Type attributeType)
		{
			if (!_initialized)
			{
				_initialized = true;
				Assembly assembly = attributeType.Assembly();
				Type type = assembly.GetType("Microsoft.FSharp.Reflection.FSharpType");
				MethodInfo method = type.GetMethod("IsUnion", BindingFlags.Static | BindingFlags.Public);
				_isUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(method);
				MethodInfo method2 = type.GetMethod("GetUnionCases", BindingFlags.Static | BindingFlags.Public);
				_getUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(method2);
				Type type2 = assembly.GetType("Microsoft.FSharp.Reflection.FSharpValue");
				MethodInfo method3 = type2.GetMethod("GetUnionFields", BindingFlags.Static | BindingFlags.Public);
				_getUnionFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(method3);
				_getUnionCaseInfo = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(method3.ReturnType.GetProperty("Item1"));
				_getUnionCaseFields = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(method3.ReturnType.GetProperty("Item2"));
				MethodInfo method4 = type2.GetMethod("MakeUnion", BindingFlags.Static | BindingFlags.Public);
				_makeUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(method4);
				Type type3 = assembly.GetType("Microsoft.FSharp.Reflection.UnionCaseInfo");
				_getUnionCaseInfoName = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(type3.GetProperty("Name"));
				_getUnionCaseInfoFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(type3.GetMethod("GetFields"));
			}
		}

		private static void ReadAndAssertProperty(JsonReader reader, string propertyName)
		{
			ReadAndAssert(reader);
			if (reader.TokenType != JsonToken.PropertyName || !string.Equals(reader.Value.ToString(), propertyName, StringComparison.OrdinalIgnoreCase))
			{
				throw new JsonSerializationException("Expected JSON property '{0}'.".FormatWith(CultureInfo.InvariantCulture, propertyName));
			}
		}

		private static void ReadAndAssert(JsonReader reader)
		{
			if (!reader.Read())
			{
				throw new JsonSerializationException("Unexpected end.");
			}
		}
	}
	internal interface IEntityKeyMember
	{
		string Key { get; set; }

		object Value { get; set; }
	}
	public class EntityKeyMemberConverter : JsonConverter
	{
		private const string EntityKeyMemberFullTypeName = "System.Data.EntityKeyMember";

		private const string KeyPropertyName = "Key";

		private const string TypePropertyName = "Type";

		private const string ValuePropertyName = "Value";

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver;
			IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper<IEntityKeyMember>(value);
			Type type = ((entityKeyMember.Value != null) ? entityKeyMember.Value.GetType() : null);
			writer.WriteStartObject();
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Key") : "Key");
			writer.WriteValue(entityKeyMember.Key);
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Type") : "Type");
			writer.WriteValue(type?.FullName);
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Value") : "Value");
			if ((object)type != null)
			{
				if (JsonSerializerInternalWriter.TryConvertToString(entityKeyMember.Value, type, out var s))
				{
					writer.WriteValue(s);
				}
				else
				{
					writer.WriteValue(entityKeyMember.Value);
				}
			}
			else
			{
				writer.WriteNull();
			}
			writer.WriteEndObject();
		}

		private static void ReadAndAssertProperty(JsonReader reader, string propertyName)
		{
			ReadAndAssert(reader);
			if (reader.TokenType != JsonToken.PropertyName || !string.Equals(reader.Value.ToString(), propertyName, StringComparison.OrdinalIgnoreCase))
			{
				throw new JsonSerializationException("Expected JSON property '{0}'.".FormatWith(CultureInfo.InvariantCulture, propertyName));
			}
		}

		private static void ReadAndAssert(JsonReader reader)
		{
			if (!reader.Read())
			{
				throw new JsonSerializationException("Unexpected end.");
			}
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper<IEntityKeyMember>(Activator.CreateInstance(objectType));
			ReadAndAssertProperty(reader, "Key");
			ReadAndAssert(reader);
			entityKeyMember.Key = reader.Value.ToString();
			ReadAndAssertProperty(reader, "Type");
			ReadAndAssert(reader);
			string typeName = reader.Value.ToString();
			Type type = Type.GetType(typeName);
			ReadAndAssertProperty(reader, "Value");
			ReadAndAssert(reader);
			entityKeyMember.Value = serializer.Deserialize(reader, type);
			ReadAndAssert(reader);
			return DynamicWrapper.GetUnderlyingObject(entityKeyMember);
		}

		public override bool CanConvert(Type objectType)
		{
			return objectType.AssignableToTypeName("System.Data.EntityKeyMember");
		}
	}
	public class KeyValuePairConverter : JsonConverter
	{
		private const string KeyName = "Key";

		private const string ValueName = "Value";

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			Type type = value.GetType();
			PropertyInfo property = type.GetProperty("Key");
			PropertyInfo property2 = type.GetProperty("Value");
			DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver;
			writer.WriteStartObject();
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Key") : "Key");
			serializer.Serialize(writer, ReflectionUtils.GetMemberValue(property, value));
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Value") : "Value");
			serializer.Serialize(writer, ReflectionUtils.GetMemberValue(property2, value));
			writer.WriteEndObject();
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			bool flag = ReflectionUtils.IsNullableType(objectType);
			if (reader.TokenType == JsonToken.Null)
			{
				if (!flag)
				{
					throw JsonSerializationException.Create(reader, "Cannot convert null value to KeyValuePair.");
				}
				return null;
			}
			Type type = (flag ? Nullable.GetUnderlyingType(objectType) : objectType);
			IList<Type> genericArguments = type.GetGenericArguments();
			Type objectType2 = genericArguments[0];
			Type objectType3 = genericArguments[1];
			object obj = null;
			object obj2 = null;
			reader.Read();
			while (reader.TokenType == JsonToken.PropertyName)
			{
				string a = reader.Value.ToString();
				if (string.Equals(a, "Key", StringComparison.OrdinalIgnoreCase))
				{
					reader.Read();
					obj = serializer.Deserialize(reader, objectType2);
				}
				else if (string.Equals(a, "Value", StringComparison.OrdinalIgnoreCase))
				{
					reader.Read();
					obj2 = serializer.Deserialize(reader, objectType3);
				}
				else
				{
					reader.Skip();
				}
				reader.Read();
			}
			return Activator.CreateInstance(type, obj, obj2);
		}

		public override bool CanConvert(Type objectType)
		{
			Type type = (ReflectionUtils.IsNullableType(objectType) ? Nullable.GetUnderlyingType(objectType) : objectType);
			if (type.IsValueType() && type.IsGenericType())
			{
				return (object)type.GetGenericTypeDefinition() == typeof(KeyValuePair<, >);
			}
			return false;
		}
	}
	public class BsonObjectIdConverter : JsonConverter
	{
		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			BsonObjectId bsonObjectId = (BsonObjectId)value;
			if (writer is BsonWriter bsonWriter)
			{
				bsonWriter.WriteObjectId(bsonObjectId.Value);
			}
			else
			{
				writer.WriteValue(bsonObjectId.Value);
			}
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.TokenType != JsonToken.Bytes)
			{
				throw new JsonSerializationException("Expected Bytes but got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
			}
			byte[] value = (byte[])reader.Value;
			return new BsonObjectId(value);
		}

		public override bool CanConvert(Type objectType)
		{
			return (object)objectType == typeof(BsonObjectId);
		}
	}
	public class RegexConverter : JsonConverter
	{
		private const string PatternName = "Pattern";

		private const string OptionsName = "Options";

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			Regex regex = (Regex)value;
			if (writer is BsonWriter writer2)
			{
				WriteBson(writer2, regex);
			}
			else
			{
				WriteJson(writer, regex, serializer);
			}
		}

		private bool HasFlag(RegexOptions options, RegexOptions flag)
		{
			return (options & flag) == flag;
		}

		private void WriteBson(BsonWriter writer, Regex regex)
		{
			string text = null;
			if (HasFlag(regex.Options, RegexOptions.IgnoreCase))
			{
				text += "i";
			}
			if (HasFlag(regex.Options, RegexOptions.Multiline))
			{
				text += "m";
			}
			if (HasFlag(regex.Options, RegexOptions.Singleline))
			{
				text += "s";
			}
			text += "u";
			if (HasFlag(regex.Options, RegexOptions.ExplicitCapture))
			{
				text += "x";
			}
			writer.WriteRegex(regex.ToString(), text);
		}

		private void WriteJson(JsonWriter writer, Regex regex, JsonSerializer serializer)
		{
			DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver;
			writer.WriteStartObject();
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Pattern") : "Pattern");
			writer.WriteValue(regex.ToString());
			writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Options") : "Options");
			serializer.Serialize(writer, regex.Options);
			writer.WriteEndObject();
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.TokenType == JsonToken.StartObject)
			{
				return ReadRegexObject(reader, serializer);
			}
			if (reader.TokenType == JsonToken.String)
			{
				return ReadRegexString(reader);
			}
			throw JsonSerializationException.Create(reader, "Unexpected token when reading Regex.");
		}

		private object ReadRegexString(JsonReader reader)
		{
			string text = (string)reader.Value;
			int num = text.LastIndexOf('/');
			string pattern = text.Substring(1, num - 1);
			string text2 = text.Substring(num + 1);
			RegexOptions regexOptions = RegexOptions.None;
			string text3 = text2;
			for (int i = 0; i < text3.Length; i++)
			{
				switch (text3[i])
				{
				case 'i':
					regexOptions |= RegexOptions.IgnoreCase;
					break;
				case 'm':
					regexOptions |= RegexOptions.Multiline;
					break;
				case 's':
					regexOptions |= RegexOptions.Singleline;
					break;
				case 'x':
					regexOptions |= RegexOptions.ExplicitCapture;
					break;
				}
			}
			return new Regex(pattern, regexOptions);
		}

		private Regex ReadRegexObject(JsonReader reader, JsonSerializer serializer)
		{
			string text = null;
			RegexOptions? regexOptions = null;
			while (reader.Read())
			{
				switch (reader.TokenType)
				{
				case JsonToken.PropertyName:
				{
					string a = reader.Value.ToString();
					if (!reader.Read())
					{
						throw JsonSerializationException.Create(reader, "Unexpected end when reading Regex.");
					}
					if (string.Equals(a, "Pattern", StringComparison.OrdinalIgnoreCase))
					{
						text = (string)reader.Value;
					}
					else if (string.Equals(a, "Options", StringComparison.OrdinalIgnoreCase))
					{
						regexOptions = serializer.Deserialize<RegexOptions>(reader);
					}
					else
					{
						reader.Skip();
					}
					break;
				}
				case JsonToken.EndObject:
					if (text == null)
					{
						throw JsonSerializationEx

plugins/MtGAPI/System.Xml.dll

Decompiled a week ago
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.Serialization.Advanced;
using System.Xml.XPath;
using System.Xml.Xsl;
using Microsoft.CSharp;
using Microsoft.VisualBasic;
using Mono.Xml;
using Mono.Xml.Schema;
using Mono.Xml.XPath;
using Mono.Xml.XPath.yyParser;
using Mono.Xml.XPath.yydebug;
using Mono.Xml.Xsl;
using Mono.Xml.Xsl.Operations;
using Mono.Xml.Xsl.yyParser;
using Mono.Xml.Xsl.yydebug;
using Mono.Xml2;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyDescription("System.Xml.dll")]
[assembly: AssemblyDefaultAlias("System.Xml.dll")]
[assembly: AssemblyCompany("MONO development team")]
[assembly: AssemblyProduct("MONO Common language infrastructure")]
[assembly: AssemblyCopyright("(c) various MONO Authors")]
[assembly: SatelliteContractVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.50727.1433")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("../ecma.pub")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyFileVersion("2.0.50727.1433")]
[assembly: CompilationRelaxations(CompilationRelaxations.NoStringInterning)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("System.Xml.dll")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace Mono.Xml.XPath
{
	internal class XPathParser
	{
		private class YYRules : MarshalByRefObject
		{
			public static string[] yyRule = new string[104]
			{
				"$accept : Expr", "Pattern : LocationPathPattern", "Pattern : Pattern BAR LocationPathPattern", "LocationPathPattern : SLASH", "LocationPathPattern : SLASH RelativePathPattern", "LocationPathPattern : IdKeyPattern", "LocationPathPattern : IdKeyPattern SLASH RelativePathPattern", "LocationPathPattern : IdKeyPattern SLASH2 RelativePathPattern", "LocationPathPattern : SLASH2 RelativePathPattern", "LocationPathPattern : RelativePathPattern",
				"IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL PAREN_CLOSE", "IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL COMMA LITERAL PAREN_CLOSE", "RelativePathPattern : StepPattern", "RelativePathPattern : RelativePathPattern SLASH StepPattern", "RelativePathPattern : RelativePathPattern SLASH2 StepPattern", "StepPattern : ChildOrAttributeAxisSpecifier NodeTest Predicates", "ChildOrAttributeAxisSpecifier : AbbreviatedAxisSpecifier", "ChildOrAttributeAxisSpecifier : CHILD COLON2", "ChildOrAttributeAxisSpecifier : ATTRIBUTE COLON2", "Predicates :",
				"Predicates : Predicates Predicate", "Expr : OrExpr", "OrExpr : AndExpr", "OrExpr : OrExpr OR AndExpr", "AndExpr : EqualityExpr", "AndExpr : AndExpr AND EqualityExpr", "EqualityExpr : RelationalExpr", "EqualityExpr : EqualityExpr EQ RelationalExpr", "EqualityExpr : EqualityExpr NE RelationalExpr", "RelationalExpr : AdditiveExpr",
				"RelationalExpr : RelationalExpr LT AdditiveExpr", "RelationalExpr : RelationalExpr GT AdditiveExpr", "RelationalExpr : RelationalExpr LE AdditiveExpr", "RelationalExpr : RelationalExpr GE AdditiveExpr", "AdditiveExpr : MultiplicativeExpr", "AdditiveExpr : AdditiveExpr PLUS MultiplicativeExpr", "AdditiveExpr : AdditiveExpr MINUS MultiplicativeExpr", "MultiplicativeExpr : UnaryExpr", "MultiplicativeExpr : MultiplicativeExpr MULTIPLY UnaryExpr", "MultiplicativeExpr : MultiplicativeExpr DIV UnaryExpr",
				"MultiplicativeExpr : MultiplicativeExpr MOD UnaryExpr", "UnaryExpr : UnionExpr", "UnaryExpr : MINUS UnaryExpr", "UnionExpr : PathExpr", "UnionExpr : UnionExpr BAR PathExpr", "PathExpr : LocationPath", "PathExpr : FilterExpr", "PathExpr : FilterExpr SLASH RelativeLocationPath", "PathExpr : FilterExpr SLASH2 RelativeLocationPath", "LocationPath : RelativeLocationPath",
				"LocationPath : AbsoluteLocationPath", "AbsoluteLocationPath : SLASH", "AbsoluteLocationPath : SLASH RelativeLocationPath", "AbsoluteLocationPath : SLASH2 RelativeLocationPath", "RelativeLocationPath : Step", "RelativeLocationPath : RelativeLocationPath SLASH Step", "RelativeLocationPath : RelativeLocationPath SLASH2 Step", "Step : AxisSpecifier NodeTest Predicates", "Step : AbbreviatedStep", "NodeTest : NameTest",
				"NodeTest : NodeType PAREN_OPEN PAREN_CLOSE", "NodeTest : PROCESSING_INSTRUCTION PAREN_OPEN OptionalLiteral PAREN_CLOSE", "NameTest : ASTERISK", "NameTest : QName", "AbbreviatedStep : DOT", "AbbreviatedStep : DOT2", "Predicates :", "Predicates : Predicates Predicate", "AxisSpecifier : AxisName COLON2", "AxisSpecifier : AbbreviatedAxisSpecifier",
				"AbbreviatedAxisSpecifier :", "AbbreviatedAxisSpecifier : AT", "NodeType : COMMENT", "NodeType : TEXT", "NodeType : PROCESSING_INSTRUCTION", "NodeType : NODE", "FilterExpr : PrimaryExpr", "FilterExpr : FilterExpr Predicate", "PrimaryExpr : DOLLAR QName", "PrimaryExpr : PAREN_OPEN Expr PAREN_CLOSE",
				"PrimaryExpr : LITERAL", "PrimaryExpr : NUMBER", "PrimaryExpr : FunctionCall", "FunctionCall : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE", "OptionalArgumentList :", "OptionalArgumentList : Expr OptionalArgumentListTail", "OptionalArgumentListTail :", "OptionalArgumentListTail : COMMA Expr OptionalArgumentListTail", "Predicate : BRACKET_OPEN Expr BRACKET_CLOSE", "AxisName : ANCESTOR",
				"AxisName : ANCESTOR_OR_SELF", "AxisName : ATTRIBUTE", "AxisName : CHILD", "AxisName : DESCENDANT", "AxisName : DESCENDANT_OR_SELF", "AxisName : FOLLOWING", "AxisName : FOLLOWING_SIBLING", "AxisName : NAMESPACE", "AxisName : PARENT", "AxisName : PRECEDING",
				"AxisName : PRECEDING_SIBLING", "AxisName : SELF", "OptionalLiteral :", "OptionalLiteral : LITERAL"
			};

			public static string getRule(int index)
			{
				return yyRule[index];
			}
		}

		internal IStaticXsltContext Context;

		private static int yacc_verbose_flag;

		public TextWriter ErrorOutput = Console.Out;

		public int eof_token;

		internal Mono.Xml.XPath.yydebug.yyDebug debug;

		protected static int yyFinal = 25;

		protected static string[] yyNames;

		private int yyExpectingState;

		protected int yyMax;

		private static short[] yyLhs;

		private static short[] yyLen;

		private static short[] yyDefRed;

		protected static short[] yyDgoto;

		protected static short[] yySindex;

		protected static short[] yyRindex;

		protected static short[] yyGindex;

		protected static short[] yyTable;

		protected static short[] yyCheck;

		public XPathParser()
			: this(null)
		{
		}

		internal XPathParser(IStaticXsltContext context)
		{
			Context = context;
			ErrorOutput = TextWriter.Null;
		}

		static XPathParser()
		{
			string[] array = new string[334];
			array[0] = "end-of-file";
			array[36] = "'$'";
			array[40] = "'('";
			array[41] = "')'";
			array[42] = "'*'";
			array[43] = "'+'";
			array[44] = "','";
			array[45] = "'-'";
			array[46] = "'.'";
			array[47] = "'/'";
			array[60] = "'<'";
			array[61] = "'='";
			array[62] = "'>'";
			array[64] = "'@'";
			array[91] = "'['";
			array[93] = "']'";
			array[124] = "'|'";
			array[257] = "ERROR";
			array[258] = "EOF";
			array[259] = "SLASH";
			array[260] = "SLASH2";
			array[261] = "\"//\"";
			array[262] = "DOT";
			array[263] = "DOT2";
			array[264] = "\"..\"";
			array[265] = "COLON2";
			array[266] = "\"::\"";
			array[267] = "COMMA";
			array[268] = "AT";
			array[269] = "FUNCTION_NAME";
			array[270] = "BRACKET_OPEN";
			array[271] = "BRACKET_CLOSE";
			array[272] = "PAREN_OPEN";
			array[273] = "PAREN_CLOSE";
			array[274] = "AND";
			array[275] = "\"and\"";
			array[276] = "OR";
			array[277] = "\"or\"";
			array[278] = "DIV";
			array[279] = "\"div\"";
			array[280] = "MOD";
			array[281] = "\"mod\"";
			array[282] = "PLUS";
			array[283] = "MINUS";
			array[284] = "ASTERISK";
			array[285] = "DOLLAR";
			array[286] = "BAR";
			array[287] = "EQ";
			array[288] = "NE";
			array[289] = "\"!=\"";
			array[290] = "LE";
			array[291] = "\"<=\"";
			array[292] = "GE";
			array[293] = "\">=\"";
			array[294] = "LT";
			array[295] = "GT";
			array[296] = "ANCESTOR";
			array[297] = "\"ancestor\"";
			array[298] = "ANCESTOR_OR_SELF";
			array[299] = "\"ancstor-or-self\"";
			array[300] = "ATTRIBUTE";
			array[301] = "\"attribute\"";
			array[302] = "CHILD";
			array[303] = "\"child\"";
			array[304] = "DESCENDANT";
			array[305] = "\"descendant\"";
			array[306] = "DESCENDANT_OR_SELF";
			array[307] = "\"descendant-or-self\"";
			array[308] = "FOLLOWING";
			array[309] = "\"following\"";
			array[310] = "FOLLOWING_SIBLING";
			array[311] = "\"sibling\"";
			array[312] = "NAMESPACE";
			array[313] = "\"NameSpace\"";
			array[314] = "PARENT";
			array[315] = "\"parent\"";
			array[316] = "PRECEDING";
			array[317] = "\"preceding\"";
			array[318] = "PRECEDING_SIBLING";
			array[319] = "\"preceding-sibling\"";
			array[320] = "SELF";
			array[321] = "\"self\"";
			array[322] = "COMMENT";
			array[323] = "\"comment\"";
			array[324] = "TEXT";
			array[325] = "\"text\"";
			array[326] = "PROCESSING_INSTRUCTION";
			array[327] = "\"processing-instruction\"";
			array[328] = "NODE";
			array[329] = "\"node\"";
			array[330] = "MULTIPLY";
			array[331] = "NUMBER";
			array[332] = "LITERAL";
			array[333] = "QName";
			yyNames = array;
			yyLhs = new short[104]
			{
				-1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
				4, 4, 3, 3, 3, 5, 6, 6, 6, 8,
				8, 0, 11, 11, 12, 12, 13, 13, 13, 14,
				14, 14, 14, 14, 15, 15, 15, 16, 16, 16,
				16, 17, 17, 18, 18, 19, 19, 19, 19, 20,
				20, 23, 23, 23, 22, 22, 22, 24, 24, 7,
				7, 7, 27, 27, 26, 26, 8, 8, 25, 25,
				9, 9, 28, 28, 28, 28, 21, 21, 31, 31,
				31, 31, 31, 32, 33, 33, 34, 34, 10, 30,
				30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
				30, 30, 29, 29
			};
			yyLen = new short[104]
			{
				2, 1, 3, 1, 2, 1, 3, 3, 2, 1,
				4, 6, 1, 3, 3, 3, 1, 2, 2, 0,
				2, 1, 1, 3, 1, 3, 1, 3, 3, 1,
				3, 3, 3, 3, 1, 3, 3, 1, 3, 3,
				3, 1, 2, 1, 3, 1, 1, 3, 3, 1,
				1, 1, 2, 2, 1, 3, 3, 3, 1, 1,
				3, 4, 1, 1, 1, 1, 0, 2, 2, 1,
				0, 1, 1, 1, 1, 1, 1, 2, 2, 3,
				1, 1, 1, 4, 0, 2, 0, 3, 3, 1,
				1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
				1, 1, 0, 1
			};
			yyDefRed = new short[118]
			{
				0, 0, 0, 64, 65, 71, 0, 0, 0, 0,
				89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
				99, 100, 101, 81, 80, 0, 69, 0, 0, 0,
				0, 0, 0, 37, 0, 43, 45, 0, 0, 50,
				54, 0, 58, 0, 76, 82, 0, 0, 0, 0,
				42, 78, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
				0, 0, 62, 72, 73, 0, 75, 63, 19, 59,
				0, 68, 0, 0, 79, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 39, 40, 38, 44, 0,
				0, 0, 55, 56, 0, 0, 0, 0, 85, 83,
				88, 103, 0, 20, 60, 0, 61, 87
			};
			yyDgoto = new short[35]
			{
				25, 0, 0, 0, 0, 0, 0, 78, 105, 26,
				69, 27, 28, 29, 30, 31, 32, 33, 34, 35,
				36, 37, 38, 39, 40, 41, 42, 79, 80, 112,
				43, 44, 45, 83, 108
			};
			yySindex = new short[118]
			{
				-254, -130, -130, 0, 0, 0, -270, -254, -254, -326,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, -266, -262, -271,
				-256, -201, -267, 0, -258, 0, 0, -238, -169, 0,
				0, -227, 0, -245, 0, 0, -169, -169, -254, -243,
				0, 0, -254, -254, -254, -254, -254, -254, -254, -254,
				-254, -254, -254, -254, -254, -189, -130, -130, -254, 0,
				-130, -130, 0, 0, 0, -237, 0, 0, 0, 0,
				-232, 0, -224, -228, 0, -262, -271, -256, -256, -201,
				-201, -201, -201, -267, -267, 0, 0, 0, 0, -169,
				-169, -222, 0, 0, -285, -219, -220, -254, 0, 0,
				0, 0, -218, 0, 0, -224, 0, 0
			};
			yyRindex = new short[118]
			{
				-176, 1, -176, 0, 0, 0, 0, -176, -176, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 19, 93, 37,
				27, 357, 276, 0, 250, 0, 0, 85, 114, 0,
				0, 0, 0, 0, 0, 0, 140, 169, -198, 0,
				0, 0, -176, -176, -176, -176, -176, -176, -176, -176,
				-176, -176, -176, -176, -176, -176, -176, -176, -176, 0,
				-176, -176, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, -208, 0, 0, 336, 484, 458, 476, 383,
				393, 419, 429, 302, 328, 0, 0, 0, 0, 195,
				224, 0, 0, 0, -206, 59, 0, -176, 0, 0,
				0, 0, 0, 0, 0, -208, 0, 0
			};
			yyGindex = new short[35]
			{
				-7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				-29, 0, 20, 31, 48, -33, 44, 25, 0, 29,
				0, 0, 2, 0, 66, 0, 0, 0, 0, 0,
				0, 0, 0, 0, -23
			};
			yyTable = new short[765]
			{
				49, 51, 48, 46, 47, 1, 2, 51, 3, 4,
				52, 62, 53, 63, 5, 6, 54, 55, 7, 21,
				81, 66, 67, 89, 90, 91, 92, 26, 65, 8,
				84, 9, 68, 50, 56, 104, 57, 24, 58, 59,
				106, 82, 10, 107, 11, 109, 12, 111, 13, 110,
				14, 68, 15, 114, 16, 116, 17, 72, 18, 57,
				19, 101, 20, 64, 21, 86, 22, 102, 99, 100,
				1, 2, 85, 3, 4, 84, 113, 23, 24, 5,
				6, 60, 61, 7, 86, 46, 70, 95, 96, 97,
				70, 71, 117, 22, 98, 73, 9, 74, 0, 75,
				115, 76, 87, 88, 93, 94, 77, 10, 70, 11,
				0, 12, 0, 13, 49, 14, 0, 15, 0, 16,
				0, 17, 0, 18, 70, 19, 70, 20, 70, 21,
				70, 22, 3, 4, 0, 70, 102, 103, 5, 0,
				52, 0, 23, 24, 0, 0, 70, 0, 70, 0,
				70, 0, 70, 0, 0, 0, 0, 70, 0, 0,
				0, 0, 0, 0, 0, 0, 10, 0, 11, 53,
				12, 0, 13, 0, 14, 0, 15, 0, 16, 0,
				17, 0, 18, 0, 19, 0, 20, 0, 21, 0,
				22, 0, 0, 0, 0, 47, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 48, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 51, 0,
				0, 0, 51, 0, 51, 51, 34, 51, 0, 51,
				0, 51, 0, 51, 51, 70, 21, 51, 51, 51,
				21, 51, 21, 51, 26, 51, 51, 0, 26, 0,
				26, 26, 35, 26, 24, 0, 0, 0, 24, 0,
				24, 24, 0, 24, 26, 26, 0, 0, 57, 57,
				0, 0, 0, 70, 0, 70, 57, 70, 36, 70,
				57, 51, 57, 57, 70, 57, 23, 57, 0, 57,
				0, 57, 57, 0, 0, 57, 57, 57, 0, 57,
				0, 57, 46, 57, 57, 0, 46, 29, 46, 46,
				22, 46, 0, 46, 22, 46, 22, 46, 46, 22,
				0, 46, 46, 46, 0, 46, 0, 46, 0, 46,
				46, 49, 0, 32, 0, 49, 0, 49, 49, 57,
				49, 0, 49, 33, 49, 0, 49, 49, 0, 0,
				49, 49, 49, 0, 49, 0, 49, 52, 49, 49,
				0, 52, 0, 52, 52, 46, 52, 0, 52, 30,
				52, 0, 52, 52, 0, 0, 52, 52, 52, 31,
				52, 0, 52, 0, 52, 52, 53, 0, 0, 0,
				53, 0, 53, 53, 49, 53, 0, 53, 0, 53,
				0, 53, 53, 0, 0, 53, 53, 53, 27, 53,
				0, 53, 47, 53, 53, 0, 47, 0, 47, 47,
				52, 47, 0, 47, 0, 47, 28, 47, 47, 0,
				0, 47, 47, 47, 25, 47, 0, 47, 0, 47,
				47, 48, 0, 0, 0, 48, 0, 48, 48, 53,
				48, 0, 48, 0, 48, 0, 48, 48, 0, 0,
				48, 48, 48, 0, 48, 0, 48, 41, 48, 48,
				0, 41, 0, 41, 41, 47, 41, 0, 41, 0,
				41, 0, 41, 41, 0, 0, 0, 41, 41, 0,
				41, 0, 41, 34, 41, 41, 0, 34, 0, 34,
				34, 0, 34, 0, 48, 0, 0, 0, 34, 34,
				0, 0, 0, 34, 34, 0, 34, 0, 34, 35,
				34, 34, 0, 35, 0, 35, 35, 0, 35, 0,
				41, 0, 0, 0, 35, 35, 0, 0, 0, 35,
				35, 0, 35, 0, 35, 36, 35, 35, 0, 36,
				0, 36, 36, 23, 36, 0, 0, 23, 0, 23,
				36, 36, 23, 0, 0, 36, 36, 0, 36, 0,
				36, 0, 36, 36, 29, 0, 0, 0, 29, 0,
				29, 29, 0, 29, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 29, 29, 0, 29, 0, 29,
				32, 29, 29, 0, 32, 0, 32, 32, 0, 32,
				33, 0, 0, 0, 33, 0, 33, 33, 0, 33,
				32, 32, 0, 32, 0, 32, 0, 32, 32, 0,
				33, 33, 0, 33, 0, 33, 30, 33, 33, 0,
				30, 0, 30, 30, 0, 30, 31, 0, 0, 0,
				31, 0, 31, 31, 0, 31, 30, 30, 0, 30,
				0, 30, 0, 30, 30, 0, 31, 31, 0, 31,
				0, 31, 0, 31, 31, 27, 0, 0, 0, 27,
				0, 27, 27, 0, 27, 0, 0, 0, 0, 0,
				0, 0, 0, 28, 0, 27, 27, 28, 0, 28,
				28, 25, 28, 0, 0, 25, 0, 25, 25, 0,
				25, 0, 0, 28, 28
			};
			yyCheck = new short[765]
			{
				7, 0, 272, 1, 2, 259, 260, 333, 262, 263,
				276, 278, 274, 280, 268, 269, 287, 288, 272, 0,
				265, 259, 260, 56, 57, 58, 59, 0, 286, 283,
				273, 285, 270, 8, 290, 272, 292, 0, 294, 295,
				272, 48, 296, 267, 298, 273, 300, 332, 302, 271,
				304, 270, 306, 273, 308, 273, 310, 284, 312, 0,
				314, 68, 316, 330, 318, 273, 320, 273, 66, 67,
				259, 260, 52, 262, 263, 273, 105, 331, 332, 268,
				269, 282, 283, 272, 53, 0, 284, 62, 63, 64,
				259, 260, 115, 0, 65, 322, 285, 324, -1, 326,
				107, 328, 54, 55, 60, 61, 333, 296, 284, 298,
				-1, 300, -1, 302, 0, 304, -1, 306, -1, 308,
				-1, 310, -1, 312, 322, 314, 324, 316, 326, 318,
				328, 320, 262, 263, -1, 333, 70, 71, 268, -1,
				0, -1, 331, 332, -1, -1, 322, -1, 324, -1,
				326, -1, 328, -1, -1, -1, -1, 333, -1, -1,
				-1, -1, -1, -1, -1, -1, 296, -1, 298, 0,
				300, -1, 302, -1, 304, -1, 306, -1, 308, -1,
				310, -1, 312, -1, 314, -1, 316, -1, 318, -1,
				320, -1, -1, -1, -1, 0, -1, -1, -1, -1,
				-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, 0, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
				0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, -1, -1, -1, -1, 267, -1,
				-1, -1, 271, -1, 273, 274, 0, 276, -1, 278,
				-1, 280, -1, 282, 283, 284, 267, 286, 287, 288,
				271, 290, 273, 292, 267, 294, 295, -1, 271, -1,
				273, 274, 0, 276, 267, -1, -1, -1, 271, -1,
				273, 274, -1, 276, 287, 288, -1, -1, 259, 260,
				-1, -1, -1, 322, -1, 324, 267, 326, 0, 328,
				271, 330, 273, 274, 333, 276, 0, 278, -1, 280,
				-1, 282, 283, -1, -1, 286, 287, 288, -1, 290,
				-1, 292, 267, 294, 295, -1, 271, 0, 273, 274,
				267, 276, -1, 278, 271, 280, 273, 282, 283, 276,
				-1, 286, 287, 288, -1, 290, -1, 292, -1, 294,
				295, 267, -1, 0, -1, 271, -1, 273, 274, 330,
				276, -1, 278, 0, 280, -1, 282, 283, -1, -1,
				286, 287, 288, -1, 290, -1, 292, 267, 294, 295,
				-1, 271, -1, 273, 274, 330, 276, -1, 278, 0,
				280, -1, 282, 283, -1, -1, 286, 287, 288, 0,
				290, -1, 292, -1, 294, 295, 267, -1, -1, -1,
				271, -1, 273, 274, 330, 276, -1, 278, -1, 280,
				-1, 282, 283, -1, -1, 286, 287, 288, 0, 290,
				-1, 292, 267, 294, 295, -1, 271, -1, 273, 274,
				330, 276, -1, 278, -1, 280, 0, 282, 283, -1,
				-1, 286, 287, 288, 0, 290, -1, 292, -1, 294,
				295, 267, -1, -1, -1, 271, -1, 273, 274, 330,
				276, -1, 278, -1, 280, -1, 282, 283, -1, -1,
				286, 287, 288, -1, 290, -1, 292, 267, 294, 295,
				-1, 271, -1, 273, 274, 330, 276, -1, 278, -1,
				280, -1, 282, 283, -1, -1, -1, 287, 288, -1,
				290, -1, 292, 267, 294, 295, -1, 271, -1, 273,
				274, -1, 276, -1, 330, -1, -1, -1, 282, 283,
				-1, -1, -1, 287, 288, -1, 290, -1, 292, 267,
				294, 295, -1, 271, -1, 273, 274, -1, 276, -1,
				330, -1, -1, -1, 282, 283, -1, -1, -1, 287,
				288, -1, 290, -1, 292, 267, 294, 295, -1, 271,
				-1, 273, 274, 267, 276, -1, -1, 271, -1, 273,
				282, 283, 276, -1, -1, 287, 288, -1, 290, -1,
				292, -1, 294, 295, 267, -1, -1, -1, 271, -1,
				273, 274, -1, 276, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, 287, 288, -1, 290, -1, 292,
				267, 294, 295, -1, 271, -1, 273, 274, -1, 276,
				267, -1, -1, -1, 271, -1, 273, 274, -1, 276,
				287, 288, -1, 290, -1, 292, -1, 294, 295, -1,
				287, 288, -1, 290, -1, 292, 267, 294, 295, -1,
				271, -1, 273, 274, -1, 276, 267, -1, -1, -1,
				271, -1, 273, 274, -1, 276, 287, 288, -1, 290,
				-1, 292, -1, 294, 295, -1, 287, 288, -1, 290,
				-1, 292, -1, 294, 295, 267, -1, -1, -1, 271,
				-1, 273, 274, -1, 276, -1, -1, -1, -1, -1,
				-1, -1, -1, 267, -1, 287, 288, 271, -1, 273,
				274, 267, 276, -1, -1, 271, -1, 273, 274, -1,
				276, -1, -1, 287, 288
			};
		}

		internal Expression Compile(string xpath)
		{
			try
			{
				Tokenizer yyLex = new Tokenizer(xpath);
				return (Expression)yyparse(yyLex);
			}
			catch (XPathException)
			{
				throw;
			}
			catch (Exception innerException)
			{
				throw new XPathException("Error during parse of " + xpath, innerException);
			}
		}

		private NodeSet CreateNodeTest(Axes axis, object nodeTest, ArrayList plist)
		{
			NodeSet nodeSet = CreateNodeTest(axis, nodeTest);
			if (plist != null)
			{
				for (int i = 0; i < plist.Count; i++)
				{
					nodeSet = new ExprFilter(nodeSet, (Expression)plist[i]);
				}
			}
			return nodeSet;
		}

		private NodeTest CreateNodeTest(Axes axis, object test)
		{
			if (test is XPathNodeType)
			{
				return new NodeTypeTest(axis, (XPathNodeType)(int)test, null);
			}
			if (test is string || test == null)
			{
				return new NodeTypeTest(axis, XPathNodeType.ProcessingInstruction, (string)test);
			}
			XmlQualifiedName xmlQualifiedName = (XmlQualifiedName)test;
			if (xmlQualifiedName == XmlQualifiedName.Empty)
			{
				return new NodeTypeTest(axis);
			}
			return new NodeNameTest(axis, xmlQualifiedName, Context);
		}

		public void yyerror(string message)
		{
			yyerror(message, null);
		}

		public void yyerror(string message, string[] expected)
		{
			if (yacc_verbose_flag > 0 && expected != null && expected.Length > 0)
			{
				ErrorOutput.Write(message + ", expecting");
				for (int i = 0; i < expected.Length; i++)
				{
					ErrorOutput.Write(" " + expected[i]);
				}
				ErrorOutput.WriteLine();
			}
			else
			{
				ErrorOutput.WriteLine(message);
			}
		}

		public static string yyname(int token)
		{
			if (token < 0 || token > yyNames.Length)
			{
				return "[illegal]";
			}
			string result;
			if ((result = yyNames[token]) != null)
			{
				return result;
			}
			return "[unknown]";
		}

		protected int[] yyExpectingTokens(int state)
		{
			int num = 0;
			bool[] array = new bool[yyNames.Length];
			int num2;
			int i;
			if ((num2 = yySindex[state]) != 0)
			{
				for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++)
				{
					if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null)
					{
						num++;
						array[i] = true;
					}
				}
			}
			if ((num2 = yyRindex[state]) != 0)
			{
				for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++)
				{
					if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null)
					{
						num++;
						array[i] = true;
					}
				}
			}
			int[] array2 = new int[num];
			num2 = (i = 0);
			while (num2 < num)
			{
				if (array[i])
				{
					array2[num2++] = i;
				}
				i++;
			}
			return array2;
		}

		protected string[] yyExpecting(int state)
		{
			int[] array = yyExpectingTokens(state);
			string[] array2 = new string[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i++] = yyNames[array[i]];
			}
			return array2;
		}

		internal object yyparse(Mono.Xml.XPath.yyParser.yyInput yyLex, object yyd)
		{
			debug = (Mono.Xml.XPath.yydebug.yyDebug)yyd;
			return yyparse(yyLex);
		}

		protected object yyDefault(object first)
		{
			return first;
		}

		internal object yyparse(Mono.Xml.XPath.yyParser.yyInput yyLex)
		{
			if (yyMax <= 0)
			{
				yyMax = 256;
			}
			int num = 0;
			int[] array = new int[yyMax];
			object obj = null;
			object[] array2 = new object[yyMax];
			int num2 = -1;
			int num3 = 0;
			int num4 = 0;
			while (true)
			{
				if (num4 >= array.Length)
				{
					int[] array3 = new int[array.Length + yyMax];
					array.CopyTo(array3, 0);
					array = array3;
					object[] array4 = new object[array2.Length + yyMax];
					array2.CopyTo(array4, 0);
					array2 = array4;
				}
				array[num4] = num;
				array2[num4] = obj;
				if (debug != null)
				{
					debug.push(num, obj);
				}
				while (true)
				{
					int num5;
					if ((num5 = yyDefRed[num]) == 0)
					{
						if (num2 < 0)
						{
							num2 = (yyLex.advance() ? yyLex.token() : 0);
							if (debug != null)
							{
								debug.lex(num, num2, yyname(num2), yyLex.value());
							}
						}
						if ((num5 = yySindex[num]) != 0 && (num5 += num2) >= 0 && num5 < yyTable.Length && yyCheck[num5] == num2)
						{
							if (debug != null)
							{
								debug.shift(num, yyTable[num5], num3 - 1);
							}
							num = yyTable[num5];
							obj = yyLex.value();
							num2 = -1;
							if (num3 > 0)
							{
								num3--;
							}
							break;
						}
						if ((num5 = yyRindex[num]) == 0 || (num5 += num2) < 0 || num5 >= yyTable.Length || yyCheck[num5] != num2)
						{
							switch (num3)
							{
							case 0:
								yyExpectingState = num;
								if (debug != null)
								{
									debug.error("syntax error");
								}
								if (num2 == 0 || num2 == eof_token)
								{
									throw new Mono.Xml.XPath.yyParser.yyUnexpectedEof();
								}
								break;
							case 1:
							case 2:
								break;
							case 3:
								goto IL_02f5;
							default:
								goto IL_034b;
							}
							num3 = 3;
							while ((num5 = yySindex[array[num4]]) == 0 || (num5 += 256) < 0 || num5 >= yyTable.Length || yyCheck[num5] != 256)
							{
								if (debug != null)
								{
									debug.pop(array[num4]);
								}
								if (--num4 < 0)
								{
									if (debug != null)
									{
										debug.reject();
									}
									throw new Mono.Xml.XPath.yyParser.yyException("irrecoverable syntax error");
								}
							}
							if (debug != null)
							{
								debug.shift(array[num4], yyTable[num5], 3);
							}
							num = yyTable[num5];
							obj = yyLex.value();
							break;
						}
						num5 = yyTable[num5];
					}
					goto IL_034b;
					IL_02f5:
					if (num2 == 0)
					{
						if (debug != null)
						{
							debug.reject();
						}
						throw new Mono.Xml.XPath.yyParser.yyException("irrecoverable syntax error at end-of-file");
					}
					if (debug != null)
					{
						debug.discard(num, num2, yyname(num2), yyLex.value());
					}
					num2 = -1;
					continue;
					IL_034b:
					int num6 = num4 + 1 - yyLen[num5];
					if (debug != null)
					{
						debug.reduce(num, array[num6 - 1], num5, YYRules.getRule(num5), yyLen[num5]);
					}
					obj = yyDefault((num6 <= num4) ? array2[num6] : null);
					switch (num5)
					{
					case 2:
						obj = new ExprUNION((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 3:
						obj = new ExprRoot();
						break;
					case 4:
						obj = new ExprSLASH(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 6:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 7:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 8:
						obj = new ExprSLASH2(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 10:
					{
						XmlQualifiedName xmlQualifiedName2 = (XmlQualifiedName)array2[-3 + num4];
						if (xmlQualifiedName2.Name != "id" || xmlQualifiedName2.Namespace != string.Empty)
						{
							throw new XPathException($"Expected 'id' but got '{xmlQualifiedName2}'");
						}
						obj = ExprFunctionCall.Factory(xmlQualifiedName2, new FunctionArguments(new ExprLiteral((string)array2[-1 + num4]), null), Context);
						break;
					}
					case 11:
					{
						XmlQualifiedName xmlQualifiedName = (XmlQualifiedName)array2[-5 + num4];
						if (xmlQualifiedName.Name != "key" || xmlQualifiedName.Namespace != string.Empty)
						{
							throw new XPathException($"Expected 'key' but got '{xmlQualifiedName}'");
						}
						obj = Context.TryGetFunction(xmlQualifiedName, new FunctionArguments(new ExprLiteral((string)array2[-3 + num4]), new FunctionArguments(new ExprLiteral((string)array2[-1 + num4]), null)));
						break;
					}
					case 13:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 14:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 15:
						obj = CreateNodeTest((Axes)(int)array2[-2 + num4], array2[-1 + num4], (ArrayList)array2[0 + num4]);
						break;
					case 17:
						obj = Axes.Child;
						break;
					case 18:
						obj = Axes.Attribute;
						break;
					case 19:
						obj = null;
						break;
					case 20:
					{
						ArrayList arrayList2 = (ArrayList)array2[-1 + num4];
						if (arrayList2 == null)
						{
							arrayList2 = new ArrayList();
						}
						arrayList2.Add((Expression)array2[0 + num4]);
						obj = arrayList2;
						break;
					}
					case 23:
						obj = new ExprOR((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 25:
						obj = new ExprAND((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 27:
						obj = new ExprEQ((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 28:
						obj = new ExprNE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 30:
						obj = new ExprLT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 31:
						obj = new ExprGT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 32:
						obj = new ExprLE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 33:
						obj = new ExprGE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 35:
						obj = new ExprPLUS((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 36:
						obj = new ExprMINUS((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 38:
						obj = new ExprMULT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 39:
						obj = new ExprDIV((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 40:
						obj = new ExprMOD((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 42:
						obj = new ExprNEG((Expression)array2[0 + num4]);
						break;
					case 44:
						obj = new ExprUNION((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 47:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 48:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 51:
						obj = new ExprRoot();
						break;
					case 52:
						obj = new ExprSLASH(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 53:
						obj = new ExprSLASH2(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 55:
						obj = new ExprSLASH((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 56:
						obj = new ExprSLASH2((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 57:
						obj = CreateNodeTest((Axes)(int)array2[-2 + num4], array2[-1 + num4], (ArrayList)array2[0 + num4]);
						break;
					case 60:
						obj = (XPathNodeType)(int)array2[-2 + num4];
						break;
					case 61:
						obj = (string)array2[-1 + num4];
						break;
					case 62:
						obj = XmlQualifiedName.Empty;
						break;
					case 64:
						obj = new NodeTypeTest(Axes.Self, XPathNodeType.All);
						break;
					case 65:
						obj = new NodeTypeTest(Axes.Parent, XPathNodeType.All);
						break;
					case 66:
						obj = null;
						break;
					case 67:
					{
						ArrayList arrayList = (ArrayList)array2[-1 + num4];
						if (arrayList == null)
						{
							arrayList = new ArrayList();
						}
						arrayList.Add(array2[0 + num4]);
						obj = arrayList;
						break;
					}
					case 68:
						obj = array2[-1 + num4];
						break;
					case 70:
						obj = Axes.Child;
						break;
					case 71:
						obj = Axes.Attribute;
						break;
					case 72:
						obj = XPathNodeType.Comment;
						break;
					case 73:
						obj = XPathNodeType.Text;
						break;
					case 74:
						obj = XPathNodeType.ProcessingInstruction;
						break;
					case 75:
						obj = XPathNodeType.All;
						break;
					case 77:
						obj = new ExprFilter((Expression)array2[-1 + num4], (Expression)array2[0 + num4]);
						break;
					case 78:
					{
						Expression expression2 = null;
						if (Context != null)
						{
							expression2 = Context.TryGetVariable(((XmlQualifiedName)array2[0 + num4]).ToString());
						}
						if (expression2 == null)
						{
							expression2 = new ExprVariable((XmlQualifiedName)array2[0 + num4], Context);
						}
						obj = expression2;
						break;
					}
					case 79:
						obj = new ExprParens((Expression)array2[-1 + num4]);
						break;
					case 80:
						obj = new ExprLiteral((string)array2[0 + num4]);
						break;
					case 81:
						obj = new ExprNumber((double)array2[0 + num4]);
						break;
					case 83:
					{
						Expression expression = null;
						if (Context != null)
						{
							expression = Context.TryGetFunction((XmlQualifiedName)array2[-3 + num4], (FunctionArguments)array2[-1 + num4]);
						}
						if (expression == null)
						{
							expression = ExprFunctionCall.Factory((XmlQualifiedName)array2[-3 + num4], (FunctionArguments)array2[-1 + num4], Context);
						}
						obj = expression;
						break;
					}
					case 85:
						obj = new FunctionArguments((Expression)array2[-1 + num4], (FunctionArguments)array2[0 + num4]);
						break;
					case 87:
						obj = new FunctionArguments((Expression)array2[-1 + num4], (FunctionArguments)array2[0 + num4]);
						break;
					case 88:
						obj = array2[-1 + num4];
						break;
					case 89:
						obj = Axes.Ancestor;
						break;
					case 90:
						obj = Axes.AncestorOrSelf;
						break;
					case 91:
						obj = Axes.Attribute;
						break;
					case 92:
						obj = Axes.Child;
						break;
					case 93:
						obj = Axes.Descendant;
						break;
					case 94:
						obj = Axes.DescendantOrSelf;
						break;
					case 95:
						obj = Axes.Following;
						break;
					case 96:
						obj = Axes.FollowingSibling;
						break;
					case 97:
						obj = Axes.Namespace;
						break;
					case 98:
						obj = Axes.Parent;
						break;
					case 99:
						obj = Axes.Preceding;
						break;
					case 100:
						obj = Axes.PrecedingSibling;
						break;
					case 101:
						obj = Axes.Self;
						break;
					}
					num4 -= yyLen[num5];
					num = array[num4];
					int num7 = yyLhs[num5];
					if (num == 0 && num7 == 0)
					{
						if (debug != null)
						{
							debug.shift(0, yyFinal);
						}
						num = yyFinal;
						if (num2 < 0)
						{
							num2 = (yyLex.advance() ? yyLex.token() : 0);
							if (debug != null)
							{
								debug.lex(num, num2, yyname(num2), yyLex.value());
							}
						}
						if (num2 == 0)
						{
							if (debug != null)
							{
								debug.accept(obj);
							}
							return obj;
						}
						break;
					}
					num = (((num5 = yyGindex[num7]) == 0 || (num5 += num) < 0 || num5 >= yyTable.Length || yyCheck[num5] != num) ? yyDgoto[num7] : yyTable[num5]);
					if (debug != null)
					{
						debug.shift(array[num4], num);
					}
					break;
				}
				num4++;
			}
		}
	}
}
namespace Mono.Xml.XPath.yydebug
{
	internal interface yyDebug
	{
		void push(int state, object value);

		void lex(int state, int token, string name, object value);

		void shift(int from, int to, int errorFlag);

		void pop(int state);

		void discard(int state, int token, string name, object value);

		void reduce(int from, int to, int rule, string text, int len);

		void shift(int from, int to);

		void accept(object value);

		void error(string message);

		void reject();
	}
	internal class yyDebugSimple : yyDebug
	{
		private void println(string s)
		{
			Console.Error.WriteLine(s);
		}

		public void push(int state, object value)
		{
			println("push\tstate " + state + "\tvalue " + value);
		}

		public void lex(int state, int token, string name, object value)
		{
			println("lex\tstate " + state + "\treading " + name + "\tvalue " + value);
		}

		public void shift(int from, int to, int errorFlag)
		{
			switch (errorFlag)
			{
			default:
				println("shift\tfrom state " + from + " to " + to);
				break;
			case 0:
			case 1:
			case 2:
				println("shift\tfrom state " + from + " to " + to + "\t" + errorFlag + " left to recover");
				break;
			case 3:
				println("shift\tfrom state " + from + " to " + to + "\ton error");
				break;
			}
		}

		public void pop(int state)
		{
			println("pop\tstate " + state + "\ton error");
		}

		public void discard(int state, int token, string name, object value)
		{
			println("discard\tstate " + state + "\ttoken " + name + "\tvalue " + value);
		}

		public void reduce(int from, int to, int rule, string text, int len)
		{
			println("reduce\tstate " + from + "\tuncover " + to + "\trule (" + rule + ") " + text);
		}

		public void shift(int from, int to)
		{
			println("goto\tfrom state " + from + " to " + to);
		}

		public void accept(object value)
		{
			println("accept\tvalue " + value);
		}

		public void error(string message)
		{
			println("error\t" + message);
		}

		public void reject()
		{
			println("reject");
		}
	}
}
namespace Mono.Xml.XPath
{
	internal class Token
	{
		public const int ERROR = 257;

		public const int EOF = 258;

		public const int SLASH = 259;

		public const int SLASH2 = 260;

		public const int DOT = 262;

		public const int DOT2 = 263;

		public const int COLON2 = 265;

		public const int COMMA = 267;

		public const int AT = 268;

		public const int FUNCTION_NAME = 269;

		public const int BRACKET_OPEN = 270;

		public const int BRACKET_CLOSE = 271;

		public const int PAREN_OPEN = 272;

		public const int PAREN_CLOSE = 273;

		public const int AND = 274;

		public const int and = 275;

		public const int OR = 276;

		public const int or = 277;

		public const int DIV = 278;

		public const int div = 279;

		public const int MOD = 280;

		public const int mod = 281;

		public const int PLUS = 282;

		public const int MINUS = 283;

		public const int ASTERISK = 284;

		public const int DOLLAR = 285;

		public const int BAR = 286;

		public const int EQ = 287;

		public const int NE = 288;

		public const int LE = 290;

		public const int GE = 292;

		public const int LT = 294;

		public const int GT = 295;

		public const int ANCESTOR = 296;

		public const int ancestor = 297;

		public const int ANCESTOR_OR_SELF = 298;

		public const int ATTRIBUTE = 300;

		public const int attribute = 301;

		public const int CHILD = 302;

		public const int child = 303;

		public const int DESCENDANT = 304;

		public const int descendant = 305;

		public const int DESCENDANT_OR_SELF = 306;

		public const int FOLLOWING = 308;

		public const int following = 309;

		public const int FOLLOWING_SIBLING = 310;

		public const int sibling = 311;

		public const int NAMESPACE = 312;

		public const int NameSpace = 313;

		public const int PARENT = 314;

		public const int parent = 315;

		public const int PRECEDING = 316;

		public const int preceding = 317;

		public const int PRECEDING_SIBLING = 318;

		public const int SELF = 320;

		public const int self = 321;

		public const int COMMENT = 322;

		public const int comment = 323;

		public const int TEXT = 324;

		public const int text = 325;

		public const int PROCESSING_INSTRUCTION = 326;

		public const int NODE = 328;

		public const int node = 329;

		public const int MULTIPLY = 330;

		public const int NUMBER = 331;

		public const int LITERAL = 332;

		public const int QName = 333;

		public const int yyErrorCode = 256;
	}
}
namespace Mono.Xml.XPath.yyParser
{
	internal class yyException : Exception
	{
		public yyException(string message)
			: base(message)
		{
		}
	}
	internal class yyUnexpectedEof : yyException
	{
		public yyUnexpectedEof(string message)
			: base(message)
		{
		}

		public yyUnexpectedEof()
			: base(string.Empty)
		{
		}
	}
	internal interface yyInput
	{
		bool advance();

		int token();

		object value();
	}
}
namespace Mono.Xml.Xsl
{
	internal class XsltPatternParser
	{
		private class YYRules : MarshalByRefObject
		{
			public static string[] yyRule = new string[104]
			{
				"$accept : Pattern", "Pattern : LocationPathPattern", "Pattern : Pattern BAR LocationPathPattern", "LocationPathPattern : SLASH", "LocationPathPattern : SLASH RelativePathPattern", "LocationPathPattern : IdKeyPattern", "LocationPathPattern : IdKeyPattern SLASH RelativePathPattern", "LocationPathPattern : IdKeyPattern SLASH2 RelativePathPattern", "LocationPathPattern : SLASH2 RelativePathPattern", "LocationPathPattern : RelativePathPattern",
				"IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL PAREN_CLOSE", "IdKeyPattern : FUNCTION_NAME PAREN_OPEN LITERAL COMMA LITERAL PAREN_CLOSE", "RelativePathPattern : StepPattern", "RelativePathPattern : RelativePathPattern SLASH StepPattern", "RelativePathPattern : RelativePathPattern SLASH2 StepPattern", "StepPattern : ChildOrAttributeAxisSpecifier NodeTest Predicates", "ChildOrAttributeAxisSpecifier : AbbreviatedAxisSpecifier", "ChildOrAttributeAxisSpecifier : CHILD COLON2", "ChildOrAttributeAxisSpecifier : ATTRIBUTE COLON2", "Predicates :",
				"Predicates : Predicates Predicate", "Expr : OrExpr", "OrExpr : AndExpr", "OrExpr : OrExpr OR AndExpr", "AndExpr : EqualityExpr", "AndExpr : AndExpr AND EqualityExpr", "EqualityExpr : RelationalExpr", "EqualityExpr : EqualityExpr EQ RelationalExpr", "EqualityExpr : EqualityExpr NE RelationalExpr", "RelationalExpr : AdditiveExpr",
				"RelationalExpr : RelationalExpr LT AdditiveExpr", "RelationalExpr : RelationalExpr GT AdditiveExpr", "RelationalExpr : RelationalExpr LE AdditiveExpr", "RelationalExpr : RelationalExpr GE AdditiveExpr", "AdditiveExpr : MultiplicativeExpr", "AdditiveExpr : AdditiveExpr PLUS MultiplicativeExpr", "AdditiveExpr : AdditiveExpr MINUS MultiplicativeExpr", "MultiplicativeExpr : UnaryExpr", "MultiplicativeExpr : MultiplicativeExpr MULTIPLY UnaryExpr", "MultiplicativeExpr : MultiplicativeExpr DIV UnaryExpr",
				"MultiplicativeExpr : MultiplicativeExpr MOD UnaryExpr", "UnaryExpr : UnionExpr", "UnaryExpr : MINUS UnaryExpr", "UnionExpr : PathExpr", "UnionExpr : UnionExpr BAR PathExpr", "PathExpr : LocationPath", "PathExpr : FilterExpr", "PathExpr : FilterExpr SLASH RelativeLocationPath", "PathExpr : FilterExpr SLASH2 RelativeLocationPath", "LocationPath : RelativeLocationPath",
				"LocationPath : AbsoluteLocationPath", "AbsoluteLocationPath : SLASH", "AbsoluteLocationPath : SLASH RelativeLocationPath", "AbsoluteLocationPath : SLASH2 RelativeLocationPath", "RelativeLocationPath : Step", "RelativeLocationPath : RelativeLocationPath SLASH Step", "RelativeLocationPath : RelativeLocationPath SLASH2 Step", "Step : AxisSpecifier NodeTest Predicates", "Step : AbbreviatedStep", "NodeTest : NameTest",
				"NodeTest : NodeType PAREN_OPEN PAREN_CLOSE", "NodeTest : PROCESSING_INSTRUCTION PAREN_OPEN OptionalLiteral PAREN_CLOSE", "NameTest : ASTERISK", "NameTest : QName", "AbbreviatedStep : DOT", "AbbreviatedStep : DOT2", "Predicates :", "Predicates : Predicates Predicate", "AxisSpecifier : AxisName COLON2", "AxisSpecifier : AbbreviatedAxisSpecifier",
				"AbbreviatedAxisSpecifier :", "AbbreviatedAxisSpecifier : AT", "NodeType : COMMENT", "NodeType : TEXT", "NodeType : PROCESSING_INSTRUCTION", "NodeType : NODE", "FilterExpr : PrimaryExpr", "FilterExpr : FilterExpr Predicate", "PrimaryExpr : DOLLAR QName", "PrimaryExpr : PAREN_OPEN Expr PAREN_CLOSE",
				"PrimaryExpr : LITERAL", "PrimaryExpr : NUMBER", "PrimaryExpr : FunctionCall", "FunctionCall : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE", "OptionalArgumentList :", "OptionalArgumentList : Expr OptionalArgumentListTail", "OptionalArgumentListTail :", "OptionalArgumentListTail : COMMA Expr OptionalArgumentListTail", "Predicate : BRACKET_OPEN Expr BRACKET_CLOSE", "AxisName : ANCESTOR",
				"AxisName : ANCESTOR_OR_SELF", "AxisName : ATTRIBUTE", "AxisName : CHILD", "AxisName : DESCENDANT", "AxisName : DESCENDANT_OR_SELF", "AxisName : FOLLOWING", "AxisName : FOLLOWING_SIBLING", "AxisName : NAMESPACE", "AxisName : PARENT", "AxisName : PRECEDING",
				"AxisName : PRECEDING_SIBLING", "AxisName : SELF", "OptionalLiteral :", "OptionalLiteral : LITERAL"
			};

			public static string getRule(int index)
			{
				return yyRule[index];
			}
		}

		internal IStaticXsltContext Context;

		private static int yacc_verbose_flag;

		public TextWriter ErrorOutput = Console.Out;

		public int eof_token;

		internal Mono.Xml.Xsl.yydebug.yyDebug debug;

		protected static int yyFinal = 7;

		protected static string[] yyNames;

		private int yyExpectingState;

		protected int yyMax;

		private static short[] yyLhs;

		private static short[] yyLen;

		private static short[] yyDefRed;

		protected static short[] yyDgoto;

		protected static short[] yySindex;

		protected static short[] yyRindex;

		protected static short[] yyGindex;

		protected static short[] yyTable;

		protected static short[] yyCheck;

		public XsltPatternParser()
			: this(null)
		{
		}

		internal XsltPatternParser(IStaticXsltContext context)
		{
			Context = context;
			ErrorOutput = TextWriter.Null;
		}

		static XsltPatternParser()
		{
			string[] array = new string[334];
			array[0] = "end-of-file";
			array[36] = "'$'";
			array[40] = "'('";
			array[41] = "')'";
			array[42] = "'*'";
			array[43] = "'+'";
			array[44] = "','";
			array[45] = "'-'";
			array[46] = "'.'";
			array[47] = "'/'";
			array[60] = "'<'";
			array[61] = "'='";
			array[62] = "'>'";
			array[64] = "'@'";
			array[91] = "'['";
			array[93] = "']'";
			array[124] = "'|'";
			array[257] = "ERROR";
			array[258] = "EOF";
			array[259] = "SLASH";
			array[260] = "SLASH2";
			array[261] = "\"//\"";
			array[262] = "DOT";
			array[263] = "DOT2";
			array[264] = "\"..\"";
			array[265] = "COLON2";
			array[266] = "\"::\"";
			array[267] = "COMMA";
			array[268] = "AT";
			array[269] = "FUNCTION_NAME";
			array[270] = "BRACKET_OPEN";
			array[271] = "BRACKET_CLOSE";
			array[272] = "PAREN_OPEN";
			array[273] = "PAREN_CLOSE";
			array[274] = "AND";
			array[275] = "\"and\"";
			array[276] = "OR";
			array[277] = "\"or\"";
			array[278] = "DIV";
			array[279] = "\"div\"";
			array[280] = "MOD";
			array[281] = "\"mod\"";
			array[282] = "PLUS";
			array[283] = "MINUS";
			array[284] = "ASTERISK";
			array[285] = "DOLLAR";
			array[286] = "BAR";
			array[287] = "EQ";
			array[288] = "NE";
			array[289] = "\"!=\"";
			array[290] = "LE";
			array[291] = "\"<=\"";
			array[292] = "GE";
			array[293] = "\">=\"";
			array[294] = "LT";
			array[295] = "GT";
			array[296] = "ANCESTOR";
			array[297] = "\"ancestor\"";
			array[298] = "ANCESTOR_OR_SELF";
			array[299] = "\"ancstor-or-self\"";
			array[300] = "ATTRIBUTE";
			array[301] = "\"attribute\"";
			array[302] = "CHILD";
			array[303] = "\"child\"";
			array[304] = "DESCENDANT";
			array[305] = "\"descendant\"";
			array[306] = "DESCENDANT_OR_SELF";
			array[307] = "\"descendant-or-self\"";
			array[308] = "FOLLOWING";
			array[309] = "\"following\"";
			array[310] = "FOLLOWING_SIBLING";
			array[311] = "\"sibling\"";
			array[312] = "NAMESPACE";
			array[313] = "\"NameSpace\"";
			array[314] = "PARENT";
			array[315] = "\"parent\"";
			array[316] = "PRECEDING";
			array[317] = "\"preceding\"";
			array[318] = "PRECEDING_SIBLING";
			array[319] = "\"preceding-sibling\"";
			array[320] = "SELF";
			array[321] = "\"self\"";
			array[322] = "COMMENT";
			array[323] = "\"comment\"";
			array[324] = "TEXT";
			array[325] = "\"text\"";
			array[326] = "PROCESSING_INSTRUCTION";
			array[327] = "\"processing-instruction\"";
			array[328] = "NODE";
			array[329] = "\"node\"";
			array[330] = "MULTIPLY";
			array[331] = "NUMBER";
			array[332] = "LITERAL";
			array[333] = "QName";
			yyNames = array;
			yyLhs = new short[104]
			{
				-1, 0, 0, 1, 1, 1, 1, 1, 1, 1,
				3, 3, 2, 2, 2, 4, 5, 5, 5, 7,
				7, 10, 11, 11, 12, 12, 13, 13, 13, 14,
				14, 14, 14, 14, 15, 15, 15, 16, 16, 16,
				16, 17, 17, 18, 18, 19, 19, 19, 19, 20,
				20, 23, 23, 23, 22, 22, 22, 24, 24, 6,
				6, 6, 27, 27, 26, 26, 7, 7, 25, 25,
				8, 8, 28, 28, 28, 28, 21, 21, 31, 31,
				31, 31, 31, 32, 33, 33, 34, 34, 9, 30,
				30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
				30, 30, 29, 29
			};
			yyLen = new short[104]
			{
				2, 1, 3, 1, 2, 1, 3, 3, 2, 1,
				4, 6, 1, 3, 3, 3, 1, 2, 2, 0,
				2, 1, 1, 3, 1, 3, 1, 3, 3, 1,
				3, 3, 3, 3, 1, 3, 3, 1, 3, 3,
				3, 1, 2, 1, 3, 1, 1, 3, 3, 1,
				1, 1, 2, 2, 1, 3, 3, 3, 1, 1,
				3, 4, 1, 1, 1, 1, 0, 2, 2, 1,
				0, 1, 1, 1, 1, 1, 1, 2, 2, 3,
				1, 1, 1, 4, 0, 2, 0, 3, 3, 1,
				1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
				1, 1, 0, 1
			};
			yyDefRed = new short[151]
			{
				0, 0, 0, 71, 0, 0, 0, 0, 1, 0,
				0, 12, 0, 16, 0, 0, 0, 18, 17, 0,
				0, 0, 0, 0, 62, 72, 73, 0, 75, 63,
				19, 59, 0, 0, 2, 13, 14, 0, 0, 0,
				0, 0, 0, 10, 103, 0, 0, 20, 60, 0,
				61, 0, 0, 64, 65, 0, 0, 0, 0, 89,
				90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
				100, 101, 81, 80, 69, 0, 0, 0, 0, 0,
				0, 0, 37, 0, 43, 45, 0, 0, 50, 54,
				0, 58, 0, 76, 82, 11, 0, 0, 0, 0,
				42, 78, 88, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
				0, 0, 19, 68, 0, 0, 79, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 39, 40, 38,
				44, 0, 0, 55, 56, 0, 0, 85, 83, 0,
				87
			};
			yyDgoto = new short[35]
			{
				7, 8, 9, 10, 11, 12, 30, 40, 74, 47,
				75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
				85, 86, 87, 88, 89, 90, 91, 31, 32, 45,
				92, 93, 94, 125, 147
			};
			yySindex = new short[151]
			{
				-245, -251, -251, 0, -261, -221, -218, -256, 0, -231,
				-219, 0, -225, 0, -231, -231, -279, 0, 0, -245,
				-251, -251, -251, -251, 0, 0, 0, -211, 0, 0,
				0, 0, -209, -235, 0, 0, 0, -231, -231, -247,
				-174, -167, -220, 0, 0, -159, -250, 0, 0, -157,
				0, 216, 216, 0, 0, -154, -250, -250, -213, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, -149, -152, -148, -215, -16,
				-203, -244, 0, -158, 0, 0, -239, -50, 0, 0,
				-225, 0, -135, 0, 0, 0, -50, -50, -250, -141,
				0, 0, 0, -250, -250, -250, -250, -250, -250, -250,
				-250, -250, -250, -250, -250, -250, -185, 216, 216, 0,
				216, 216, 0, 0, -128, -131, 0, -148, -215, -16,
				-16, -203, -203, -203, -203, -244, -244, 0, 0, 0,
				0, -50, -50, 0, 0, -174, -250, 0, 0, -128,
				0
			};
			yyRindex = new short[151]
			{
				-122, 1, -122, 0, 0, 0, 0, 0, 0, 3,
				4, 0, 0, 0, 5, 6, 0, 0, 0, -122,
				-122, -122, -122, -122, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 7, 8, -124,
				2, 0, 0, 0, 0, 0, -122, 0, 0, 0,
				0, -97, -122, 0, 0, 0, -122, -122, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, -228, -115, -169, 219,
				-53, 264, 0, 193, 0, 0, -23, 57, 0, 0,
				0, 0, 0, 0, 0, 0, 83, 112, -257, 0,
				0, 0, 0, -122, -122, -122, -122, -122, -122, -122,
				-122, -122, -122, -122, -122, -122, -122, -122, -122, 0,
				-122, -122, 0, 0, -119, 0, 0, -68, -133, 388,
				407, 10, 342, 352, 378, 290, 316, 0, 0, 0,
				0, 138, 167, 0, 0, -123, -122, 0, 0, -119,
				0
			};
			yyGindex = new short[35]
			{
				0, 126, 87, 0, 192, 0, 76, 46, 548, 89,
				-56, 0, 70, 74, 110, 201, 134, -20, 0, 64,
				0, 0, -26, 0, 175, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 33
			};
			yyTable = new short[696]
			{
				99, 3, 15, 9, 5, 4, 8, 6, 7, 51,
				52, 16, 53, 54, 1, 2, 84, 3, 3, 55,
				117, 118, 56, 3, 4, 96, 97, 70, 20, 21,
				19, 46, 42, 57, 113, 58, 114, 100, 43, 21,
				22, 23, 124, 21, 17, 21, 59, 18, 60, 5,
				61, 6, 62, 33, 63, 5, 64, 6, 65, 24,
				66, 39, 67, 41, 68, 70, 69, 70, 70, 70,
				71, 70, 105, 106, 51, 52, 70, 53, 54, 111,
				112, 72, 73, 3, 55, 44, 115, 56, 14, 15,
				149, 141, 142, 137, 138, 139, 46, 25, 24, 26,
				58, 27, 24, 28, 24, 24, 48, 24, 29, 37,
				38, 59, 49, 60, 50, 61, 95, 62, 98, 63,
				101, 64, 102, 65, 103, 66, 104, 67, 116, 68,
				123, 69, 126, 70, 25, 71, 57, 57, 25, 146,
				25, 25, 148, 25, 57, 34, 72, 73, 57, 102,
				57, 57, 22, 57, 86, 57, 22, 57, 22, 57,
				57, 22, 70, 57, 57, 57, 122, 57, 145, 57,
				51, 57, 57, 127, 51, 119, 51, 51, 128, 51,
				140, 51, 150, 51, 0, 51, 51, 70, 0, 51,
				51, 51, 0, 51, 0, 51, 0, 51, 51, 23,
				70, 0, 70, 23, 70, 23, 70, 57, 23, 120,
				121, 70, 35, 36, 29, 129, 130, 0, 29, 0,
				29, 29, 0, 29, 0, 70, 0, 70, 0, 70,
				0, 70, 0, 51, 29, 29, 70, 29, 0, 29,
				0, 29, 29, 0, 46, 135, 136, 0, 46, 0,
				46, 46, 0, 46, 0, 46, 0, 46, 0, 46,
				46, 15, 15, 46, 46, 46, 0, 46, 0, 46,
				0, 46, 46, 0, 107, 0, 108, 32, 109, 110,
				0, 32, 0, 32, 32, 70, 32, 3, 15, 9,
				5, 4, 8, 6, 7, 143, 144, 32, 32, 0,
				32, 0, 32, 0, 32, 32, 0, 46, 131, 132,
				133, 134, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 70, 49, 70, 0, 70, 49, 70,
				49, 49, 0, 49, 70, 49, 0, 49, 0, 49,
				49, 0, 0, 49, 49, 49, 0, 49, 0, 49,
				52, 49, 49, 0, 52, 0, 52, 52, 0, 52,
				0, 52, 0, 52, 0, 52, 52, 0, 0, 52,
				52, 52, 0, 52, 0, 52, 0, 52, 52, 53,
				0, 0, 0, 53, 0, 53, 53, 49, 53, 0,
				53, 0, 53, 0, 53, 53, 0, 0, 53, 53,
				53, 0, 53, 0, 53, 47, 53, 53, 0, 47,
				0, 47, 47, 52, 47, 0, 47, 0, 47, 0,
				47, 47, 0, 0, 47, 47, 47, 0, 47, 0,
				47, 0, 47, 47, 48, 0, 0, 0, 48, 0,
				48, 48, 53, 48, 0, 48, 0, 48, 0, 48,
				48, 0, 0, 48, 48, 48, 0, 48, 0, 48,
				41, 48, 48, 0, 41, 0, 41, 41, 47, 41,
				0, 41, 0, 41, 0, 41, 41, 0, 53, 54,
				41, 41, 0, 41, 3, 41, 26, 41, 41, 0,
				26, 0, 26, 26, 0, 26, 0, 48, 0, 0,
				0, 0, 0, 0, 0, 0, 26, 26, 0, 0,
				0, 0, 59, 0, 60, 0, 61, 0, 62, 0,
				63, 0, 64, 41, 65, 0, 66, 0, 67, 0,
				68, 34, 69, 0, 70, 34, 71, 34, 34, 0,
				34, 0, 0, 0, 0, 0, 34, 34, 13, 13,
				13, 34, 34, 0, 34, 0, 34, 35, 34, 34,
				0, 35, 0, 35, 35, 0, 35, 13, 13, 13,
				13, 13, 35, 35, 0, 0, 0, 35, 35, 0,
				35, 0, 35, 36, 35, 35, 0, 36, 0, 36,
				36, 0, 36, 0, 0, 0, 0, 0, 36, 36,
				0, 0, 0, 36, 36, 0, 36, 0, 36, 33,
				36, 36, 0, 33, 0, 33, 33, 0, 33, 30,
				0, 0, 0, 30, 0, 30, 30, 0, 30, 33,
				33, 0, 33, 0, 33, 0, 33, 33, 0, 30,
				30, 0, 30, 0, 30, 31, 30, 30, 0, 31,
				0, 31, 31, 0, 31, 27, 0, 0, 0, 27,
				0, 27, 27, 0, 27, 31, 31, 0, 31, 0,
				31, 0, 31, 31, 28, 27, 27, 0, 28, 0,
				28, 28, 0, 28, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 28, 28
			};
			yyCheck = new short[696]
			{
				56, 0, 0, 0, 0, 0, 0, 0, 0, 259,
				260, 272, 262, 263, 259, 260, 273, 268, 268, 269,
				259, 260, 272, 268, 269, 51, 52, 284, 259, 260,
				286, 270, 267, 283, 278, 285, 280, 57, 273, 267,
				259, 260, 98, 271, 265, 273, 296, 265, 298, 300,
				300, 302, 302, 332, 304, 300, 306, 302, 308, 284,
				310, 272, 312, 272, 314, 322, 316, 324, 318, 326,
				320, 328, 287, 288, 259, 260, 333, 262, 263, 282,
				283, 331, 332, 268, 269, 332, 330, 272, 1, 2,
				146, 117, 118, 113, 114, 115, 270, 322, 267, 324,
				285, 326, 271, 328, 273, 274, 273, 276, 333, 22,
				23, 296, 332, 298, 273, 300, 273, 302, 272, 304,
				333, 306, 271, 308, 276, 310, 274, 312, 286, 314,
				265, 316, 273, 318, 267, 320, 259, 260, 271, 267,
				273, 274, 273, 276, 267, 19, 331, 332, 271, 273,
				273, 274, 267, 276, 273, 278, 271, 280, 273, 282,
				283, 276, 284, 286, 287, 288, 90, 290, 122, 292,
				267, 294, 295, 103, 271, 86, 273, 274, 104, 276,
				116, 278, 149, 280, -1, 282, 283, 284, -1, 286,
				287, 288, -1, 290, -1, 292, -1, 294, 295, 267,
				322, -1, 324, 271, 326, 273, 328, 330, 276, 259,
				260, 333, 20, 21, 267, 105, 106, -1, 271, -1,
				273, 274, -1, 276, -1, 322, -1, 324, -1, 326,
				-1, 328, -1, 330, 287, 288, 333, 290, -1, 292,
				-1, 294, 295, -1, 267, 111, 112, -1, 271, -1,
				273, 274, -1, 276, -1, 278, -1, 280, -1, 282,
				283, 259, 260, 286, 287, 288, -1, 290, -1, 292,
				-1, 294, 295, -1, 290, -1, 292, 267, 294, 295,
				-1, 271, -1, 273, 274, 284, 276, 286, 286, 286,
				286, 286, 286, 286, 286, 120, 121, 287, 288, -1,
				290, -1, 292, -1, 294, 295, -1, 330, 107, 108,
				109, 110, -1, -1, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, 322, 267, 324, -1, 326, 271, 328,
				273, 274, -1, 276, 333, 278, -1, 280, -1, 282,
				283, -1, -1, 286, 287, 288, -1, 290, -1, 292,
				267, 294, 295, -1, 271, -1, 273, 274, -1, 276,
				-1, 278, -1, 280, -1, 282, 283, -1, -1, 286,
				287, 288, -1, 290, -1, 292, -1, 294, 295, 267,
				-1, -1, -1, 271, -1, 273, 274, 330, 276, -1,
				278, -1, 280, -1, 282, 283, -1, -1, 286, 287,
				288, -1, 290, -1, 292, 267, 294, 295, -1, 271,
				-1, 273, 274, 330, 276, -1, 278, -1, 280, -1,
				282, 283, -1, -1, 286, 287, 288, -1, 290, -1,
				292, -1, 294, 295, 267, -1, -1, -1, 271, -1,
				273, 274, 330, 276, -1, 278, -1, 280, -1, 282,
				283, -1, -1, 286, 287, 288, -1, 290, -1, 292,
				267, 294, 295, -1, 271, -1, 273, 274, 330, 276,
				-1, 278, -1, 280, -1, 282, 283, -1, 262, 263,
				287, 288, -1, 290, 268, 292, 267, 294, 295, -1,
				271, -1, 273, 274, -1, 276, -1, 330, -1, -1,
				-1, -1, -1, -1, -1, -1, 287, 288, -1, -1,
				-1, -1, 296, -1, 298, -1, 300, -1, 302, -1,
				304, -1, 306, 330, 308, -1, 310, -1, 312, -1,
				314, 267, 316, -1, 318, 271, 320, 273, 274, -1,
				276, -1, -1, -1, -1, -1, 282, 283, 0, 1,
				2, 287, 288, -1, 290, -1, 292, 267, 294, 295,
				-1, 271, -1, 273, 274, -1, 276, 19, 20, 21,
				22, 23, 282, 283, -1, -1, -1, 287, 288, -1,
				290, -1, 292, 267, 294, 295, -1, 271, -1, 273,
				274, -1, 276, -1, -1, -1, -1, -1, 282, 283,
				-1, -1, -1, 287, 288, -1, 290, -1, 292, 267,
				294, 295, -1, 271, -1, 273, 274, -1, 276, 267,
				-1, -1, -1, 271, -1, 273, 274, -1, 276, 287,
				288, -1, 290, -1, 292, -1, 294, 295, -1, 287,
				288, -1, 290, -1, 292, 267, 294, 295, -1, 271,
				-1, 273, 274, -1, 276, 267, -1, -1, -1, 271,
				-1, 273, 274, -1, 276, 287, 288, -1, 290, -1,
				292, -1, 294, 295, 267, 287, 288, -1, 271, -1,
				273, 274, -1, 276, -1, -1, -1, -1, -1, -1,
				-1, -1, -1, -1, 287, 288
			};
		}

		internal Expression Compile(string xpath)
		{
			try
			{
				Tokenizer yyLex = new Tokenizer(xpath);
				return (Expression)yyparse(yyLex);
			}
			catch (XPathException)
			{
				throw;
			}
			catch (Exception innerException)
			{
				throw new XPathException("Error during parse of " + xpath, innerException);
			}
		}

		private NodeSet CreateNodeTest(Axes axis, object nodeTest, ArrayList plist)
		{
			NodeSet nodeSet = CreateNodeTest(axis, nodeTest);
			if (plist != null)
			{
				for (int i = 0; i < plist.Count; i++)
				{
					nodeSet = new ExprFilter(nodeSet, (Expression)plist[i]);
				}
			}
			return nodeSet;
		}

		private NodeTest CreateNodeTest(Axes axis, object test)
		{
			if (test is XPathNodeType)
			{
				return new NodeTypeTest(axis, (XPathNodeType)(int)test, null);
			}
			if (test is string || test == null)
			{
				return new NodeTypeTest(axis, XPathNodeType.ProcessingInstruction, (string)test);
			}
			XmlQualifiedName xmlQualifiedName = (XmlQualifiedName)test;
			if (xmlQualifiedName == XmlQualifiedName.Empty)
			{
				return new NodeTypeTest(axis);
			}
			return new NodeNameTest(axis, xmlQualifiedName, Context);
		}

		public void yyerror(string message)
		{
			yyerror(message, null);
		}

		public void yyerror(string message, string[] expected)
		{
			if (yacc_verbose_flag > 0 && expected != null && expected.Length > 0)
			{
				ErrorOutput.Write(message + ", expecting");
				for (int i = 0; i < expected.Length; i++)
				{
					ErrorOutput.Write(" " + expected[i]);
				}
				ErrorOutput.WriteLine();
			}
			else
			{
				ErrorOutput.WriteLine(message);
			}
		}

		public static string yyname(int token)
		{
			if (token < 0 || token > yyNames.Length)
			{
				return "[illegal]";
			}
			string result;
			if ((result = yyNames[token]) != null)
			{
				return result;
			}
			return "[unknown]";
		}

		protected int[] yyExpectingTokens(int state)
		{
			int num = 0;
			bool[] array = new bool[yyNames.Length];
			int num2;
			int i;
			if ((num2 = yySindex[state]) != 0)
			{
				for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++)
				{
					if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null)
					{
						num++;
						array[i] = true;
					}
				}
			}
			if ((num2 = yyRindex[state]) != 0)
			{
				for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++)
				{
					if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null)
					{
						num++;
						array[i] = true;
					}
				}
			}
			int[] array2 = new int[num];
			num2 = (i = 0);
			while (num2 < num)
			{
				if (array[i])
				{
					array2[num2++] = i;
				}
				i++;
			}
			return array2;
		}

		protected string[] yyExpecting(int state)
		{
			int[] array = yyExpectingTokens(state);
			string[] array2 = new string[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i++] = yyNames[array[i]];
			}
			return array2;
		}

		internal object yyparse(Mono.Xml.Xsl.yyParser.yyInput yyLex, object yyd)
		{
			debug = (Mono.Xml.Xsl.yydebug.yyDebug)yyd;
			return yyparse(yyLex);
		}

		protected object yyDefault(object first)
		{
			return first;
		}

		internal object yyparse(Mono.Xml.Xsl.yyParser.yyInput yyLex)
		{
			if (yyMax <= 0)
			{
				yyMax = 256;
			}
			int num = 0;
			int[] array = new int[yyMax];
			object obj = null;
			object[] array2 = new object[yyMax];
			int num2 = -1;
			int num3 = 0;
			int num4 = 0;
			while (true)
			{
				if (num4 >= array.Length)
				{
					int[] array3 = new int[array.Length + yyMax];
					array.CopyTo(array3, 0);
					array = array3;
					object[] array4 = new object[array2.Length + yyMax];
					array2.CopyTo(array4, 0);
					array2 = array4;
				}
				array[num4] = num;
				array2[num4] = obj;
				if (debug != null)
				{
					debug.push(num, obj);
				}
				while (true)
				{
					int num5;
					if ((num5 = yyDefRed[num]) == 0)
					{
						if (num2 < 0)
						{
							num2 = (yyLex.advance() ? yyLex.token() : 0);
							if (debug != null)
							{
								debug.lex(num, num2, yyname(num2), yyLex.value());
							}
						}
						if ((num5 = yySindex[num]) != 0 && (num5 += num2) >= 0 && num5 < yyTable.Length && yyCheck[num5] == num2)
						{
							if (debug != null)
							{
								debug.shift(num, yyTable[num5], num3 - 1);
							}
							num = yyTable[num5];
							obj = yyLex.value();
							num2 = -1;
							if (num3 > 0)
							{
								num3--;
							}
							break;
						}
						if ((num5 = yyRindex[num]) == 0 || (num5 += num2) < 0 || num5 >= yyTable.Length || yyCheck[num5] != num2)
						{
							switch (num3)
							{
							case 0:
								yyExpectingState = num;
								if (debug != null)
								{
									debug.error("syntax error");
								}
								if (num2 == 0 || num2 == eof_token)
								{
									throw new Mono.Xml.Xsl.yyParser.yyUnexpectedEof();
								}
								break;
							case 1:
							case 2:
								break;
							case 3:
								goto IL_02f5;
							default:
								goto IL_034b;
							}
							num3 = 3;
							while ((num5 = yySindex[array[num4]]) == 0 || (num5 += 256) < 0 || num5 >= yyTable.Length || yyCheck[num5] != 256)
							{
								if (debug != null)
								{
									debug.pop(array[num4]);
								}
								if (--num4 < 0)
								{
									if (debug != null)
									{
										debug.reject();
									}
									throw new Mono.Xml.Xsl.yyParser.yyException("irrecoverable syntax error");
								}
							}
							if (debug != null)
							{
								debug.shift(array[num4], yyTable[num5], 3);
							}
							num = yyTable[num5];
							obj = yyLex.value();
							break;
						}
						num5 = yyTable[num5];
					}
					goto IL_034b;
					IL_02f5:
					if (num2 == 0)
					{
						if (debug != null)
						{
							debug.reject();
						}
						throw new Mono.Xml.Xsl.yyParser.yyException("irrecoverable syntax error at end-of-file");
					}
					if (debug != null)
					{
						debug.discard(num, num2, yyname(num2), yyLex.value());
					}
					num2 = -1;
					continue;
					IL_034b:
					int num6 = num4 + 1 - yyLen[num5];
					if (debug != null)
					{
						debug.reduce(num, array[num6 - 1], num5, YYRules.getRule(num5), yyLen[num5]);
					}
					obj = yyDefault((num6 <= num4) ? array2[num6] : null);
					switch (num5)
					{
					case 2:
						obj = new ExprUNION((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 3:
						obj = new ExprRoot();
						break;
					case 4:
						obj = new ExprSLASH(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 6:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 7:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 8:
						obj = new ExprSLASH2(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 10:
					{
						XmlQualifiedName xmlQualifiedName2 = (XmlQualifiedName)array2[-3 + num4];
						if (xmlQualifiedName2.Name != "id" || xmlQualifiedName2.Namespace != string.Empty)
						{
							throw new XPathException($"Expected 'id' but got '{xmlQualifiedName2}'");
						}
						obj = ExprFunctionCall.Factory(xmlQualifiedName2, new FunctionArguments(new ExprLiteral((string)array2[-1 + num4]), null), Context);
						break;
					}
					case 11:
					{
						XmlQualifiedName xmlQualifiedName = (XmlQualifiedName)array2[-5 + num4];
						if (xmlQualifiedName.Name != "key" || xmlQualifiedName.Namespace != string.Empty)
						{
							throw new XPathException($"Expected 'key' but got '{xmlQualifiedName}'");
						}
						obj = Context.TryGetFunction(xmlQualifiedName, new FunctionArguments(new ExprLiteral((string)array2[-3 + num4]), new FunctionArguments(new ExprLiteral((string)array2[-1 + num4]), null)));
						break;
					}
					case 13:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 14:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 15:
						obj = CreateNodeTest((Axes)(int)array2[-2 + num4], array2[-1 + num4], (ArrayList)array2[0 + num4]);
						break;
					case 17:
						obj = Axes.Child;
						break;
					case 18:
						obj = Axes.Attribute;
						break;
					case 19:
						obj = null;
						break;
					case 20:
					{
						ArrayList arrayList2 = (ArrayList)array2[-1 + num4];
						if (arrayList2 == null)
						{
							arrayList2 = new ArrayList();
						}
						arrayList2.Add((Expression)array2[0 + num4]);
						obj = arrayList2;
						break;
					}
					case 23:
						obj = new ExprOR((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 25:
						obj = new ExprAND((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 27:
						obj = new ExprEQ((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 28:
						obj = new ExprNE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 30:
						obj = new ExprLT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 31:
						obj = new ExprGT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 32:
						obj = new ExprLE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 33:
						obj = new ExprGE((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 35:
						obj = new ExprPLUS((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 36:
						obj = new ExprMINUS((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 38:
						obj = new ExprMULT((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 39:
						obj = new ExprDIV((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 40:
						obj = new ExprMOD((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 42:
						obj = new ExprNEG((Expression)array2[0 + num4]);
						break;
					case 44:
						obj = new ExprUNION((Expression)array2[-2 + num4], (Expression)array2[0 + num4]);
						break;
					case 47:
						obj = new ExprSLASH((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 48:
						obj = new ExprSLASH2((Expression)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 51:
						obj = new ExprRoot();
						break;
					case 52:
						obj = new ExprSLASH(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 53:
						obj = new ExprSLASH2(new ExprRoot(), (NodeSet)array2[0 + num4]);
						break;
					case 55:
						obj = new ExprSLASH((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 56:
						obj = new ExprSLASH2((NodeSet)array2[-2 + num4], (NodeSet)array2[0 + num4]);
						break;
					case 57:
						obj = CreateNodeTest((Axes)(int)array2[-2 + num4], array2[-1 + num4], (ArrayList)array2[0 + num4]);
						break;
					case 60:
						obj = (XPathNodeType)(int)array2[-2 + num4];
						break;
					case 61:
						obj = (string)array2[-1 + num4];
						break;
					case 62:
						obj = XmlQualifiedName.Empty;
						break;
					case 64:
						obj = new NodeTypeTest(Axes.Self, XPathNodeType.All);
						break;
					case 65:
						obj = new NodeTypeTest(Axes.Parent, XPathNodeType.All);
						break;
					case 66:
						obj = null;
						break;
					case 67:
					{
						ArrayList arrayList = (ArrayList)array2[-1 + num4];
						if (arrayList == null)
						{
							arrayList = new ArrayList();
						}
						arrayList.Add(array2[0 + num4]);
						obj = arrayList;
						break;
					}
					case 68:
						obj = array2[-1 + num4];
						break;
					case 70:
						obj = Axes.Child;
						break;
					case 71:
						obj = Axes.Attribute;
						break;
					case 72:
						obj = XPathNodeType.Comment;
						break;
					case 73:
						obj = XPathNodeType.Text;
						break;
					case 74:
						obj = XPathNodeType.ProcessingInstruction;
						break;
					case 75:
						obj = XPathNodeType.All;
						break;
					case 77:
						obj = new ExprFilter((Expression)array2[-1 + num4], (Expression)array2[0 + num4]);
						break;
					case 78:
					{
						Expression expression2 = null;
						if (Context != null)
						{
							expression2 = Context.TryGetVariable(((XmlQualifiedName)array2[0 + num4]).ToString());
						}
						if (expression2 == null)
						{
							expression2 = new ExprVariable((XmlQualifiedName)array2[0 + num4], Context);
						}
						obj = expression2;
						break;
					}
					case 79:
						obj = new ExprParens((Expression)array2[-1 + num4]);
						break;
					case 80:
						obj = new ExprLiteral((string)array2[0 + num4]);
						break;
					case 81:
						obj = new ExprNumber((double)array2[0 + num4]);
						break;
					case 83:
					{
						Expression expression = null;
						if (Context != null)
						{
							expression = Context.TryGetFunction((XmlQualifiedName)array2[-3 + num4], (FunctionArguments)array2[-1 + num4]);
						}
						if (expression == null)
						{
							expression = ExprFunctionCall.Factory((XmlQualifiedName)array2[-3 + num4], (FunctionArguments)array2[-1 + num4], Context);
						}
						obj = expression;
						break;
					}
					case 85:
						obj = new FunctionArguments((Expression)array2[-1 + num4], (FunctionArguments)array2[0 + num4]);
						break;
					case 87:
						obj = new FunctionArguments((Expression)array2[-1 + num4], (FunctionArguments)array2[0 + num4]);
						break;
					case 88:
						obj = array2[-1 + num4];
						break;
					case 89:
						obj = Axes.Ancestor;
						break;
					case 90:
						obj = Axes.AncestorOrSelf;
						break;
					case 91:
						obj = Axes.Attribute;
						break;
					case 92:
						obj = Axes.Child;
						break;
					case 93:
						obj = Axes.Descendant;
						break;
					case 94:
						obj = Axes.DescendantOrSelf;
						break;
					case 95:
						obj = Axes.Following;
						break;
					case 96:
						obj = Axes.FollowingSibling;
						break;
					case 97:
						obj = Axes.Namespace;
						break;
					case 98:
						obj = Axes.Parent;
						break;
					case 99:
						obj = Axes.Preceding;
						break;
					case 100:
						obj = Axes.PrecedingSibling;
						break;
					case 101:
						obj = Axes.Self;
						break;
					}
					num4 -= yyLen[num5];
					num = array[num4];
					int num7 = yyLhs[num5];
					if (num == 0 && num7 == 0)
					{
						if (debug != null)
						{
							debug.shift(0, yyFinal);
						}
						num = yyFinal;
						if (num2 < 0)
						{
							num2 = (yyLex.advance() ? yyLex.token() : 0);
							if (debug != null)
							{
								debug.lex(num, num2, yyname(num2), yyLex.value());
							}
						}
						if (num2 == 0)
						{
							if (debug != null)
							{
								debug.accept(obj);
							}
							return obj;
						}
						break;
					}
					num = (((num5 = yyGindex[num7]) == 0 || (num5 += num) < 0 || num5 >= yyTable.Length || yyCheck[num5] != num) ? yyDgoto[num7] : yyTable[num5]);
					if (debug != null)
					{
						debug.shift(array[num4], num);
					}
					break;
				}
				num4++;
			}
		}
	}
}
namespace Mono.Xml.Xsl.yydebug
{
	internal interface yyDebug
	{
		void push(int state, object value);

		void lex(int state, int token, string name, object value);

		void shift(int from, int to, int errorFlag);

		void pop(int state);

		void discard(int state, int token, string name, object value);

		void reduce(int from, int to, int rule, string text, int len);

		void shift(int from, int to);

		void accept(object value);

		void error(string message);

		void reject();
	}
	internal class yyDebugSimple : yyDebug
	{
		private void println(string s)
		{
			Console.Error.WriteLine(s);
		}

		public void push(int state, object value)
		{
			println("push\tstate " + state + "\tvalue " + value);
		}

		public void lex(int state, int token, string name, object value)
		{
			println("lex\tstate " + state + "\treading " + name + "\tvalue " + value);
		}

		public void shift(int from, int to, int errorFlag)
		{
			switch (errorFlag)
			{
			default:
				println("shift\tfrom state " + from + " to " + to);
				break;
			case 0:
			case 1:
			case 2:
				println("shift\tfrom state " + from + " to " + to + "\t" + errorFlag + " left to recover");
				break;
			case 3:
				println("shift\tfrom state " + from + " to " + to + "\ton error");
				break;
			}
		}

		public void pop(int state)
		{
			println("pop\tstate " + state + "\ton error");
		}

		public void discard(int state, int token, string name, object value)
		{
			println("discard\tstate " + state + "\ttoken " + name + "\tvalue " + value);
		}

		public void reduce(int from, int to, int rule, string text, int len)
		{
			println("reduce\tstate " + from + "\tuncover " + to + "\trule (" + rule + ") " + text);
		}

		public void shift(int from, int to)
		{
			println("goto\tfrom state " + from + " to " + to);
		}

		public void accept(object value)
		{
			println("accept\tvalue " + value);
		}

		public void error(string message)
		{
			println("error\t" + message);
		}

		public void reject()
		{
			println("reject");
		}
	}
}
namespace Mono.Xml.Xsl
{
	internal class Token
	{
		public const int ERROR = 257;

		public const int EOF = 258;

		public const int SLASH = 259;

		public const int SLASH2 = 260;

		public const int DOT = 262;

		public const int DOT2 = 263;

		public const int COLON2 = 265;

		public const int COMMA = 267;

		public const int AT = 268;

		public const int FUNCTION_NAME = 269;

		public const int BRACKET_OPEN = 270;

		public const int BRACKET_CLOSE = 271;

		public const int PAREN_OPEN = 272;

		public const int PAREN_CLOSE = 273;

		public const int AND = 274;

		public const int and = 275;

		public const int OR = 276;

		public const int or = 277;

		public const int DIV = 278;

		public const int div = 279;

		public const int MOD = 280;

		public const int mod = 281;

		public const int PLUS = 282;

		public const int MINUS = 283;

		public const int ASTERISK = 284;

		public const int DOLLAR = 285;

		public const int BAR = 286;

		public const int EQ = 287;

		public const int NE = 288;

		public const int LE = 290;

		public const int GE = 292;

		public const int LT = 294;

		public const int GT = 295;

		public const int ANCESTOR = 296;

		public const int ancestor = 297;

		public const int ANCESTOR_OR_SELF = 298;

		public const int ATTRIBUTE = 300;

		public const int attribute = 301;

		public const int CHILD = 302;

		public const int child = 303;

		public const int DESCENDANT = 304;

		public const int descendant = 305;

		public const int DESCENDANT_OR_SELF = 306;

		public const int FOLLOWING = 308;

		public const int following = 309;

		public const int FOLLOWING_SIBLING = 310;

		public const int sibling = 311;

		public const int NAMESPACE = 312;

		public const int NameSpace = 313;

		public const int PARENT = 314;

		public const int parent = 315;

		public const int PRECEDING = 316;

		public const int preceding = 317;

		public const int PRECEDING_SIBLING = 318;

		public const int SELF = 320;

		public const int self = 321;

		public const int COMMENT = 322;

		public const int comment = 323;

		public const int TEXT = 324;

		public const int text = 325;

		public const int PROCESSING_INSTRUCTION = 326;

		public const int NODE = 328;

		public const int node = 329;

		public const int MULTIPLY = 330;

		public const int NUMBER = 331;

		public const int LITERAL = 332;

		public const int QName = 333;

		public const int yyErrorCode = 256;
	}
}
namespace Mono.Xml.Xsl.yyParser
{
	internal class yyException : Exception
	{
		public yyException(string message)
			: base(message)
		{
		}
	}
	internal class yyUnexpectedEof : yyException
	{
		public yyUnexpectedEof(string message)
			: base(message)
		{
		}

		public yyUnexpectedEof()
			: base(string.Empty)
		{
		}
	}
	internal interface yyInput
	{
		bool advance();

		int token();

		object value();
	}
}
namespace Mono.Xml.Xsl
{
	internal class Tokenizer : Mono.Xml.Xsl.yyParser.yyInput
	{
		private const char EOL = '\0';

		private string m_rgchInput;

		private int m_ich;

		private int m_cch;

		private int m_iToken;

		private int m_iTokenPrev = 258;

		private object m_objToken;

		private bool m_fPrevWasOperator;

		private bool m_fThisIsOperator;

		private static readonly Hashtable s_mapTokens;

		private static readonly object[] s_rgTokenMap;

		private bool IsFirstToken => m_iTokenPrev == 258;

		public Tokenizer(string strInput)
		{
			m_rgchInput = strInput;
			m_ich = 0;
			m_cch = strInput.Length;
			SkipWhitespace();
		}

		static Tokenizer()
		{
			s_mapTokens = new Hashtable();
			s_rgTokenMap = new object[42]
			{
				274, "and", 276, "or", 278, "div", 280, "mod", 296, "ancestor",
				298, "ancestor-or-self", 300, "attribute", 302, "child", 304, "descendant", 306, "descendant-or-self",
				308, "following", 310, "following-sibling", 312, "namespace", 314, "parent", 316, "preceding",
				318, "preceding-sibling", 320, "self", 322, "comment", 324, "text", 326, "processing-instruction",
				328, "node"
			};
			for (int i = 0; i < s_rgTokenMap.Length; i += 2)
			{
				s_mapTokens.Add(s_rgTokenMap[i + 1], s_rgTokenMap[i]);
			}
		}

		private char Peek(int iOffset)
		{
			if (m_ich + iOffset >= m_cch)
			{
				return '\0';
			}
			return m_rgchInput[m_ich + iOffset];
		}

		private char Peek()
		{
			return Peek(0);
		}

		private char GetChar()
		{
			if (m_ich >= m_cch)
			{
				return '\0';
			}
			return m_rgchInput[m_ich++];
		}

		private char PutBack()
		{
			if (m_ich == 0)
			{
				throw new XPathException("XPath parser returned an error status: invalid tokenizer state.");
			}
			return m_rgchInput[--m_ich];
		}

		private bool SkipWhitespace()
		{
			if (!IsWhitespace(Peek()))
			{
				return false;
			}
			while (IsWhitespace(Peek()))
			{
				GetChar();
			}
			return true;
		}

		private int ParseNumber()
		{
			StringBuilder stringBuilder = new StringBuilder();
			while (IsDigit(Peek()))
			{
				stringBuilder.Append(GetChar());
			}
			if (Peek() == '.')
			{
				stringBuilder.Append(GetChar());
				while (IsDigit(Peek()))
				{
					stringBuilder.Append(GetChar());
				}
			}
			m_objToken = double.Parse(stringBuilder.ToString(), NumberFormatInfo.InvariantInfo);
			return 331;
		}

		private int ParseLiteral()
		{
			StringBuilder stringBuilder = new StringBuilder();
			char @char = GetChar();
			char c;
			while ((c = Peek()) != @char)
			{
				if (c == '\0')
				{
					throw new XPathException("unmatched " + @char + " in expression");
				}
				stringBuilder.Append(GetChar());
			}
			GetChar();
			m_objToken = stringBuilder.ToString();
			return 332;
		}

		private string ReadIdentifier()
		{
			StringBuilder stringBuilder = new StringBuilder();
			char c = Peek();
			if (!char.IsLetter(c) && c != '_')
			{
				return null;
			}
			stringBuilder.Append(GetChar());
			while ((c = Peek()) == '_' || c == '-' || c == '.' || char.IsLetterOrDigit(c))
			{
				stringBuilder.Append(GetChar());
			}
			SkipWhitespace();
			return stringBuilder.ToString();
		}

		private int ParseIdentifier()
		{
			string text = ReadIdentifier();
			object obj = s_mapTokens[text];
			int num = ((obj == null) ? 333 : ((int)obj));
			m_objToken = text;
			char c = Peek();
			if (c == ':')
			{
				if (Peek(1) == ':')
				{
					if (obj == null || !IsAxisName(num))
					{
						throw new XPathException("invalid axis name: '" + text + "'");
					}
					return num;
				}
				GetChar();
				SkipWhitespace();
				c = Peek();
				if (c == '*')
				{
					GetChar();
					m_objToken = new XmlQualifiedName(string.Empty, text);
					return 333;
				}
				string text2 = ReadIdentifier();
				if (text2 == null)
				{
					throw new XPathException("invalid QName: " + text + ":" + c);
				}
				c = Peek();
				m_objToken = new XmlQualifiedName(text2, text);
				if (c == '(')
				{
					return 269;
				}
				return 333;
			}
			if (!IsFirstToken && !m_fPrevWasOperator)
			{
				if (obj == null || !IsOperatorName(num))
				{
					throw new XPathException("invalid operator name: '" + text + "'");
				}
				return num;
			}
			if (c == '(')
			{
				if (obj == null)
				{
					m_objToken = new XmlQualifiedName(text, string.Empty);
					return 269;
				}
				if (IsNodeType(num))
				{
					return num;
				}
				throw new XPathException("invalid function name: '" + text + "'");
			}
			m_objToken = new XmlQualifiedName(text, string.Empty);
			return 333;
		}

		private static bool IsWhitespace(char ch)
		{
			return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
		}

		private static bool IsDigit(char ch)
		{
			return ch >= '0' && ch <= '9';
		}

		private int ParseToken()
		{
			char c = Peek();
			switch (c)
			{
			case '\0':
				return 258;
			case '/':
				m_fThisIsOperator = true;
				GetChar();
				if (Peek() == '/')
				{
					GetChar();
					return 260;
				}
				return 259;
			case '.':
				GetChar();
				if (Peek() == '.')
				{
					GetChar();
					return 263;
				}
				if (IsDigit(Peek()))
				{
					PutBack();
					return ParseNumber();
				}
				return 262;
			case ':':
				GetChar();
				if (Peek() == ':')
				{
					m_fThisIsOperator = true;
					GetChar();
					return 265;
				}
				return 257;
			case ',':
				m_fThisIsOperator = true;
				GetChar();
				return 267;
			case '@':
				m_fThisIsOperator = true;
				GetChar();
				return 268;
			case '[':
				m_fThisIsOperator = true;
				GetChar();
				return 270;
			case ']':
				GetChar();
				return 271;
			case '(':
				m_fThisIsOperator = true;
				GetChar();
				return 272;
			case ')':
				GetChar();
				return 273;
			case '+':
				m_fThisIsOperator = true;
				GetChar();
				return 282;
			case '-':
				m_fThisIsOperator = true;
				GetChar();
				return 283;
			case '*':
				GetChar();
				if (!IsFirstToken && !m_fPrevWasOperator)
				{
					m_fThisIsOperator = true;
					return 330;
				}
				return 284;
			case '$':
				GetChar();
				m_fThisIsOperator = true;
				return 285;
			case '|':
				m_fThisIsOperator = true;
				GetChar();
				return 286;
			case '=':
				m_fThisIsOperator = true;
				GetChar();
				return 287;
			case '!':
				GetChar();
				if (Peek() == '=')
				{
					m_fThisIsOperator = true;
					GetChar();
					return 288;
				}
				break;
			case '>':
				m_fThisIsOperator = true;
				GetChar();
				if (Peek() == '=')
				{
					GetChar();
					return 292;
				}
				return 295;
			case '<':
				m_fThisIsOperator = true;
				GetChar();
				if (Peek() == '=')
				{
					GetChar();
					return 290;
				}
				return 294;
			case '\'':
				return ParseLiteral();
			case '"':
				return ParseLiteral();
			default:
				if (IsDigit(c))
				{
					return ParseNumber();
				}
				if (char.IsLetter(c) || c == '_')
				{
					int num = ParseIdentifier();
					if (IsOperatorName(num))
					{
						m_fThisIsOperator = true;
					}
					return num;
				}
				break;
			}
			throw new XPathException("invalid token: '" + c + "'");
		}

		public bool advance()
		{
			m_fThisIsOperator = false;
			m_objToken = null;
			m_iToken = ParseToken();
			SkipWhitespace();
			m_iTokenPrev = m_iToken;
			m_fPrevWasOperator = m_fThisIsOperator;
			return m_iToken != 258;
		}

		public int token()
		{
			return m_iToken;
		}

		public object value()
		{
			return m_objToken;
		}

		private bool IsNodeType(int iToken)
		{
			switch (iToken)
			{
			case 322:
			case 324:
			case 326:
			case 328:
				return true;
			default:
				return false;
			}
		}

		private bool IsOperatorName(int iToken)
		{
			switch (iToken)
			{
			case 274:
			case 276:
			case 278:
			case 280:
				return true;
			default:
				return false;
			}
		}

		private bool IsAxisName(int iToken)
		{
			switch (iToken)
			{
			case 296:
			case 298:
			case 300:
			case 302:
			case 304:
			case 306:
			case 308:
			case 310:
			case 312:
			case 314:
			case 316:
			case 318:
			case 320:
				return true;
			default:
				return false;
			}
		}
	}
}
internal static class Consts
{
	public const string MonoVersion = "2.6.5.0";

	public const string MonoCompany = "MONO development team";

	public const string MonoProduct = "MONO Common language infrastructure";

	public const string MonoCopyright = "(c) various MONO Authors";

	public const string FxVersion = "2.0.0.0";

	public const string VsVersion = "8.0.0.0";

	public const string FxFileVersion = "2.0.50727.1433";

	public const string VsFileVersion = "8.0.50727.1433";

	public const string AssemblyI18N = "I18N, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMicrosoft_VisualStudio = "Microsoft.VisualStudio, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMicrosoft_VisualStudio_Web = "Microsoft.VisualStudio.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMicrosoft_VSDesigner = "Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMono_Http = "Mono.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Posix = "Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Security = "Mono.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Messaging_RabbitMQ = "Mono.Messaging.RabbitMQ, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyCorlib = "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem = "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Data = "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Design = "System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_DirectoryServices = "System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Drawing = "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Drawing_Design = "System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Messaging = "System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Security = "System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_ServiceProcess = "System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Web = "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Windows_Forms = "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Core = "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
}
internal sealed class Locale
{
	private Locale()
	{
	}

	public static string GetText(string msg)
	{
		return msg;
	}

	public static string GetText(string fmt, params object[] args)
	{
		return string.Format(fmt, args);
	}
}
namespace System
{
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoTODOAttribute : Attribute
	{
		private string comment;

		public string Comment => comment;

		public MonoTODOAttribute()
		{
		}

		public MonoTODOAttribute(string comment)
		{
			this.comment = comment;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoDocumentationNoteAttribute : MonoTODOAttribute
	{
		public MonoDocumentationNoteAttribute(string comment)
			: base(comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoExtensionAttribute : MonoTODOAttribute
	{
		public MonoExtensionAttribute(string comment)
			: base(comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoInternalNoteAttribute : MonoTODOAttribute
	{
		public MonoInternalNoteAttribute(string comment)
			: base(comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoLimitationAttribute : MonoTODOAttribute
	{
		public MonoLimitationAttribute(string comment)
			: base(comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoNotSupportedAttribute : MonoTODOAttribute
	{
		public MonoNotSupportedAttribute(string comment)
			: base(comment)
		{
		}
	}
}
namespace Mono.Xml.Schema
{
	internal class XmlSchemaValidatingReader : XmlReader, IHasXmlParserContext, IXmlLineInfo, IXmlNamespaceResolver, IXmlSchemaInfo
	{
		private static readonly XmlSchemaAttribute[] emptyAttributeArray = new XmlSchemaAttribute[0];

		private XmlReader reader;

		private XmlSchemaValidationFlags options;

		private XmlSchemaValidator v;

		private XmlValueGetter getter;

		private XmlSchemaInfo xsinfo;

		private IXmlLineInfo readerLineInfo;

		private ValidationType validationType;

		private IXmlNamespaceResolver nsResolver;

		private XmlSchemaAttribute[] defaultAttributes = emptyAttributeArray;

		private int currentDefaultAttribute = -1;

		private ArrayList defaultAttributesCache = new ArrayList();

		private bool defaultAttributeConsumed;

		private XmlSchemaType currentAttrType;

		private bool validationDone;

		private XmlSchemaElement element;

		int IXmlLineInfo.LineNumber => (readerLineInfo != null) ? readerLineInfo.LineNumber : 0;

		int IXmlLineInfo.LinePosition => (readerLineInfo != null) ? readerLineInfo.LinePosition : 0;

		public XmlSchemaType ElementSchemaType => (element == null) ? null : element.ElementSchemaType;

		public int LineNumber => (readerLineInfo != null) ? readerLineInfo.LineNumber : 0;

		public int LinePosition => (readerLineInfo != null) ? readerLineInfo.LinePosition : 0;

		public XmlSchemaType SchemaType
		{
			get
			{
				if (ReadState != ReadState.Interactive)
				{
					return null;
				}
				switch (NodeType)
				{
				case XmlNodeType.Element:
					if (ElementSchemaType != null)
					{
						return ElementSchemaType;
					}
					return null;
				case XmlNodeType.Attribute:
					if (currentAttrType == null && ElementSchemaType is XmlSchemaComplexType xmlSchemaComplexType)
					{
						if (xmlSchemaComplexType.AttributeUses[new XmlQualifiedName(LocalName, NamespaceURI)] is XmlSchemaAttribute xmlSchemaAttribute)
						{
							currentAttrType = xmlSchemaAttribute.AttributeSchemaType;
						}
						return currentAttrType;
					}
					return currentAttrType;
				default:
					return null;
				}
			}
		}

		public ValidationType ValidationType
		{
			get
			{
				return validationType;
			}
			set
			{
				if (ReadState != 0)
				{
					throw new InvalidOperationException("ValidationType must be set before reading.");
				}
				validationType = value;
			}
		}

		public override int AttributeCount => reader.AttributeCount + defaultAttributes.Length;

		public override string BaseURI => reader.BaseURI;

		public override bool CanResolveEntity => reader.CanResolveEntity;

		public override int Depth
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.Depth;
				}
				if (defaultAttributeConsumed)
				{
					return reader.Depth + 2;
				}
				return reader.Depth + 1;
			}
		}

		public override bool EOF => reader.EOF;

		public override bool HasValue
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.HasValue;
				}
				return true;
			}
		}

		public override bool IsDefault
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.IsDefault;
				}
				return true;
			}
		}

		public override bool IsEmptyElement
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.IsEmptyElement;
				}
				return false;
			}
		}

		public override string this[int i] => GetAttribute(i);

		public override string this[string name] => GetAttribute(name);

		public override string this[string localName, string ns] => GetAttribute(localName, ns);

		public override string LocalName
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.LocalName;
				}
				if (defaultAttributeConsumed)
				{
					return string.Empty;
				}
				return defaultAttributes[currentDefaultAttribute].QualifiedName.Name;
			}
		}

		public override string Name
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.Name;
				}
				if (defaultAttributeConsumed)
				{
					return string.Empty;
				}
				XmlQualifiedName qualifiedName = defaultAttributes[currentDefaultAttribute].QualifiedName;
				string prefix = Prefix;
				if (prefix == string.Empty)
				{
					return qualifiedName.Name;
				}
				return prefix + ":" + qualifiedName.Name;
			}
		}

		public override string NamespaceURI
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.NamespaceURI;
				}
				if (defaultAttributeConsumed)
				{
					return string.Empty;
				}
				return defaultAttributes[currentDefaultAttribute].QualifiedName.Namespace;
			}
		}

		public override XmlNameTable NameTable => reader.NameTable;

		public override XmlNodeType NodeType
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.NodeType;
				}
				if (defaultAttributeConsumed)
				{
					return XmlNodeType.Text;
				}
				return XmlNodeType.Attribute;
			}
		}

		public XmlParserContext ParserContext => XmlSchemaUtil.GetParserContext(reader);

		public override string Prefix
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.Prefix;
				}
				if (defaultAttributeConsumed)
				{
					return string.Empty;
				}
				XmlQualifiedName qualifiedName = defaultAttributes[currentDefaultAttribute].QualifiedName;
				string text = nsResolver.LookupPrefix(qualifiedName.Namespace);
				if (text == null)
				{
					return string.Empty;
				}
				return text;
			}
		}

		public override char QuoteChar => reader.QuoteChar;

		public override ReadState ReadState => reader.ReadState;

		public override IXmlSchemaInfo SchemaInfo => this;

		public override string Value
		{
			get
			{
				if (currentDefaultAttribute < 0)
				{
					return reader.Value;
				}
				string text = defaultAttributes[currentDefaultAttribute].ValidatedDefaultValue;
				if (text == null)
				{
					text = defaultAttributes[currentDefaultAttribute].ValidatedFixedValue;
				}
				return text;
			}
		}

		public override string XmlLang
		{
			get
			{
				string xmlLang = reader.XmlLang;
				if (xmlLang != null)
				{
					return xmlLang;
				}
				int num = FindDefaultAttribute("lang", "http://www.w3.org/XML/1998/namespace");
				if (num < 0)
				{
					return null;
				}
				xmlLang = defaultAttributes[num].ValidatedDefaultValue;
				if (xmlLang == null)
				{
					xmlLang = defaultAttributes[num].ValidatedFixedValue;
				}
				return xmlLang;
			}
		}

		public override XmlSpace XmlSpace
		{
			get
			{
				XmlSpace xmlSpace = reader.XmlSpace;
				if (xmlSpace != 0)
				{
					return xmlSpace;
				}
				int num = FindDefaultAttribute("space", "http://www.w3.org/XML/1998/namespace");
				if (num < 0)
				{
					return XmlSpace.None;
				}
				string text = defaultAttributes[num].ValidatedDefaultValue;
				if (text == null)
				{
					text = defaultAttributes[num].ValidatedFixedValue;
				}
				return (XmlSpace)(int)Enum.Parse(typeof(XmlSpace), text, ignoreCase: false);
			}
		}

		public bool IsNil => xsinfo.IsNil;

		public XmlSchemaSimpleType MemberType => xsinfo.MemberType;

		public XmlSchemaAttribute SchemaAttribute => xsinfo.SchemaAttribute;

		public XmlSchemaElement SchemaElement => xsinfo.SchemaElement;

		public XmlSchemaValidity Validity => xsinfo.Validity;

		public event ValidationEventHandler ValidationEventHandler
		{
			add
			{
				v.ValidationEventHandler += value;
			}
			remove
			{
				v.ValidationEventHandler -= value;
			}
		}

		public XmlSchemaValidatingReader(XmlReader reader, XmlReaderSettings settings)
		{
			XmlSchemaValidatingReader xmlSchemaValidatingReader = this;
			IXmlNamespaceResolver xmlNamespaceResolver = reader as IXmlNamespaceResolver;
			if (xmlNamespaceResolver == null)
			{
				xmlNamespaceResolver = new XmlNamespaceManager(reader.NameTable);
			}
			XmlSchemaSet xmlSchemaSet = settings.Schemas;
			if (xmlSchemaSet == null)
			{
				xmlSchemaSet = new XmlSchemaSet();
			}
			options = settings.ValidationFlags;
			this.reader = reader;
			v = new XmlSchemaValidator(reader.NameTable, xmlSchemaSet, xmlNamespaceResolver, options);
			if (reader.BaseURI != string.Empty)
			{
				v.SourceUri = new Uri(reader.BaseURI);
			}
			readerLineInfo = reader as IXmlLineInfo;
			getter = () => (xmlSchemaValidatingReader.v.CurrentAttributeType != null) ? xmlSchemaValidatingReader.v.CurrentAttributeType.ParseValue(xmlSchemaValidatingReader.Value, xmlSchemaValidatingReader.NameTable, xmlSchemaValidatingReader) : xmlSchemaValidatingReader.Value;
			xsinfo = new XmlSchemaInfo();
			v.LineInfoProvider = this;
			v.ValidationEventSender = reader;
			nsResolver = xmlNamespaceResolver;
			ValidationEventHandler += delegate(object o, ValidationEventArgs e)
			{
				settings.OnValidationError(o, e);
			};
			if (settings != null && settings.Schemas != null)
			{
				v.XmlResolver = settings.Schemas.XmlResolver;
			}
			else
			{
				v.XmlResolver = new XmlUrlResolver();
			}
			v.Initialize();
		}

		bool IXmlLineInfo.HasLineInfo()
		{
			return readerLineInfo != null && readerLineInfo.HasLineInfo();
		}

		private void ResetStateOnRead()
		{
			currentDefaultAttribute = -1;
			defaultAttributeConsumed = false;
			currentAttrType = null;
			defaultAttributes = emptyAttributeArray;
			v.CurrentAttributeType = null;
		}

		public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
		{
			if (!(reader is IXmlNamespaceResolver xmlNamespaceResolver))
			{
				throw new NotSupportedException("The input XmlReader does not implement IXmlNamespaceResolver and thus this validating reader cannot collect in-scope namespaces.");
			}
			return xmlNamespaceResolver.GetNamespacesInScope(scope);
		}

		public string LookupPrefix(string ns)
		{
			return nsResolver.LookupPrefix(ns);
		}

		public override void Close()
		{
			reader.Close();
		}

		public override string GetAttribute(int i)
		{
			XmlNodeType nodeType = reader.NodeType;
			if (nodeType == XmlNodeType.DocumentType || nodeType == XmlNodeType.XmlDeclaration)
			{
				return reader.GetAttribute(i);
			}
			if (reader.AttributeCount > i)
			{
				reader.GetAttribute(i);
			}
			int num = i - reader.AttributeCount;
			if (i < AttributeCount)
			{
				return defaultAttributes[num].DefaultValue;
			}
			throw new ArgumentOutOfRangeException("i", i, "Specified attribute index is out of range.");
		}

		public override string GetAttribute(string name)
		{
			XmlNodeType nodeType = reader.NodeType;
			if (nodeType == XmlNodeType.DocumentType || nodeType == XmlNodeType.XmlDeclaration)
			{
				return reader.GetAttribute(name);
			}
			string attribute = reader.GetAttribute(name);
			if (attribute != null)
			{
				return attribute;
			}
			XmlQualifiedName xmlQualifiedName = SplitQName(name);
			return GetDefaultAttribute(xmlQualifiedName.Name, xmlQualifiedName.Namespace);
		}

		private XmlQualifiedName SplitQName(string name)
		{
			XmlConvert.VerifyName(name);
			Exception innerEx = null;
			XmlQualifiedName result = XmlSchemaUtil.ToQName(reader, name, out innerEx);
			if (innerEx != null)
			{
				return XmlQualifiedName.Empty;
			}
			return result;
		}

		public override string GetAttribute(string localName, string ns)
		{
			XmlNodeType nodeType = reader.NodeType;
			if (nodeType == XmlNodeType.DocumentType || nodeType == XmlNodeType.XmlDeclaration)
			{
				return reader.GetAttribute(localName, ns);
			}
			string attribute = reader.GetAttribute(localName, ns);
			if (attribute != null)
			{
				return attribute;
			}
			return GetDefaultAttribute(localName, ns);
		}

		private string GetDefaultAttribute(string localName, string ns)
		{
			int num = FindDefaultAttribute(localName, ns);
			if (num < 0)
			{
				return null;
			}
			string text = defaultAttributes[num].ValidatedDefaultValue;
			if (text == null)
			{
				text = defaultAttributes[num].ValidatedFixedValue;
			}
			return text;
		}

		private int FindDefaultAttribute(string localName, string ns)
		{
			for (int i = 0; i < defaultAttribute

plugins/MtGAPI/System.Xml.Linq.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
using System.Text;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.XPath;

[assembly: AssemblyTitle("System.Xml.Linq.dll")]
[assembly: AssemblyDescription("System.Xml.Linq.dll")]
[assembly: AssemblyDefaultAlias("System.Xml.Linq.dll")]
[assembly: AssemblyCompany("Mono development team")]
[assembly: AssemblyProduct("Mono Common Language Infrastructure")]
[assembly: AssemblyCopyright("(c) Various Mono authors")]
[assembly: SatelliteContractVersion("3.5.0.0")]
[assembly: AssemblyInformationalVersion("3.5.21022.8")]
[assembly: AssemblyFileVersion("3.5.21022.8")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("../ecma.pub")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: ComVisible(false)]
[assembly: CompilationRelaxations(CompilationRelaxations.NoStringInterning)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("3.5.0.0")]
internal static class Consts
{
	public const string MonoVersion = "3.12.1.0";

	public const string MonoCompany = "Mono development team";

	public const string MonoProduct = "Mono Common Language Infrastructure";

	public const string MonoCopyright = "(c) Various Mono authors";

	public const string FxVersion = "3.5.0.0";

	public const string FxFileVersion = "3.5.21022.8";

	public const string VsVersion = "0.0.0.0";

	private const string PublicKeyToken = "b77a5c561934e089";

	public const string AssemblyI18N = "I18N, Version=3.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMicrosoft_VisualStudio = "Microsoft.VisualStudio, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMicrosoft_VisualStudio_Web = "Microsoft.VisualStudio.Web, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMicrosoft_VSDesigner = "Microsoft.VSDesigner, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblyMono_Http = "Mono.Http, Version=3.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Posix = "Mono.Posix, Version=3.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Security = "Mono.Security, Version=3.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyMono_Messaging_RabbitMQ = "Mono.Messaging.RabbitMQ, Version=3.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";

	public const string AssemblyCorlib = "mscorlib, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem = "System, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Data = "System.Data, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Design = "System.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_DirectoryServices = "System.DirectoryServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Drawing = "System.Drawing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Drawing_Design = "System.Drawing.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Messaging = "System.Messaging, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Security = "System.Security, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_ServiceProcess = "System.ServiceProcess, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Web = "System.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";

	public const string AssemblySystem_Windows_Forms = "System.Windows.Forms, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

	public const string AssemblySystem_Core = "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
}
internal sealed class Locale
{
	private Locale()
	{
	}

	public static string GetText(string msg)
	{
		/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
	}

	public static string GetText(string fmt, params object[] args)
	{
		/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
	}
}
namespace System
{
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoTODOAttribute : Attribute
	{
		private string comment;

		public string Comment
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public MonoTODOAttribute()
		{
		}

		public MonoTODOAttribute(string comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoDocumentationNoteAttribute : MonoTODOAttribute
	{
		public MonoDocumentationNoteAttribute(string comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoExtensionAttribute : MonoTODOAttribute
	{
		public MonoExtensionAttribute(string comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoInternalNoteAttribute : MonoTODOAttribute
	{
		public MonoInternalNoteAttribute(string comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoLimitationAttribute : MonoTODOAttribute
	{
		public MonoLimitationAttribute(string comment)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
	internal class MonoNotSupportedAttribute : MonoTODOAttribute
	{
		public MonoNotSupportedAttribute(string comment)
		{
		}
	}
}
namespace System.Xml.Linq
{
	public static class Extensions
	{
		[DebuggerHidden]
		public static IEnumerable<XElement> Ancestors<T>(this IEnumerable<T> source) where T : XNode
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> Ancestors<T>(this IEnumerable<T> source, XName name) where T : XNode
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> AncestorsAndSelf(this IEnumerable<XElement> source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> AncestorsAndSelf(this IEnumerable<XElement> source, XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XAttribute> Attributes(this IEnumerable<XElement> source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XAttribute> Attributes(this IEnumerable<XElement> source, XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XNode> DescendantNodes<T>(this IEnumerable<T> source) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XNode> DescendantNodesAndSelf(this IEnumerable<XElement> source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> Descendants<T>(this IEnumerable<T> source) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> Descendants<T>(this IEnumerable<T> source, XName name) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> DescendantsAndSelf(this IEnumerable<XElement> source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> DescendantsAndSelf(this IEnumerable<XElement> source, XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> Elements<T>(this IEnumerable<T> source) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> Elements<T>(this IEnumerable<T> source, XName name) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<T> InDocumentOrder<T>(this IEnumerable<T> source) where T : XNode
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XNode> Nodes<T>(this IEnumerable<T> source) where T : XContainer
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static void Remove(this IEnumerable<XAttribute> source)
		{
		}

		public static void Remove<T>(this IEnumerable<T> source) where T : XNode
		{
		}
	}
	[Flags]
	public enum LoadOptions
	{
		None = 0,
		PreserveWhitespace = 1,
		SetBaseUri = 2,
		SetLineInfo = 4
	}
	[Flags]
	public enum SaveOptions
	{
		None = 0,
		DisableFormatting = 1
	}
	public class XAttribute : XObject
	{
		private static readonly XAttribute[] empty_array;

		private XName name;

		private string value;

		private XAttribute next;

		private XAttribute previous;

		private static readonly char[] escapeChars;

		public static IEnumerable<XAttribute> EmptySequence
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public bool IsNamespaceDeclaration
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XName Name
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XAttribute NextAttribute
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XAttribute PreviousAttribute
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XAttribute(XAttribute other)
		{
		}

		public XAttribute(XName name, object value)
		{
		}

		[CLSCompliant(false)]
		public static explicit operator bool(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator bool?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTime(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTime?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTimeOffset(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTimeOffset?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator decimal(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator decimal?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator double(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator double?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator float(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator float?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator Guid(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator Guid?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator int(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator int?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator long(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator long?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator uint(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator uint?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator ulong(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator ulong?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator TimeSpan(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator TimeSpan?(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator string(XAttribute attribute)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void Remove()
		{
		}

		public void SetValue(object value)
		{
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	public class XCData : XText
	{
		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XCData(string value)
		{
		}

		public XCData(XCData other)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}
	}
	public class XComment : XNode
	{
		private string value;

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XComment(string value)
		{
		}

		public XComment(XComment other)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}
	}
	public abstract class XContainer : XNode
	{
		private XNode first;

		private XNode last;

		public XNode FirstNode
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public XNode LastNode
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		internal XContainer()
		{
		}

		private void CheckChildType(object o, bool addFirst)
		{
		}

		public void Add(object content)
		{
		}

		private void AddNode(XNode n)
		{
		}

		public void Add(params object[] content)
		{
		}

		public void AddFirst(object content)
		{
		}

		public void AddFirst(params object[] content)
		{
		}

		internal virtual bool OnAddingObject(object o, bool rejectAttribute, XNode refNode, bool addFirst)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XmlWriter CreateWriter()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XNode> Nodes()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XNode> DescendantNodes()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> Descendants()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> Descendants(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> Elements()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> Elements(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XElement Element(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		internal void ReadContentFrom(XmlReader reader, LoadOptions options)
		{
		}

		public void RemoveNodes()
		{
		}

		public void ReplaceNodes(object content)
		{
		}

		public void ReplaceNodes(params object[] content)
		{
		}
	}
	public class XDeclaration
	{
		private string encoding;

		private string standalone;

		private string version;

		public string Encoding
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public string Standalone
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public string Version
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XDeclaration(string version, string encoding, string standalone)
		{
		}

		public XDeclaration(XDeclaration other)
		{
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	public class XDocument : XContainer
	{
		private XDeclaration xmldecl;

		public XDeclaration Declaration
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XDocumentType DocumentType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XElement Root
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XDocument()
		{
		}

		public XDocument(params object[] content)
		{
		}

		public XDocument(XDeclaration declaration, params object[] content)
		{
		}

		public XDocument(XDocument other)
		{
		}

		public static XDocument Load(string uri)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(string uri, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(Stream stream)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(Stream stream, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(TextReader textReader)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(TextReader textReader, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(XmlReader reader)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Load(XmlReader reader, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private static XDocument LoadCore(XmlReader reader, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private void ReadContent(XmlReader reader, LoadOptions options)
		{
		}

		private static void ValidateWhitespace(string s)
		{
		}

		public static XDocument Parse(string text)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XDocument Parse(string text, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void Save(string fileName)
		{
		}

		public void Save(string fileName, SaveOptions options)
		{
		}

		public void Save(TextWriter textWriter)
		{
		}

		public void Save(TextWriter textWriter, SaveOptions options)
		{
		}

		public void Save(XmlWriter writer)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}

		internal override bool OnAddingObject(object obj, bool rejectAttribute, XNode refNode, bool addFirst)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private void VerifyAddedNode(object node, bool addFirst)
		{
		}
	}
	public class XDocumentType : XNode
	{
		private string name;

		private string pubid;

		private string sysid;

		private string intSubset;

		public string Name
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public string PublicId
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public string SystemId
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public string InternalSubset
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XDocumentType(string name, string publicId, string systemId, string internalSubset)
		{
		}

		public XDocumentType(XDocumentType other)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}
	}
	[XmlSchemaProvider(null, IsAny = true)]
	[XmlTypeConvertor("ConvertForAssignment")]
	public class XElement : XContainer, IXmlSerializable
	{
		private static IEnumerable<XElement> emptySequence;

		private XName name;

		private XAttribute attr_first;

		private XAttribute attr_last;

		private bool explicit_is_empty;

		public static IEnumerable<XElement> EmptySequence
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XAttribute FirstAttribute
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public XAttribute LastAttribute
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public bool HasAttributes
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public bool HasElements
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public bool IsEmpty
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public XName Name
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XElement(XName name, object content)
		{
		}

		public XElement(XElement other)
		{
		}

		public XElement(XName name)
		{
		}

		public XElement(XName name, params object[] content)
		{
		}

		public XElement(XStreamingElement other)
		{
		}

		private static object ConvertForAssignment(object value)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator bool(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator bool?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTime(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTime?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTimeOffset(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator DateTimeOffset?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator decimal(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator decimal?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator double(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator double?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator float(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator float?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator Guid(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator Guid?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator int(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator int?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator long(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator long?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator uint(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator uint?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator ulong(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator ulong?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator TimeSpan(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator TimeSpan?(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static explicit operator string(XElement element)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private IEnumerable<XElement> GetAncestorList(XName name, bool getMeIn)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XAttribute Attribute(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XAttribute> Attributes()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XAttribute> Attributes(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private static void DefineDefaultSettings(XmlReaderSettings settings, LoadOptions options)
		{
		}

		private static XmlReaderSettings CreateDefaultSettings(LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(string uri)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(string uri, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(TextReader textReader)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(TextReader textReader, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(XmlReader reader)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Load(XmlReader reader, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		internal static XElement LoadCore(XmlReader r, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Parse(string text)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement Parse(string text, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void RemoveAll()
		{
		}

		public void RemoveAttributes()
		{
		}

		public void Save(string fileName)
		{
		}

		public void Save(string fileName, SaveOptions options)
		{
		}

		public void Save(TextWriter textWriter)
		{
		}

		public void Save(TextWriter textWriter, SaveOptions options)
		{
		}

		public void Save(XmlWriter writer)
		{
		}

		public IEnumerable<XElement> AncestorsAndSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public IEnumerable<XElement> AncestorsAndSelf(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public IEnumerable<XElement> DescendantsAndSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public IEnumerable<XElement> DescendantsAndSelf(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XNode> DescendantNodesAndSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void SetAttributeValue(XName name, object value)
		{
		}

		private void SetAttributeObject(XAttribute a)
		{
		}

		private string LookupPrefix(string ns, XmlWriter w)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private static string CreateDummyNamespace(ref int createdNS, IEnumerable<XAttribute> atts, bool isAttr)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override void WriteTo(XmlWriter writer)
		{
		}

		public XNamespace GetDefaultNamespace()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XNamespace GetNamespaceOfPrefix(string prefix)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public string GetPrefixOfNamespace(XNamespace ns)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		private IEnumerable<string> GetPrefixOfNamespaceCore(XNamespace ns)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void ReplaceAll(object content)
		{
		}

		public void ReplaceAll(params object[] content)
		{
		}

		public void ReplaceAttributes(object content)
		{
		}

		public void ReplaceAttributes(params object[] content)
		{
		}

		public void SetElementValue(XName name, object value)
		{
		}

		public void SetValue(object value)
		{
		}

		internal override bool OnAddingObject(object o, bool rejectAttribute, XNode refNode, bool addFirst)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		void IXmlSerializable.WriteXml(XmlWriter writer)
		{
		}

		void IXmlSerializable.ReadXml(XmlReader reader)
		{
		}

		XmlSchema IXmlSerializable.GetSchema()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	internal class XChildrenIterator : IEnumerable<object>, IEnumerable
	{
		private XContainer source;

		private XNode n;

		public XChildrenIterator(XContainer source)
		{
		}

		[DebuggerHidden]
		public IEnumerator<object> GetEnumerator()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	[Serializable]
	public sealed class XName : IEquatable<XName>, ISerializable
	{
		private string local;

		private XNamespace ns;

		public string LocalName
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XNamespace Namespace
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string NamespaceName
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		private XName(SerializationInfo info, StreamingContext context)
		{
		}

		internal XName(string local, XNamespace ns)
		{
		}

		private static Exception ErrorInvalidExpandedName()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool Equals(object obj)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		bool IEquatable<XName>.Equals(XName other)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XName Get(string expandedName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private static void ExpandName(string expandedName, out string local, out string ns)
		{
		}

		public static XName Get(string localName, string namespaceName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override int GetHashCode()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool operator ==(XName left, XName right)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static implicit operator XName(string expandedName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool operator !=(XName left, XName right)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
		}
	}
	public sealed class XNamespace
	{
		private static readonly XNamespace blank;

		private static readonly XNamespace xml;

		private static readonly XNamespace xmlns;

		private static Dictionary<string, XNamespace> nstable;

		private string uri;

		private Dictionary<string, XName> table;

		public static XNamespace None
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public static XNamespace Xml
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public static XNamespace Xmlns
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string NamespaceName
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		static XNamespace()
		{
		}

		private XNamespace(string namespaceName)
		{
		}

		public static XNamespace Get(string namespaceName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XName GetName(string localName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool Equals(object obj)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool operator ==(XNamespace left, XNamespace right)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool operator !=(XNamespace left, XNamespace right)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XName operator +(XNamespace ns, string localName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[CLSCompliant(false)]
		public static implicit operator XNamespace(string namespaceName)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override int GetHashCode()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	public abstract class XNode : XObject
	{
		private static XNodeEqualityComparer eq_comparer;

		private static XNodeDocumentOrderComparer order_comparer;

		private XNode previous;

		private XNode next;

		public static XNodeDocumentOrderComparer DocumentOrderComparer
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public static XNodeEqualityComparer EqualityComparer
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XNode PreviousNode
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public XNode NextNode
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		internal XNode()
		{
		}

		public static int CompareDocumentOrder(XNode n1, XNode n2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool DeepEquals(XNode n1, XNode n2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public string ToString(SaveOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void AddAfterSelf(object content)
		{
		}

		public void AddAfterSelf(params object[] content)
		{
		}

		public void AddBeforeSelf(object content)
		{
		}

		public void AddBeforeSelf(params object[] content)
		{
		}

		public static XNode ReadFrom(XmlReader reader)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		internal static XNode ReadFrom(XmlReader r, LoadOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void Remove()
		{
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public abstract void WriteTo(XmlWriter writer);

		[DebuggerHidden]
		public IEnumerable<XElement> Ancestors()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> Ancestors(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public XmlReader CreateReader()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> ElementsAfterSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> ElementsAfterSelf(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> ElementsBeforeSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XElement> ElementsBeforeSelf(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public bool IsAfter(XNode node)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public bool IsBefore(XNode node)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XNode> NodesAfterSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<XNode> NodesBeforeSelf()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void ReplaceWith(object content)
		{
		}

		public void ReplaceWith(params object[] content)
		{
		}
	}
	public sealed class XNodeDocumentOrderComparer : IComparer, IComparer<XNode>
	{
		private enum CompareResult
		{
			Same,
			Random,
			Parent,
			Child,
			Ancestor,
			Descendant,
			Preceding,
			Following
		}

		public int Compare(XNode x, XNode y)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private CompareResult CompareCore(XNode n1, XNode n2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private CompareResult CompareSibling(XNode n1, XNode n2, CompareResult forSameValue)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		int IComparer.Compare(object n1, object n2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	public sealed class XNodeEqualityComparer : IEqualityComparer, IEqualityComparer<XNode>
	{
		public bool Equals(XNode x, XNode y)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private bool Equals(XAttribute a1, XAttribute a2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private bool Equals(XDeclaration d1, XDeclaration d2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		bool IEqualityComparer.Equals(object n1, object n2)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private int GetHashCode(XDeclaration d)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public int GetHashCode(XNode obj)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		int IEqualityComparer.GetHashCode(object obj)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
	internal class XNodeNavigator : XPathNavigator
	{
		private static readonly XAttribute attr_ns_xml;

		private XNode node;

		private XAttribute attr;

		private XmlNameTable name_table;

		public override string BaseURI
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool CanEdit
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool HasAttributes
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool HasChildren
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool IsEmptyElement
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string LocalName
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string Name
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string NamespaceURI
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override XmlNameTable NameTable
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override XPathNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string Prefix
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override IXmlSchemaInfo SchemaInfo
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override object UnderlyingObject
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XNodeNavigator(XNode node, XmlNameTable nameTable)
		{
		}

		public XNodeNavigator(XNodeNavigator other)
		{
		}

		private string GetInnerText(XContainer node)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private void GetInnerText(XNode n, ref StringBuilder sb)
		{
		}

		public override XPathNavigator Clone()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool IsSamePosition(XPathNavigator other)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveTo(XPathNavigator other)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToFirstAttribute()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToFirstChild()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToFirstNamespace(XPathNamespaceScope scope)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToId(string id)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToNext()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToNextAttribute()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToNextNamespace(XPathNamespaceScope scope)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToParent()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToPrevious()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override void MoveToRoot()
		{
		}
	}
	internal class XNodeReader : XmlReader, IXmlLineInfo
	{
		private ReadState state;

		private XNode node;

		private XNode start;

		private int attr;

		private bool attr_value;

		private bool end_element;

		private NameTable name_table;

		int IXmlLineInfo.LineNumber
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		int IXmlLineInfo.LinePosition
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override int AttributeCount
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string BaseURI
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override int Depth
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool EOF
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool HasAttributes
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool HasValue
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override bool IsEmptyElement
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string LocalName
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string NamespaceURI
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override XmlNameTable NameTable
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string Prefix
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override ReadState ReadState
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public override string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		internal XNode CurrentNode
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XNodeReader(XNode node)
		{
		}

		bool IXmlLineInfo.HasLineInfo()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		internal XAttribute GetCurrentAttribute()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private XAttribute GetXAttribute(int idx)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private object GetCurrentName()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private object GetName(int attr)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override void Close()
		{
		}

		public override string LookupNamespace(string prefix)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToElement()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToFirstAttribute()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToNextAttribute()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToAttribute(string name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		private string GetPrefixedName(XName name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool MoveToAttribute(string local, string ns)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override string GetAttribute(int i)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override string GetAttribute(string name)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override string GetAttribute(string local, string ns)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool Read()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override bool ReadAttributeValue()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override void ResolveEntity()
		{
		}
	}
	internal class XNodeWriter : XmlWriter
	{
		private XContainer root;

		private bool is_closed;

		private XContainer current;

		private XAttribute attribute;

		private XmlNodeType state;

		public override WriteState WriteState
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XNodeWriter(XContainer fragment)
		{
		}

		private void CheckState()
		{
		}

		private void WritePossiblyTopLevelNode(XNode n, bool possiblyAttribute)
		{
		}

		private void FillXmlns(XElement el, string prefix, XNamespace xns)
		{
		}

		public override void Close()
		{
		}

		public override void Flush()
		{
		}

		public override string LookupPrefix(string ns)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public override void WriteStartDocument()
		{
		}

		public override void WriteStartDocument(bool standalone)
		{
		}

		private void WriteStartDocument(string sddecl)
		{
		}

		public override void WriteEndDocument()
		{
		}

		public override void WriteDocType(string name, string publicId, string systemId, string internalSubset)
		{
		}

		public override void WriteStartElement(string prefix, string name, string ns)
		{
		}

		public override void WriteEndElement()
		{
		}

		public override void WriteFullEndElement()
		{
		}

		private void WriteEndElementInternal(bool forceFull)
		{
		}

		public override void WriteStartAttribute(string prefix, string name, string ns)
		{
		}

		public override void WriteEndAttribute()
		{
		}

		public override void WriteCData(string data)
		{
		}

		public override void WriteComment(string comment)
		{
		}

		public override void WriteProcessingInstruction(string name, string value)
		{
		}

		public override void WriteEntityRef(string name)
		{
		}

		public override void WriteCharEntity(char c)
		{
		}

		public override void WriteWhitespace(string ws)
		{
		}

		public override void WriteString(string data)
		{
		}

		public override void WriteName(string name)
		{
		}

		public override void WriteNmToken(string nmtoken)
		{
		}

		public override void WriteQualifiedName(string name, string ns)
		{
		}

		public override void WriteChars(char[] chars, int start, int len)
		{
		}

		public override void WriteRaw(string data)
		{
		}

		public override void WriteRaw(char[] chars, int start, int len)
		{
		}

		public override void WriteBase64(byte[] data, int start, int len)
		{
		}

		public override void WriteBinHex(byte[] data, int start, int len)
		{
		}

		public override void WriteSurrogateCharEntity(char c1, char c2)
		{
		}
	}
	public abstract class XObject : IXmlLineInfo
	{
		private XContainer owner;

		private List<object> annotations;

		private string baseuri;

		private int line;

		private int column;

		int IXmlLineInfo.LineNumber
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		int IXmlLineInfo.LinePosition
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string BaseUri
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			internal set
			{
			}
		}

		public XDocument Document
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public abstract XmlNodeType NodeType { get; }

		public XElement Parent
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		internal XContainer Owner
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		internal int LineNumber
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		internal int LinePosition
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public event EventHandler<XObjectChangeEventArgs> Changing
		{
			add
			{
			}
			remove
			{
			}
		}

		public event EventHandler<XObjectChangeEventArgs> Changed
		{
			add
			{
			}
			remove
			{
			}
		}

		internal XObject()
		{
		}

		internal void SetOwner(XContainer node)
		{
		}

		public void AddAnnotation(object annotation)
		{
		}

		public T Annotation<T>() where T : class
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public object Annotation(Type type)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<T> Annotations<T>() where T : class
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public IEnumerable<object> Annotations(Type type)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void RemoveAnnotations<T>() where T : class
		{
		}

		public void RemoveAnnotations(Type type)
		{
		}

		bool IXmlLineInfo.HasLineInfo()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		internal void FillLineInfoAndBaseUri(XmlReader r, LoadOptions options)
		{
		}

		internal void OnAddingObject(object addedObject)
		{
		}

		internal void OnAddedObject(object addedObject)
		{
		}

		internal void OnNameChanging(object renamedObject)
		{
		}

		internal void OnNameChanged(object renamedObject)
		{
		}

		internal void OnRemovingObject(object removedObject)
		{
		}

		internal void OnRemovedObject(object removedObject)
		{
		}

		internal void OnValueChanging(object changedObject)
		{
		}

		internal void OnValueChanged(object changedObject)
		{
		}

		private void OnChanging(object sender, XObjectChangeEventArgs args)
		{
		}

		private void OnChanged(object sender, XObjectChangeEventArgs args)
		{
		}
	}
	public enum XObjectChange
	{
		Add,
		Remove,
		Name,
		Value
	}
	public class XObjectChangeEventArgs : EventArgs
	{
		public static readonly XObjectChangeEventArgs Add;

		public static readonly XObjectChangeEventArgs Name;

		public static readonly XObjectChangeEventArgs Remove;

		public static readonly XObjectChangeEventArgs Value;

		private XObjectChange type;

		public XObjectChange ObjectChange
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XObjectChangeEventArgs(XObjectChange objectChange)
		{
		}
	}
	public class XProcessingInstruction : XNode
	{
		private string name;

		private string data;

		public string Data
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string Target
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XProcessingInstruction(string target, string data)
		{
		}

		public XProcessingInstruction(XProcessingInstruction other)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}
	}
	public class XStreamingElement
	{
		private XName name;

		private List<object> contents;

		public XName Name
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		internal IEnumerable<object> Contents
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public XStreamingElement(XName name)
		{
		}

		public XStreamingElement(XName name, object content)
		{
		}

		public XStreamingElement(XName name, params object[] content)
		{
		}

		public void Add(object content)
		{
		}

		public void Add(params object[] content)
		{
		}

		public void Save(string fileName)
		{
		}

		public void Save(TextWriter textWriter)
		{
		}

		public void Save(XmlWriter writer)
		{
		}

		public void Save(string fileName, SaveOptions options)
		{
		}

		public void Save(TextWriter textWriter, SaveOptions options)
		{
		}

		public override string ToString()
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public string ToString(SaveOptions options)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public void WriteTo(XmlWriter writer)
		{
		}

		private void WriteContents(IEnumerable<object> items, XmlWriter w)
		{
		}

		private void WriteAttribute(XAttribute a, XmlWriter w)
		{
		}
	}
	public class XText : XNode
	{
		private string value;

		public override XmlNodeType NodeType
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
		}

		public string Value
		{
			get
			{
				/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
			}
			set
			{
			}
		}

		public XText(string value)
		{
		}

		public XText(XText other)
		{
		}

		public override void WriteTo(XmlWriter writer)
		{
		}
	}
	internal static class XUtil
	{
		public const string XmlnsNamespace = "http://www.w3.org/2000/xmlns/";

		public static bool ConvertToBoolean(string s)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static DateTime ToDateTime(string s)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static string ToString(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool ToBoolean(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static bool? ToNullableBoolean(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<object> ExpandArray(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XNode ToNode(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static object GetDetachedObject(XObject child)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static object Clone(object o)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
}
namespace System.Xml.Schema
{
	public static class Extensions
	{
		public static IXmlSchemaInfo GetSchemaInfo(this XAttribute source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static IXmlSchemaInfo GetSchemaInfo(this XElement source)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static void Validate(this XAttribute source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
		{
		}

		public static void Validate(this XAttribute source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler, bool addSchemaInfo)
		{
		}

		public static void Validate(this XDocument source, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
		{
		}

		public static void Validate(this XDocument source, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler, bool addSchemaInfo)
		{
		}

		[MonoTODO]
		public static void Validate(this XElement source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
		{
		}

		[MonoTODO]
		public static void Validate(this XElement source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler, bool addSchemaInfo)
		{
		}
	}
}
namespace System.Xml.XPath
{
	public static class Extensions
	{
		public static XPathNavigator CreateNavigator(this XNode node)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XPathNavigator CreateNavigator(this XNode node, XmlNameTable nameTable)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static object XPathEvaluate(this XNode node, string expression)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static object XPathEvaluate(this XNode node, string expression, IXmlNamespaceResolver resolver)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		private static IEnumerable<object> GetUnderlyingXObjects(XPathNodeIterator nodeIterator)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement XPathSelectElement(this XNode node, string expression)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static XElement XPathSelectElement(this XNode node, string expression, IXmlNamespaceResolver resolver)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		public static IEnumerable<XElement> XPathSelectElements(this XNode node, string expression)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}

		[DebuggerHidden]
		public static IEnumerable<XElement> XPathSelectElements(this XNode node, string expression, IXmlNamespaceResolver resolver)
		{
			/*Error: Method body consists only of 'ret', but nothing is being returned. Decompiled assembly might be a reference assembly.*/;
		}
	}
}