Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads
 
Add your own
alternative version

Fixing the IExtenderProvider in Visual Studio's ASP.NET designer

, 4 Jan 2005
An implementation of a custom CodeDomSerializer for repairing the IExtenderProvider in Visual Studio's ASP.NET designer.
namespace ASPExtenderSample
{
	using System;
	using System.Collections;
	using System.ComponentModel;
	using System.ComponentModel.Design.Serialization;
	using System.Web.UI.WebControls;	

	[
	ProvideProperty("PrimitiveTest", typeof(Button)),
	ProvideProperty("EnumTest", typeof(Button)),
	ProvideProperty("StructTest", typeof(Button)),
	ProvideProperty("ClassTest", typeof(Button)),
	ProvideProperty("StringTest", typeof(Button)),
	DesignerSerializer(typeof(ASPExtenderSerializer), typeof(CodeDomSerializer))]
	public class WorkingProvider : Component, IExtenderProvider
	{
		Hashtable _primitives = new Hashtable();
		Hashtable _enums = new Hashtable();
		Hashtable _structs = new Hashtable();
		Hashtable _classes = new Hashtable();
		Hashtable _strings = new Hashtable();

		public bool CanExtend(object extendee)
		{
			return extendee is Button;
		}
		
		[DefaultValue(-1)]
		public int GetPrimitiveTest(Button button)
		{
			if(_primitives.ContainsKey(button))
				return (int)_primitives[button];
			return -1;
		}

		public void SetPrimitiveTest(Button button, int primitive)
		{
			_primitives[button] = primitive;
		}

		[DefaultValue(BindableSupport.Default)]
		public BindableSupport GetEnumTest(Button button)
		{
			if(_enums.ContainsKey(button))
				return (BindableSupport)_enums[button];
			return BindableSupport.Default;
		}

		public void SetEnumTest(Button button, BindableSupport enumValue)
		{
			_enums[button] = enumValue;
		}

		[DefaultValue(typeof(System.Drawing.Color),null)]
		public System.Drawing.Color GetStructTest(Button button)
		{
			if(_structs.ContainsKey(button))
				return (System.Drawing.Color)_structs[button];
			return System.Drawing.Color.Empty;
		}

		public void SetStructTest(Button button, System.Drawing.Color structValue)
		{
			_structs[button] = structValue;
		}

		[DefaultValue(null)]
		public Button GetClassTest(Button button)
		{
			return _classes[button] as  Button;
		}

		public void SetClassTest(Button button, Button classValue)
		{
			_classes[button] = classValue;
		}

		[DefaultValue(null)]
		public string GetStringTest(Button button)
		{
			return _classes[button] as String;
		}

		public void SetStringTest(Button button, string stringValue)
		{
			_classes[button] = stringValue;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Wouter van Vugt
Web Developer Code Counsel
Netherlands Netherlands
Wouter van Vugt is a Microsoft MVP with Office Open XML technologies and an independent consultant focusing on creating Office Business Applications (OBAs) with SharePoint, the Office 2007 system and related .NET technologies. Wouter is a frequent contributor to developer community sites such as OpenXmlDeveloper.org and MSDN and has published several white papers and articles as well a book available on line titled Open XML: the markup explained. Wouter is the founder of Code-Counsel, a Dutch company focusing on delivering cutting-edge technical content through a variety of channels. You can find out more about Wouter by reading his blog and visiting the Code-Counsel Web site.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 5 Jan 2005
Article Copyright 2005 by Wouter van Vugt
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid