本文整理汇总了C#中System.Web.UI.ControlBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder类的具体用法?C# ControlBuilder怎么用?C# ControlBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ControlBuilder类属于System.Web.UI命名空间,在下文中一共展示了ControlBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SkinBuilder
public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath)
{
this._provider = provider;
this._control = control;
this._skinBuilder = skinBuilder;
this._themePath = themePath;
}
示例2: BuildEvalExpression
internal static void BuildEvalExpression(string field, string formatString, string propertyName,
Type propertyType, ControlBuilder controlBuilder, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, bool isEncoded, ref bool hasTempObject) {
// Altogether, this function will create a statement that looks like this:
// if (this.Page.GetDataItem() != null) {
// target.{{propName}} = ({{propType}}) this.Eval(fieldName, formatString);
// }
// this.Eval(fieldName, formatString)
CodeMethodInvokeExpression evalExpr = new CodeMethodInvokeExpression();
evalExpr.Method.TargetObject = new CodeThisReferenceExpression();
evalExpr.Method.MethodName = EvalMethodName;
evalExpr.Parameters.Add(new CodePrimitiveExpression(field));
if (!String.IsNullOrEmpty(formatString)) {
evalExpr.Parameters.Add(new CodePrimitiveExpression(formatString));
}
CodeStatementCollection evalStatements = new CodeStatementCollection();
BuildPropertySetExpression(evalExpr, propertyName, propertyType, controlBuilder, methodStatements, evalStatements, linePragma, isEncoded, ref hasTempObject);
// if (this.Page.GetDataItem() != null)
CodeMethodInvokeExpression getDataItemExpr = new CodeMethodInvokeExpression();
getDataItemExpr.Method.TargetObject = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Page");
getDataItemExpr.Method.MethodName = GetDataItemMethodName;
CodeConditionStatement ifStmt = new CodeConditionStatement();
ifStmt.Condition = new CodeBinaryOperatorExpression(getDataItemExpr,
CodeBinaryOperatorType.IdentityInequality,
new CodePrimitiveExpression(null));
ifStmt.TrueStatements.AddRange(evalStatements);
statements.Add(ifStmt);
}
示例3: Init
public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs)
{
this._contentPlaceHolderID = ID;
if (parser.FInDesigner)
{
base.Init(parser, parentBuilder, type, tagName, ID, attribs);
}
else
{
if (string.IsNullOrEmpty(ID))
{
throw new HttpException(System.Web.SR.GetString("Control_Missing_Attribute", new object[] { "ID", type.Name }));
}
this._templateName = ID;
MasterPageParser parser2 = parser as MasterPageParser;
if (parser2 == null)
{
throw new HttpException(System.Web.SR.GetString("ContentPlaceHolder_only_in_master"));
}
base.Init(parser, parentBuilder, type, tagName, ID, attribs);
if (parser2.PlaceHolderList.Contains(this.Name))
{
throw new HttpException(System.Web.SR.GetString("ContentPlaceHolder_duplicate_contentPlaceHolderID", new object[] { this.Name }));
}
parser2.PlaceHolderList.Add(this.Name);
}
}
示例4: AppendSubBuilder
public override void AppendSubBuilder (ControlBuilder subBuilder)
{
// LAMESPEC: docs suggest that only View controls are accepted, but tests
// show that anything goes here (including subBuilder.ControlType == null),
// so we're just passing the call up the chain
base.AppendSubBuilder (subBuilder);
}
示例5: Init
public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id,
IDictionary attribs)
{
base.Init(parser, parentBuilder, type, tagName, id, attribs);
_typeName = (string)attribs["typename"];
}
示例6: 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
示例7: 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;
}
}
}
}
示例8: Init
public override void Init(TemplateParser parser, ControlBuilder parentBuilder,
Type type, string tagName, string ID, IDictionary attribs) {
// Copy the ID so that it will be available when BuildObject is called
_contentPlaceHolderID = ID;
if (parser.FInDesigner) {
// shortcut for designer
base.Init(parser, parentBuilder, type, tagName, ID, attribs);
return;
}
if (String.IsNullOrEmpty(ID)) {
throw new HttpException(SR.GetString(SR.Control_Missing_Attribute, "ID", type.Name));
}
_templateName = ID;
MasterPageParser masterPageParser = parser as MasterPageParser;
if (masterPageParser == null) {
throw new HttpException(SR.GetString(SR.ContentPlaceHolder_only_in_master));
}
base.Init(parser, parentBuilder, type, tagName, ID, attribs);
if (masterPageParser.PlaceHolderList.Contains(Name))
throw new HttpException(SR.GetString(SR.ContentPlaceHolder_duplicate_contentPlaceHolderID, Name));
masterPageParser.PlaceHolderList.Add(Name);
}
示例9: Init
public override void Init(TemplateParser parser, ControlBuilder parentBuilder,
Type type, string tagName, string ID, IDictionary attribs) {
base.Init(parser, parentBuilder, type /*type*/, tagName, ID, attribs);
SetControlType(typeof(string));
}
示例10: Init
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override void Init(TemplateParser parser, ControlBuilder parentBuilder,
Type type, string tagName, string ID, IDictionary attribs) {
base.Init(parser, parentBuilder, type /*type*/, tagName, ID, attribs);
//
PropertyInfo propInfo = TargetFrameworkUtil.GetProperty(parentBuilder.ControlType,
tagName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase);
SetControlType(propInfo.PropertyType);
Debug.Assert(ControlType != null, "ControlType != null");
BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;
// Look for an "item" property on the collection that takes in an integer index
// (similar to IList::Item)
propInfo = TargetFrameworkUtil.GetProperty(ControlType, "Item", bindingFlags, types: new Type[] { typeof(int) });
if (propInfo == null) {
// fall-back on finding a non-specific Item property
// a type with overloaded indexed properties will result in an exception however
propInfo = TargetFrameworkUtil.GetProperty(ControlType, "Item", bindingFlags);
}
// If we got one, use it to determine the type of the items
if (propInfo != null)
_itemType = propInfo.PropertyType;
}
示例11: ProcessObjects
void ProcessObjects (ControlBuilder builder)
{
if (builder.Children == null)
return;
foreach (object t in builder.Children) {
if (!(t is ObjectTagBuilder))
continue;
ObjectTagBuilder tag = (ObjectTagBuilder) t;
if (tag.Scope == null) {
string fname = CreateFieldForObject (tag.Type, tag.ObjectID);
CreatePropertyForObject (tag.Type, tag.ObjectID, fname, true);
continue;
}
if (tag.Scope == "session") {
sessionObjectTags.Add (tag);
CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
false, false);
} else if (tag.Scope == "application") {
applicationObjectTags.Add (tag);
CreateFieldForObject (tag.Type, tag.ObjectID);
CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
true, false);
} else {
throw new ParseException (tag.location, "Invalid scope: " + tag.Scope);
}
}
}
示例12: Init
public override void Init (TemplateParser parser,
ControlBuilder parentBuilder,
Type type,
string tagName,
string id,
IDictionary attribs)
{
if (attribs == null)
throw new ParseException (parser.Location, "Error in ObjectTag.");
attribs.Remove ("runat");
this.id = attribs ["id"] as string;
attribs.Remove ("id");
if (this.id == null || this.id.Trim () == "")
throw new ParseException (parser.Location, "Object tag must have a valid ID.");
scope = attribs ["scope"] as string;
string className = attribs ["class"] as string;
attribs.Remove ("scope");
attribs.Remove ("class");
if (className == null || className.Trim () == "")
throw new ParseException (parser.Location, "Object tag must have 'class' attribute.");
this.type = parser.LoadType (className);
if (this.type == null)
throw new ParseException (parser.Location, "Type " + className + " not found.");
if (attribs ["progid"] != null || attribs ["classid"] != null)
throw new ParseException (parser.Location, "ClassID and ProgID are not supported.");
if (attribs.Count > 0)
throw new ParseException (parser.Location, "Unknown attribute");
}
示例13: BuildExpressionSetup
internal static void BuildExpressionSetup(ControlBuilder controlBuilder, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, bool isTwoWayBound, bool designerMode) {
// {{controlType}} target;
CodeVariableDeclarationStatement targetDecl = new CodeVariableDeclarationStatement(controlBuilder.ControlType, "dataBindingExpressionBuilderTarget");
methodStatements.Add(targetDecl);
CodeVariableReferenceExpression targetExp = new CodeVariableReferenceExpression(targetDecl.Name);
// target = ({{controlType}}) sender;
CodeAssignStatement setTarget = new CodeAssignStatement(targetExp,
new CodeCastExpression(controlBuilder.ControlType,
new CodeArgumentReferenceExpression("sender")));
setTarget.LinePragma = linePragma;
statements.Add(setTarget);
Type bindingContainerType = controlBuilder.BindingContainerType;
CodeVariableDeclarationStatement containerDecl = new CodeVariableDeclarationStatement(bindingContainerType, "Container");
methodStatements.Add(containerDecl);
// {{containerType}} Container = ({{containerType}}) target.BindingContainer;
CodeAssignStatement setContainer = new CodeAssignStatement(new CodeVariableReferenceExpression(containerDecl.Name),
new CodeCastExpression(bindingContainerType,
new CodePropertyReferenceExpression(targetExp,
"BindingContainer")));
setContainer.LinePragma = linePragma;
statements.Add(setContainer);
string variableName = isTwoWayBound ? "BindItem" : "Item";
GenerateItemTypeExpressions(controlBuilder, methodStatements, statements, linePragma, variableName);
//Generate code for other variable as well at design time in addition to runtime variable for intellisense to work.
if (designerMode) {
GenerateItemTypeExpressions(controlBuilder, methodStatements, statements, linePragma, isTwoWayBound ? "Item" : "BindItem");
}
}
示例14: SetParentBuilder
internal override void SetParentBuilder(ControlBuilder parentBuilder)
{
if (!base.InDesigner && !(parentBuilder is FileLevelPageControlBuilder))
{
throw new HttpException(System.Web.SR.GetString("Content_allowed_in_top_level_only"));
}
base.SetParentBuilder(parentBuilder);
}
示例15: OnProcessGeneratedCode
/// <summary>
/// This method is called after the code generation for this <see cref="System.Web.UI.ControlBuilder"/> is complete.
/// </summary>
/// <param name="controlBuilder">The control builder instance.</param>
/// <param name="codeCompileUnit">This is the entire <see cref="System.CodeDom.CodeCompileUnit"/> that is being generated by the compilation.</param>
/// <param name="baseType">The type declaration of code behind class. When code behind is not used, this is the same as <paramref name="derivedType"/>.</param>
/// <param name="derivedType">The type declaration of top level markup element.</param>
/// <param name="buildMethod">The method with necessary code to create the control and set it's various properties, events, fields.</param>
/// <param name="dataBindingMethod">The method with code to evaluate data binding expressions within the control.</param>
/// <param name="additionalState">This is an additional state which can be used to store/retrive data within several methods of <see cref="System.Web.Compilation.ControlBuilderInterceptor"/>.
/// The state is per control builder.</param>
public virtual void OnProcessGeneratedCode(ControlBuilder controlBuilder,
CodeCompileUnit codeCompileUnit,
CodeTypeDeclaration baseType,
CodeTypeDeclaration derivedType,
CodeMemberMethod buildMethod,
CodeMemberMethod dataBindingMethod,
IDictionary additionalState) {
}