﻿// Decompiled with JetBrains decompiler
// Type: System.Xml.Serialization.ReflectionHelper
// Assembly: System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
// MVID: B96316B8-9B8D-4ED8-8305-8C4F91B6775A
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\System.Xml.dll

using System;
using System.Collections;
using System.Reflection;

namespace System.Xml.Serialization
{
  internal class ReflectionHelper
  {
    private static readonly ParameterModifier[] empty_modifiers = new ParameterModifier[0];
    private Hashtable _clrTypes = new Hashtable();
    private Hashtable _schemaTypes = new Hashtable();

    public void RegisterSchemaType(XmlTypeMapping map, string xmlType, string ns)
    {
      string str = xmlType + "/" + ns;
      if (this._schemaTypes.ContainsKey((object) str))
        return;
      this._schemaTypes.Add((object) str, (object) map);
    }

    public XmlTypeMapping GetRegisteredSchemaType(string xmlType, string ns)
    {
      return this._schemaTypes[(object) (xmlType + "/" + ns)] as XmlTypeMapping;
    }

    public void RegisterClrType(XmlTypeMapping map, Type type, string ns)
    {
      if (type == typeof (object))
        ns = string.Empty;
      string str = type.FullName + "/" + ns;
      if (this._clrTypes.ContainsKey((object) str))
        return;
      this._clrTypes.Add((object) str, (object) map);
    }

    public XmlTypeMapping GetRegisteredClrType(Type type, string ns)
    {
      if (type == typeof (object))
        ns = string.Empty;
      return this._clrTypes[(object) (type.FullName + "/" + ns)] as XmlTypeMapping;
    }

    public static void CheckSerializableType(Type type, bool allowPrivateConstructors)
    {
      if (type.IsArray)
        return;
      if (!allowPrivateConstructors && type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder) null, Type.EmptyTypes, ReflectionHelper.empty_modifiers) == null && (!type.IsAbstract && !type.IsValueType))
        throw new InvalidOperationException(type.FullName + " cannot be serialized because it does not have a default public constructor");
      if (type.IsInterface && !TypeTranslator.GetTypeData(type).IsListType)
        throw new InvalidOperationException(type.FullName + " cannot be serialized because it is an interface");
      Type type1 = type;
      while (type1.IsPublic || type1.IsNestedPublic)
      {
        Type type2 = type1;
        type1 = type1.DeclaringType;
        if (type1 == null || type1 == type2)
          return;
      }
      throw new InvalidOperationException(type.FullName + " is inaccessible due to its protection level. Only public types can be processed");
    }
  }
}
