﻿// Decompiled with JetBrains decompiler
// Type: System.Xml.Schema.Datatype_unsignedByte
// Assembly: System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 50ABAB51-7DC3-4F0A-A797-0D0C2D124D60
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll

using System;
using System.Runtime;
using System.Xml;

namespace System.Xml.Schema
{
  internal class Datatype_unsignedByte : Datatype_unsignedShort
  {
    private static readonly Type atomicValueType = typeof (byte);
    private static readonly Type listValueType = typeof (byte[]);
    private static readonly FacetsChecker numeric10FacetsChecker = (FacetsChecker) new Numeric10FacetsChecker(new Decimal(0), new Decimal((int) byte.MaxValue));

    internal override FacetsChecker FacetsChecker
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return Datatype_unsignedByte.numeric10FacetsChecker;
      }
    }

    public override XmlTypeCode TypeCode
    {
      get
      {
        return XmlTypeCode.UnsignedByte;
      }
    }

    public override Type ValueType
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return Datatype_unsignedByte.atomicValueType;
      }
    }

    internal override Type ListValueType
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return Datatype_unsignedByte.listValueType;
      }
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public Datatype_unsignedByte()
    {
    }

    internal override int Compare(object value1, object value2)
    {
      return ((byte) value1).CompareTo(value2);
    }

    internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
    {
      typedValue = (object) null;
      Exception exception = Datatype_unsignedByte.numeric10FacetsChecker.CheckLexicalFacets(ref s, (XmlSchemaDatatype) this);
      if (exception == null)
      {
        byte result;
        exception = XmlConvert.TryToByte(s, out result);
        if (exception == null)
        {
          exception = Datatype_unsignedByte.numeric10FacetsChecker.CheckValueFacets((short) result, (XmlSchemaDatatype) this);
          if (exception == null)
          {
            typedValue = (object) result;
            return (Exception) null;
          }
        }
      }
      return exception;
    }
  }
}
