|
| |
| Lostinetdotcom | Asp.Net User |
| Re: Any good ControlBuilder examples? | 12/4/2003 11:53:50 AM |
0/0 | |
|
i have once exp . for get the binding container type:
<em:emigrid runat=server>
<menus>
<em:menu Enabled='<%#Containser....%>' Visible='<%#Containser....%>' Text='Open'/>
</menus>
<columns>
<em:TextBoundingColumn .../>
</columns>
</em:emigrid>
because the menu item is just prototype , and it's cant use TemplateContainerAttribute ,
so i wrap the Type for typename of BindingContainer
emigrid declare as:
[ControlBuilder(typeof(EmiGridBuilder))]
public class EmiGrid : ....
code here:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml;
using System.Diagnostics;
namespace Grids
{
public class EmiGridBuilder:ControlBuilder
{
public override void Init(System.Web.UI.TemplateParser parser, System.Web.UI.ControlBuilder parentBuilder, System.Type type, string tagName, string id, System.Collections.IDictionary attribs)
{
base.Init(parser,parentBuilder,new EmiGridType(),tagName,id,attribs);
}
public class EmiGridType:ProxyType
{
protected override Type InnerType
{
get
{
StackTrace st=new StackTrace();
for(int i=0;i<st.FrameCount;i++)
{
StackFrame sf=st.GetFrame(i);
MethodBase mi=sf.GetMethod();
if(mi.Name=="BuildPropertyBindingMethod")
{
int offset=sf.GetNativeOffset();
if(offset==472||offset==684)
continue;
return typeof(Grids.EmiGridItem);
}
}
return typeof(Grids.EmiGrid);
}
}
}
}
public abstract class ProxyType:Type
{
abstract protected Type InnerType
{
get;
}
protected object InvokeMethod(params object[] args)
{
string name=new StackTrace(1).GetFrame(0).GetMethod().Name;
return typeof(Type).InvokeMember(name,
BindingFlags.InvokeMethod|BindingFlags.Instance|BindingFlags.NonPublic,
null,InnerType,args);
}
public override System.Reflection.Assembly Assembly
{
get
{
return InnerType.Assembly;;
}
}
public override string AssemblyQualifiedName
{
get
{
return InnerType.AssemblyQualifiedName;
}
}
public override System.Type BaseType
{
get
{
return InnerType.BaseType;
}
}
public override System.Type DeclaringType
{
get
{
return InnerType.DeclaringType;
}
}
public override bool Equals(object o)
{
return InnerType.Equals(o);
}
public override System.Type[] FindInterfaces(System.Reflection.TypeFilter filter, object filterCriteria)
{
return InnerType.FindInterfaces(filter,filterCriteria);
}
public override System.Reflection.MemberInfo[] FindMembers(System.Reflection.MemberTypes memberType, System.Reflection.BindingFlags bindingAttr, System.Reflection.MemberFilter filter, object filterCriteria)
{
return InnerType.FindMembers(memberType,bindingAttr,filter,filterCriteria);
}
public override string FullName
{
get
{
return InnerType.FullName;
}
}
public override int GetArrayRank()
{
return InnerType.GetArrayRank();
}
protected override System.Reflection.TypeAttributes GetAttributeFlagsImpl()
{
return (System.Reflection.TypeAttributes)InvokeMethod();
}
protected override System.Reflection.ConstructorInfo GetConstructorImpl(
System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder,
System.Reflection.CallingConventions callConvention,
System.Type[] types,
System.Reflection.ParameterModifier[] modifiers
)
{
return (System.Reflection.ConstructorInfo)InvokeMethod(bindingAttr,binder,callConvention,types,modifiers);
}
public override System.Reflection.ConstructorInfo[] GetConstructors(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetConstructors(bindingAttr);
}
public override System.Reflection.MemberInfo[] GetDefaultMembers()
{
return InnerType.GetDefaultMembers();
}
public override System.Type GetElementType()
{
return InnerType.GetElementType();
}
public override System.Reflection.EventInfo GetEvent(string name, System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetEvent(name,bindingAttr);
}
public override System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetEvents(bindingAttr);
}
public override System.Reflection.EventInfo[] GetEvents()
{
return InnerType.GetEvents();
}
public override System.Reflection.FieldInfo GetField(string name, System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetField(name,bindingAttr);
}
public override System.Reflection.FieldInfo[] GetFields(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetFields(bindingAttr);
}
public override int GetHashCode()
{
return InnerType.GetHashCode();
}
public override System.Type GetInterface(string name, bool ignoreCase)
{
return InnerType.GetInterface(name,ignoreCase);
}
public override System.Reflection.InterfaceMapping GetInterfaceMap(System.Type interfaceType)
{
return InnerType.GetInterfaceMap(interfaceType);
}
public override System.Type[] GetInterfaces()
{
return InnerType.GetInterfaces();
}
public override System.Reflection.MemberInfo[] GetMember(string name, System.Reflection.MemberTypes type, System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetMember(name,type,bindingAttr);
}
public override System.Reflection.MemberInfo[] GetMember(string name, System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetMember(name,bindingAttr);
}
public override System.Reflection.MemberInfo[] GetMembers(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetMembers(bindingAttr);
}
protected override System.Reflection.MethodInfo GetMethodImpl(
string name,
System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder,
System.Reflection.CallingConventions callConvention,
System.Type[] types,
System.Reflection.ParameterModifier[] modifiers)
{
return (System.Reflection.MethodInfo)InvokeMethod(name,bindingAttr,binder,callConvention,types,modifiers);
}
public override System.Reflection.MethodInfo[] GetMethods(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetMethods(bindingAttr);
}
public override System.Type GetNestedType(string name, System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetNestedType(name,bindingAttr);
}
public override System.Type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetNestedTypes(bindingAttr);
}
public override System.Reflection.PropertyInfo[] GetProperties(System.Reflection.BindingFlags bindingAttr)
{
return InnerType.GetProperties(bindingAttr);
}
protected override System.Reflection.PropertyInfo GetPropertyImpl(
string name,
System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder,
System.Type returnType,
System.Type[] types,
System.Reflection.ParameterModifier[] modifiers)
{
return (System.Reflection.PropertyInfo)InvokeMethod(name,bindingAttr,binder,returnType,types,modifiers);
}
public override System.Guid GUID
{
get
{
return InnerType.GUID;
}
}
protected override bool HasElementTypeImpl()
{
return (bool)InvokeMethod();
}
public override object InvokeMember(string name, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object target, object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] namedParameters)
{
return InnerType.InvokeMember(name,invokeAttr,binder,target,args,modifiers,culture,namedParameters);
}
protected override bool IsArrayImpl()
{
return (bool)InvokeMethod();
}
public override bool IsAssignableFrom(System.Type c)
{
return InnerType.IsAssignableFrom(c);
}
protected override bool IsByRefImpl()
{
return (bool)InvokeMethod();
}
protected override bool IsCOMObjectImpl()
{
return (bool)InvokeMethod();
}
protected override bool IsContextfulImpl()
{
return (bool)InvokeMethod();
}
public override bool IsInstanceOfType(object o)
{
return InnerType.IsInstanceOfType(o);
}
protected override bool IsMarshalByRefImpl()
{
return (bool)InvokeMethod();
}
protected override bool IsPointerImpl()
{
return (bool)InvokeMethod();
}
protected override bool IsPrimitiveImpl()
{
return (bool)InvokeMethod();
}
public override bool IsSubclassOf(System.Type c)
{
return InnerType.IsSubclassOf(c);
}
protected override bool IsValueTypeImpl()
{
return (bool)InvokeMethod();
}
public override System.Reflection.MemberTypes MemberType
{
get
{
return InnerType.MemberType;
}
}
public override System.Reflection.Module Module
{
get
{
return InnerType.Module;
}
}
public override string Namespace
{
get
{
return InnerType.Namespace;
}
}
public override System.Type ReflectedType
{
get
{
return InnerType.ReflectedType;
}
}
public override string ToString()
{
return InnerType.ToString();
}
public override System.RuntimeTypeHandle TypeHandle
{
get
{
return InnerType.TypeHandle;
}
}
public override System.Type UnderlyingSystemType
{
get
{
return InnerType.UnderlyingSystemType;
}
}
public override object[] GetCustomAttributes(System.Type attributeType, bool inherit)
{
return InnerType.GetCustomAttributes(attributeType,inherit);
}
public override object[] GetCustomAttributes(bool inherit)
{
return InnerType.GetCustomAttributes(inherit);
}
public override bool IsDefined(System.Type attributeType, bool inherit)
{
return InnerType.IsDefined(attributeType,inherit);
}
public override string Name
{
get
{
return InnerType.Name;
}
}
}
}
Lostinet (Li Jian Dai) .NET MVP
http://www.lostinet.com/ for LWTree/DatePicker
http://www.contextboundmodel.net/ for AOP.NET |
|
| |
Free Download:
Books: Professional Web Parts and Custom Controls with ASP.NET 2.0 Authors: Peter Vogel, Pages: 449, Published: 2005 ASP.NET in a Nutshell: In a Nutshell Authors: G. Andrew Duthie, Matthew MacDonald, Pages: 979, Published: 2003 Tool and Manufacturing Engineers Handbook: A Reference Book for Manufacturing Engineers, Managers, and Technicians Authors: Tom Drozda, Charles Wick, Society of Manufacturing Engineers, Pages: 0, Published: 1983 Geo-Business: GIS in the Digital Organization Authors: James B. Pick, Pages: 396, Published: 2007 ASP.NET AJAX Programming Tricks Authors: Matthew David Ellis, Matthew Ellis, Pages: 388, Published: 2007 Professional ASP.NET 1.0: Updated and Tested for Final Release of ASP.NET V.1.0 Authors: Richard Anderson, Alex Homer, Dave Sussman, Karli Watson, Pages: 1354, Published: 2002 UML 2002--the Unified Modeling Language: Model Engineering, Concepts, and Tools : 5th International Conference, Dresden, Germany, September 30-October 4,2002 : Proceedings Authors: Jean-Marc Jézéquel, Heinrich Hussmann, Stephen Cook, Pages: 447, Published: 2002 Web:ITemplate and ControlBuilder - ASP.NET Forums It is a very good point, though, that in my example the class appears unnecessary. I can only go off the code that you provide and so any ... Attribute, Control - Builder AU This is true for many of the standard ASP.NET features. A good example is the TextBox Web control, which offers plenty of options for building applications. ... David Ebbo's blog : Creating a ControlBuilder for the page itself I know this is just an example scenario for the file-level control builder, but in fact for this specific scenario, there isn't a need to write a control ... Communication between Matlab Simulink and ABB Advant Control Builder An example of how a working Simulink and Advant Control Builder system looks like .... The toolbox Simulink does not provide any possibilities to simulate a ... UMC800 Control Builder User's Guide The Control Builder operates on any computer platform that meets the ..... For example: To open the FILE menu in the Control Builder main window, ... Rory Primrose | Creating Web Custom Controls With ASP.Net 1.1 ... Our good friends at Microsoft are obviously doing a little extra behind the .... I will provide an example of ControlBuilder support in a later article. ... Cache Control builder The Cache Control builder allows you to cache the output of a specific ... This database scenario presents a good opportunity to cache results (in this case ... CodeProject: ASP.NET Color DropDown Control. Free source code and ... An example of persisting and parsing a custom collection in an ASP. ... You are correct - I had listed the ControlBuilder in the wrong namespace D'Oh! ... UMC800 Control Builder User’s Guide 14.5.1 Example 1 - Basic Start/Stop Circuit with On Delay Timer. ...... The Control Builder operates on any computer platform that ... Nikhil Kothari's Weblog : DomainDataSource Server Control: LINQ + ... Jan 15, 2009 ... My DomainDataSource control has an associated ControlBuilder that .... support for LINQ - might be good to report this to the EF team. ... |
|
Search This Site:
|
|