#region Copyright (C) 2003-2009 Stimulsoft /* {*******************************************************************} { } { Stimulsoft Reports } { } { } { Copyright (C) 2003-2009 Stimulsoft } { ALL RIGHTS RESERVED } { } { The entire contents of this file is protected by U.S. and } { International Copyright Laws. Unauthorized reproduction, } { reverse-engineering, and distribution of all or any portion of } { the code contained in this file is strictly prohibited and may } { result in severe civil and criminal penalties and will be } { prosecuted to the maximum extent possible under the law. } { } { RESTRICTIONS } { } { THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES } { ARE CONFIDENTIAL AND PROPRIETARY } { TRADE SECRETS OF Stimulsoft } { } { CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON } { ADDITIONAL RESTRICTIONS. } { } {*******************************************************************} */ #endregion Copyright (C) 2003-2009 Stimulsoft using System; using System.ComponentModel; using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; using System.Drawing; namespace Stimulsoft.Report.Components.TextFormats.Design { /// /// Provides a type converter to convert StiCustomFormatService objects to and from various other representations. /// public class StiCustomFormatConverter : TypeConverter { public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(value, attributes); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor))return true; return base.CanConvertTo(context, destinationType); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value != null) { StiCustomFormatService service = (StiCustomFormatService)value; Type[] types = new Type[]{ typeof(string) }; ConstructorInfo info = typeof(StiCustomFormatService).GetConstructor(types); if (info != null) { object[] objs = new object[] { service.StringFormat }; return new InstanceDescriptor(info, objs); } } return base.ConvertTo(context, culture, value, destinationType); } } }