本文整理汇总了C#中System.Web.UI.ControlBuilder.GetNextID方法的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder.GetNextID方法的具体用法?C# ControlBuilder.GetNextID怎么用?C# ControlBuilder.GetNextID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.ControlBuilder
的用法示例。
在下文中一共展示了ControlBuilder.GetNextID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureID
protected void EnsureID (ControlBuilder builder)
{
string id = builder.ID;
if (id == null || id.Trim () == String.Empty)
builder.ID = builder.GetNextID (null);
}
示例2: 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 ();
//.........这里部分代码省略.........
示例3: EnsureID
protected void EnsureID (ControlBuilder builder)
{
if (builder.ID == null || builder.ID.Trim () == "")
builder.ID = builder.GetNextID (null);
}
示例4: CreateDBAttributeMethod
void CreateDBAttributeMethod (ControlBuilder builder, string attr, CodeExpression code)
{
if (code == null)
return;
string id = builder.GetNextID (null);
string dbMethodName = "__DataBind_" + id;
CodeMemberMethod method = builder.Method;
AddEventAssign (method, builder, "DataBinding", typeof (EventHandler), dbMethodName);
method = CreateDBMethod (builder, dbMethodName, GetContainerType (builder), builder.ControlType);
builder.DataBindingMethod = method;
CodeCastExpression cast;
CodeMethodReferenceExpression methodExpr;
CodeMethodInvokeExpression expr;
CodeVariableReferenceExpression targetExpr = new CodeVariableReferenceExpression ("target");
cast = new CodeCastExpression (typeof (IAttributeAccessor), targetExpr);
methodExpr = new CodeMethodReferenceExpression (cast, "SetAttribute");
expr = new CodeMethodInvokeExpression (methodExpr);
expr.Parameters.Add (new CodePrimitiveExpression (attr));
CodeMethodInvokeExpression tostring = new CodeMethodInvokeExpression ();
tostring.Method = new CodeMethodReferenceExpression (
new CodeTypeReferenceExpression (typeof (Convert)),
"ToString");
tostring.Parameters.Add (code);
expr.Parameters.Add (tostring);
method.Statements.Add (expr);
mainClass.Members.Add (method);
}
示例5: 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));
//.........这里部分代码省略.........