using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace TD.SandDock.Rendering
{
	internal class RendererBaseConverter : TypeConverter
	{
		public virtual bool b(ITypeDescriptorContext A_0, Type A_1)
		{
			return A_1 == typeof(string) || A_1 == typeof(InstanceDescriptor) || base.CanConvertTo(A_0, A_1);
		}

		public virtual object a(ITypeDescriptorContext A_0, CultureInfo A_1, object A_2, Type A_3)
		{
			if (A_3 == typeof(string))
			{
				if (A_2 is string)
				{
					return A_2;
				}
				if (A_2 is RendererBase)
				{
					return A_2.ToString();
				}
				return "(default)";
			}
			else
			{
				if (A_3 == typeof(InstanceDescriptor) && A_2 is RendererBase)
				{
					ConstructorInfo constructor = A_2.GetType().GetConstructor(Type.EmptyTypes);
					MemberInfo member = constructor;
					object[] arguments = new object[0];
					return new InstanceDescriptor(member, arguments, true);
				}
				return base.ConvertTo(A_0, A_1, A_2, A_3);
			}
		}

		public virtual object a(ITypeDescriptorContext A_0, CultureInfo A_1, object A_2)
		{
			if (A_2 is string)
			{
				string text;
				if ((text = (string)A_2) != null)
				{
					text = string.IsInterned(text);
					if (text == "Everett")
					{
						return new EverettRenderer();
					}
					if (text == "Office 2003")
					{
						return new Office2003Renderer();
					}
					if (text == "Whidbey")
					{
						return new WhidbeyRenderer();
					}
				}
				return null;
			}
			return base.ConvertFrom(A_0, A_1, A_2);
		}

		public virtual bool a(ITypeDescriptorContext A_0, Type A_1)
		{
			return A_1 == typeof(string) || base.CanConvertFrom(A_0, A_1);
		}

		public virtual bool b(ITypeDescriptorContext A_0)
		{
			return true;
		}

		public virtual bool c(ITypeDescriptorContext A_0)
		{
			return true;
		}

		public virtual TypeConverter.StandardValuesCollection a(ITypeDescriptorContext A_0)
		{
			ArrayList arrayList = new ArrayList();
			if (A_0 != null && A_0.Instance is DockContainer)
			{
				arrayList.Add("(default)");
			}
			arrayList.Add("Everett");
			arrayList.Add("Office 2003");
			arrayList.Add("Whidbey");
			return new TypeConverter.StandardValuesCollection(arrayList);
		}
	}
}
