Using TypeConverter for Parameterized Constructor Class

Hi,
Can somebody help to know how to use a class having parameterized constructor inherted from typeconverter in the property grid. That means how can I pass parameters to constructor while defining property. Below is the code for your reference.

I have a custom pipeline component and I am adding three custom properties to input columns. Different properties will have different static values. So I have developed a class inherting from Type Converter.

public class BooleanList : TypeConverter
{
    //public BooleanList(string displayValues)
    //{
    //    if (displayValues.ToLower() == "boolean")
    //    {
    //        m_list.Add("Y");
    //        m_list.Add("N");
    //    }
    //   else if (displayValues.ToLower() == "datatypes")
    //    {
    //        m_list.Add("String");
    //        m_list.Add("Numeric");
    //        m_list.Add("DateTime");
    //    }
    //}

    public BooleanList()
    {
        m_list.Add("Y");
        m_list.Add("N");
    }
    public List<string> m_list = new List<string>();

    public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
    {
        return true;
    }
    public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
    {
        return true;
    }
    public StandardValuesCollection GetValues()
    {
        return new StandardValuesCollection(m_list);
    }
    protected void SetList(List<string> list)
    {
        m_list = list;
    }
    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
    {
        return GetValues();
    }
}

The defined property will use the above class and the property will have static values (Y & N) as coded below.
propCheckNull.TypeConverter = typeof(BooleanList);
Now look at the commented part in above class. I want to use this parameterized constructor and want to send parameters while assigning to property values so that I will get static values as per the parameter. Instead of typeof(BooleanList), want to write something else where I can pass parameters.

Let me know if something is unclear.

Thanks
Sakti
saktiranjanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Huh?  I don't understand your requirement.

Bob
0
saktiranjanAuthor Commented:
OK... let me explain little more. The full code which I have posted, is a class which creates a list of values. And if you use this class in a custom property like below, you will get property values in the property grid as dropdown list.
[TypeConverter(typeof(DefineProperty))]
        public string SourceConnection
        {
            get { return this.strConnection; }
            set { strConnection = value; }
        }

In my case I am using this [TypeConverter(typeof(DefineProperty))] in a input column of data flow pipeline component in ssis as
propCheckNull.TypeConverter = typeof(BooleanList); where propCheckNull is a custom property.
Now, Can I use the same class for loading different static values in the property? If I can pass parameter to the constructor, different values can be loaded as per the parameter. But how to write that, I dont know.

Let me know if you need something specific.

Sakti
0
Bob LearnedCommented:
Does that mean that you want to use a single TypeConverter to return different values depending on how it is used?  What value would this have versus having 2 different TypeConverter classes?

Bob
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

saktiranjanAuthor Commented:
I am expecting more than 10 values to be returned on 10 different situation. For each thing, its not good idea to write those many TypeConverter classes.
0
Bob LearnedCommented:
Why not?  I don't see any problem with a base class for each TypeConverter, for the common things, and then a deriving class for the return values.

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saktiranjanAuthor Commented:
I struggled a lot but did not find any other solution except this, though I am not totally convinced.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.