本文整理汇总了C#中System.Web.UI.ControlBuilder.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder.GetType方法的具体用法?C# ControlBuilder.GetType怎么用?C# ControlBuilder.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.ControlBuilder
的用法示例。
在下文中一共展示了ControlBuilder.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnProcessGeneratedCode
public override void OnProcessGeneratedCode(ControlBuilder controlBuilder, CodeCompileUnit codeCompileUnit, CodeTypeDeclaration baseType, CodeTypeDeclaration derivedType, CodeMemberMethod buildMethod, CodeMemberMethod dataBindingMethod, System.Collections.IDictionary additionalState)
{
// only run this once during page compilation, and only use this one builder (so that we don't get master pages, etc.)
if (controlBuilder.GetType() == typeof(FileLevelPageControlBuilder))
{
// the page will only contain one namespace and one type
var ns = codeCompileUnit.Namespaces.Cast<CodeNamespace>().FirstOrDefault();
if (ns != null)
{
var type = ns.Types.Cast<CodeTypeDeclaration>().FirstOrDefault();
if (type != null)
{
/* When this is output, it will inject this into every page:
*
* protected override PageStatePersister PageStatePersister {
* get { return new CompressedHiddenFieldPageStatePersister(this); }
* }
*
*/
CodeMemberProperty property = new CodeMemberProperty()
{
Name = "PageStatePersister",
HasGet = true,
Attributes = MemberAttributes.Override | MemberAttributes.Family,
Type = new CodeTypeReference(typeof(PageStatePersister))
};
var newObj = new CodeObjectCreateExpression(typeof(CompressedHiddenFieldPageStatePersister), new CodeThisReferenceExpression());
property.GetStatements.Add(new CodeMethodReturnStatement(newObj));
type.Members.Add(property);
}
}
}
base.OnProcessGeneratedCode(controlBuilder, codeCompileUnit, baseType, derivedType, buildMethod, dataBindingMethod, additionalState);
}
开发者ID:GrabYourPitchforks,项目名称:viewstate-compression,代码行数:35,代码来源:ViewStateCompressorControlBuilderInterceptor.cs
示例2: AppendSubBuilder
/// <include file='doc\LiteralTextContainerControlBuilder.uex' path='docs/doc[@for="LiteralTextContainerControlBuilder.AppendSubBuilder"]/*' />
public override void AppendSubBuilder(ControlBuilder subBuilder)
{
if (InDesigner)
{
base.AppendSubBuilder(subBuilder);
}
// The first one is used if ASP.NET is compiled with FAST_DATABINDING off. The second
// is used if it is compiled with FAST_DATABINDING on. Note: We can't do a type
// comparison because CodeBlockBuilder is internal.
//else if (typeof(DataBoundLiteralControl).IsAssignableFrom(subBuilder.ControlType))
else if (subBuilder.GetType().FullName == "System.Web.UI.CodeBlockBuilder")
{
TextParser.AddDataBinding(subBuilder);
}
else
{
base.AppendSubBuilder(subBuilder);
if (subBuilder.ControlType != typeof(LiteralText))
{
if (_textParser != null)
{
_textParser.ResetBreaking();
}
else
{
_controlsInserted = true;
}
}
}
}
示例3: AppendSubBuilder
public override void AppendSubBuilder (ControlBuilder subBuilder)
{
if (subBuilder == null) {
base.AppendSubBuilder (subBuilder);
return;
}
if (typeof (ContentBuilderInternal).IsAssignableFrom (subBuilder.GetType ())) {
if (hasOtherControls)
throw new HttpException ("Only Content controls are supported on content pages.");
hasContentControls = true;
if (hasLiteralControls)
throw new HttpParseException ("Only Content controls are supported on content pages.");
} else
hasOtherControls = true;
base.AppendSubBuilder (subBuilder);
}
示例4: CreateControlTree
protected void CreateControlTree (ControlBuilder builder, bool inTemplate, bool childrenAsProperties)
{
EnsureID (builder);
bool isTemplate = builder.IsTemplate;
if (!isTemplate && !inTemplate) {
CreateField (builder, true);
} else if (!isTemplate) {
bool doCheck = false;
bool singleInstance = false;
ControlBuilder pb = builder.ParentBuilder;
TemplateBuilder tpb;
while (pb != null) {
tpb = pb as TemplateBuilder;
if (tpb == null) {
pb = pb.ParentBuilder;
continue;
}
if (tpb.TemplateInstance == TemplateInstance.Single)
singleInstance = true;
break;
}
if (!singleInstance)
builder.ID = builder.GetNextID (null);
else
doCheck = true;
CreateField (builder, doCheck);
}
InitMethod (builder, isTemplate, childrenAsProperties);
if (!isTemplate || builder.GetType () == typeof (RootBuilder))
CreateAssignStatementsFromAttributes (builder);
if (builder.Children != null && builder.Children.Count > 0) {
StringBuilder sb = new StringBuilder ();
foreach (object b in builder.Children) {
if (b is string) {
sb.Append ((string) b);
continue;
}
FlushText (builder, sb);
if (b is ObjectTagBuilder) {
ProcessObjectTag ((ObjectTagBuilder) b);
} else if (b is StringPropertyBuilder) {
StringPropertyBuilder pb = b as StringPropertyBuilder;
if (pb.Children != null && pb.Children.Count > 0) {
StringBuilder asb = new StringBuilder ();
foreach (string s in pb.Children)
asb.Append (s);
CodeMemberMethod method = builder.Method;
CodeAssignStatement assign = new CodeAssignStatement ();
assign.Left = new CodePropertyReferenceExpression (ctrlVar, pb.PropertyName);
assign.Right = new CodePrimitiveExpression (asb.ToString ());
method.Statements.Add (AddLinePragma (assign, builder));
}
} else if (b is ContentBuilderInternal) {
ContentBuilderInternal cb = (ContentBuilderInternal) b;
CreateControlTree (cb, false, true);
AddContentTemplateInvocation (cb, builder.Method, cb.Method.Name);
continue;
}
// Ignore TemplateBuilders - they are processed in InitMethod
else if (b is TemplateBuilder) {
} else if (b is CodeRenderBuilder) {
AddCodeRender (builder, (CodeRenderBuilder) b);
} else if (b is DataBindingBuilder) {
AddDataBindingLiteral (builder, (DataBindingBuilder) b);
} else if (b is ControlBuilder) {
ControlBuilder child = (ControlBuilder) b;
CreateControlTree (child, inTemplate, builder.ChildrenAsProperties);
AddChildCall (builder, child);
continue;
} else
throw new Exception ("???");
ControlBuilder bldr = b as ControlBuilder;
bldr.ProcessGeneratedCode (CompileUnit, BaseType, DerivedType, bldr.Method, bldr.DataBindingMethod);
}
FlushText (builder, sb);
}
ControlBuilder defaultPropertyBuilder = builder.DefaultPropertyBuilder;
if (defaultPropertyBuilder != null) {
CreateControlTree (defaultPropertyBuilder, false, true);
AddChildCall (builder, defaultPropertyBuilder);
}
if (builder.HasAspCode) {
CodeMemberMethod renderMethod = builder.RenderMethod;
CodeMethodReferenceExpression m = new CodeMethodReferenceExpression ();
m.TargetObject = thisRef;
m.MethodName = renderMethod.Name;
CodeDelegateCreateExpression create = new CodeDelegateCreateExpression ();
//.........这里部分代码省略.........
示例5: AppendCode
void AppendCode (ControlBuilder subBuilder)
{
if (type != null && !(typeof (Control).IsAssignableFrom (type)))
throw new HttpException ("Code render not supported here.");
if (typeof (CodeRenderBuilder) == subBuilder.GetType ())
hasAspCode = true;
AddChild (subBuilder);
}
示例6: AppendToProperty
void AppendToProperty (ControlBuilder subBuilder)
{
if (typeof (CodeRenderBuilder) == subBuilder.GetType ())
throw new HttpException ("Code render not supported here.");
if (defaultPropertyBuilder != null) {
defaultPropertyBuilder.AppendSubBuilder (subBuilder);
return;
}
AddChild (subBuilder);
}
示例7: AppendSubBuilder
public virtual void AppendSubBuilder (ControlBuilder subBuilder)
{
subBuilder.OnAppendToParentBuilder (this);
subBuilder.parentBuilder = this;
if (childrenAsProperties) {
AppendToProperty (subBuilder);
return;
}
if (typeof (CodeRenderBuilder).IsAssignableFrom (subBuilder.GetType ())) {
AppendCode (subBuilder);
return;
}
AddChild (subBuilder);
}
示例8: AppendSubBuilder
/// <include file='doc\Form.uex' path='docs/doc[@for="FormControlBuilder.AppendSubBuilder"]/*' />
public override void AppendSubBuilder(ControlBuilder subBuilder)
{
Type controlType = subBuilder.ControlType;
if(!(
(subBuilder.GetType().FullName == "System.Web.UI.CodeBlockBuilder") ||
(typeof(MobileControl).IsAssignableFrom(controlType)) ||
(typeof(UserControl).IsAssignableFrom(controlType)) ||
(typeof(DeviceSpecific).IsAssignableFrom(controlType))
))
{
throw(new Exception(SR.GetString(SR.Form_InvalidSubControlType, subBuilder.TagName)));
}
base.AppendSubBuilder(subBuilder);
}
示例9: CreateControlTree
void CreateControlTree (ControlBuilder builder, bool inTemplate, bool childrenAsProperties)
{
EnsureID (builder);
bool isTemplate = (typeof (TemplateBuilder).IsAssignableFrom (builder.GetType ()));
if (!isTemplate && !inTemplate) {
CreateField (builder, true);
} else if (!isTemplate) {
builder.ID = builder.GetNextID (null);
CreateField (builder, false);
}
InitMethod (builder, isTemplate, childrenAsProperties);
if (!isTemplate || builder.GetType () == typeof (RootBuilder))
CreateAssignStatementsFromAttributes (builder);
if (builder.Children != null && builder.Children.Count > 0) {
ArrayList templates = null;
StringBuilder sb = new StringBuilder ();
foreach (object b in builder.Children) {
if (b is string) {
sb.Append ((string) b);
continue;
}
FlushText (builder, sb);
if (b is ObjectTagBuilder) {
ProcessObjectTag ((ObjectTagBuilder) b);
continue;
}
#if NET_2_0
if (b is ContentControlBuilder) {
ContentControlBuilder cb = (ContentControlBuilder) b;
CreateControlTree (cb, false, true);
AddContentTemplateInvocation (cb, builder.method, cb.method.Name);
continue;
}
#endif
if (b is TemplateBuilder) {
if (templates == null)
templates = new ArrayList ();
templates.Add (b);
continue;
}
if (b is CodeRenderBuilder) {
AddCodeRender (builder, (CodeRenderBuilder) b);
continue;
}
if (b is DataBindingBuilder) {
AddDataBindingLiteral (builder, (DataBindingBuilder) b);
continue;
}
if (b is ControlBuilder) {
ControlBuilder child = (ControlBuilder) b;
CreateControlTree (child, inTemplate, builder.ChildrenAsProperties);
AddChildCall (builder, child);
continue;
}
throw new Exception ("???");
}
FlushText (builder, sb);
if (templates != null) {
foreach (TemplateBuilder b in templates) {
CreateControlTree (b, true, false);
#if NET_2_0
if (b.BindingDirection == BindingDirection.TwoWay) {
string extractMethod = CreateExtractValuesMethod (b);
AddBindableTemplateInvocation (builder.method, b.TagName, b.method.Name, extractMethod);
}
else
#endif
AddTemplateInvocation (builder.method, b.TagName, b.method.Name);
}
}
}
if (builder.defaultPropertyBuilder != null) {
ControlBuilder b = builder.defaultPropertyBuilder;
CreateControlTree (b, false, true);
AddChildCall (builder, b);
}
if (builder.HasAspCode) {
CodeMethodReferenceExpression m = new CodeMethodReferenceExpression ();
m.TargetObject = thisRef;
m.MethodName = builder.renderMethod.Name;
CodeDelegateCreateExpression create = new CodeDelegateCreateExpression ();
create.DelegateType = new CodeTypeReference (typeof (RenderMethod));
//.........这里部分代码省略.........