A class not mentioned in ASP. NET Component Design

Source: Internet
Author: User
That's it, itembuilderconverter,
Finally, I figured out what icomponent. Site meant.

Public class itembuilderconverter: typeconverter
{
Public override bool canconvertfrom (itypedescriptorcontext context, type sourcetype)
{
If (sourcetype = typeof (string ))
Return true;
Return base. canconvertfrom (context, sourcetype );
}

Public override bool canconvertion (itypedescriptorcontext context, type destinationtype)
{
If (destinationtype = typeof (string ))
Return true;
Return base. canconvertize (context, destinationtype );
}

Public override object convertfrom (itypedescriptorcontext context, cultureinfo culture, object value)
{
If (value = NULL | value. tostring () = string. Empty) return string. empty;

Object result = context. Container. components [value. tostring ()];
If (result! = NULL)
{
Return Value. tostring ();
}
Return string. empty;
}

Public override object convertion (itypedescriptorcontext context, cultureinfo culture, object value, type destinationtype)
{
If (destinationtype = NULL) throw new exception ("the target type is null ");
If (value = NULL) return NULL;

Return base. convertize (context, culture, value, destinationtype );
}
Public override bool getstandardvaluessupported (itypedescriptorcontext context)
{
Return true;
}


Public override standardvaluescollection getstandardvalues (itypedescriptorcontext context)
{
Ilist list = new arraylist ();

Ienumerator itor = context. Container. components. getenumerator ();
While (itor. movenext ())
{
Object item = itor. Current;
If (item is ilistsbuilder)
{
List. Add (icomponent) item). Site. Name );
}
}
If (list. Count> 0)
{
Return new standardvaluescollection (list );
}
Return base. getstandardvalues (context );
}


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.