﻿// Decompiled with JetBrains decompiler
// Type: System.Web.UI.MinimizableAttributeTypeConverter
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime;

namespace System.Web.UI
{
  internal class MinimizableAttributeTypeConverter : BooleanConverter
  {
    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public MinimizableAttributeTypeConverter()
    {
    }

    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
    {
      if (sourceType == typeof (string))
        return true;
      return base.CanConvertFrom(context, sourceType);
    }

    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    {
      string a = value as string;
      if (a == null)
        return base.ConvertFrom(context, culture, value);
      if (a.Length > 0 && !string.Equals(a, "false", StringComparison.OrdinalIgnoreCase))
        return (object) true;
      return (object) false;
    }
  }
}
