Get Types

Get Types

C# Web Control Code Sample for GetTypes

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
if (assembly == null) return;
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Output");
output.RenderEndTag(); //Div
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Types in Executing Assembly");
output.RenderEndTag(); //P
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "left");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Border, "0");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Cellpadding, "3");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Table);
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Thead);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Name");
output.RenderEndTag(); //Th
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Assembly");
output.RenderEndTag(); //Th
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Namespace");
output.RenderEndTag(); //Th
output.RenderEndTag(); //Thead
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tbody);
int i = 0;
foreach (System.Type type in assembly.GetTypes())
{
    i++;
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tr);
    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "left");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    output.Write("{0}", type.Name);
    output.RenderEndTag(); //Td
    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "left");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    output.Write("{0}", type.Assembly.GetName().Name);
    output.RenderEndTag(); //Td
    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "left");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    output.Write("{0}", type.Namespace);
    output.RenderEndTag(); //Td
    output.RenderEndTag(); //Tr
    if (i >= 10) break;
}
output.RenderEndTag(); //Tbody
output.RenderEndTag(); //Table
output.RenderEndTag(); //Div

C# Web Control Sample Output for GetItem

Types in Executing Assembly
Name Assembly Namespace
Registration TIC66 TIC66.layouts.TIC.Sublayouts
ViewDatabaseCaches TIC66 TIC66.layouts.TIC.DemoWebControls
ValidItemNames TIC66 TIC66.layouts.TIC.DemoWebControls
ShowSingleLineText TIC66 TIC66.layouts.TIC.DemoWebControls
ShowMultiLineText TIC66 TIC66.layouts.TIC.DemoWebControls
ShowGrpDroplink TIC66 TIC66.layouts.TIC.DemoWebControls
PageRenderings TIC66 TIC66.layouts.TIC.DemoWebControls
OrderedList TIC66 TIC66.layouts.TIC.DemoWebControls
NumberProperties TIC66 TIC66.layouts.TIC.DemoWebControls
MembershipProvider TIC66 TIC66.layouts.TIC.DemoWebControls