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); } } }
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"]; }
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"); }
/// <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; } } } }
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); }
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); }
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"); } }
public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { this._provider = provider; this._control = control; this._skinBuilder = skinBuilder; this._themePath = themePath; }
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); }
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); }
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); } }
/// <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; }
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)); }
public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs) { base.Init(parser, parentBuilder, type, tagName, ID, attribs); if ((base.InPageTheme && (base.ParentBuilder != null)) && base.ParentBuilder.IsControlSkin) { ((PageThemeParser) base.Parser).CurrentSkinBuilder = parentBuilder; } }
/// <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) { }
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); }
public override void AppendSubBuilder(ControlBuilder subBuilder) { if (subBuilder is CodeBlockBuilder) { throw new Exception(System.Web.SR.GetString("Multiview_rendering_block_not_allowed")); } base.AppendSubBuilder(subBuilder); }
public override void ParseComplete(ControlBuilder rootBuilder) { base.ParseComplete(rootBuilder); IMvcControlBuilder builder = rootBuilder as IMvcControlBuilder; if (builder != null) { builder.Inherits = _inherits; } }
public override bool AllowControl(Type controlType, ControlBuilder builder) { return (controlType == typeof(HtmlHead) || controlType == typeof(HtmlTitle) || controlType == typeof(ContentPlaceHolder) || controlType == typeof(Content) || controlType == typeof(HtmlLink)); }
public override void Init (TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs) { throw new NotImplementedException (); }
internal BuilderStackEntry(ControlBuilder builder, string tagName, string virtualPath, int line, string inputText, int textPos) { this._builder = builder; this._tagName = tagName; base.VirtualPath = virtualPath; base.Line = line; this._inputText = inputText; this._textPos = textPos; }
/// <summary> /// This methood is called before a <see cref="System.Web.UI.ControlBuilder"/> for an element in the markup is initialized. /// </summary> /// <param name="controlBuilder">The control builder which is about to be initialized.</param> /// <param name="parser">The <see cref="System.Web.UI.TemplateParser"/> which was used to parse the markup.</param> /// <param name="parentBuilder">The parent control builder (typically the builder corresponding to the parent element in the markup).</param> /// <param name="type">The type of the control that this builder will create.</param> /// <param name="tagName">The name of the tag to be built.</param> /// <param name="id">ID of the element in the markup.</param> /// <param name="attributes">List of attributes of the element in the markup.</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 PreControlBuilderInit(ControlBuilder controlBuilder, TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attributes, IDictionary additionalState) { }
public override void Init (TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs) { // enough? base.Init (parser, parentBuilder, type, tagName, ID, attribs); }
internal CompileLiteralTextParser(TemplateParser parser, ControlBuilder parentBuilder, String fileName, int lineNumber) { _parser = parser; _parentBuilder = parentBuilder; _fileName = fileName; _lineNumber = lineNumber; }
protected override void AddStatementsToInitMethodTop (ControlBuilder builder, CodeMemberMethod method) { base.AddStatementsToInitMethodTop (builder, method); if (parser.MasterPageFile != null) { CodeExpression prop; prop = new CodePropertyReferenceExpression (new CodeArgumentReferenceExpression("__ctrl"), "MasterPageFile"); CodeExpression ct = new CodePrimitiveExpression (parser.MasterPageFile); method.Statements.Add (AddLinePragma (new CodeAssignStatement (prop, ct), parser.DirectiveLocation)); } }
public override void ParseComplete(ControlBuilder rootBuilder) { base.ParseComplete(rootBuilder); SimplifyPageControlBuilder pageBuilder = rootBuilder as SimplifyPageControlBuilder; if (pageBuilder != null) { pageBuilder.PageBaseType = _viewBaseType; } }
public override void Init (TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs) { base.Init (parser, parentBuilder, type, tagName, ID, attribs); placeHolderID = attribs ["ContentPlaceHolderID"] as string; }
internal virtual void BuildExpression(BoundPropertyEntry bpe, ControlBuilder controlBuilder, CodeExpression controlReference, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, ref bool hasTempObject) { CodeExpression codeExpression = GetCodeExpression(bpe, bpe.ParsedExpressionData, new ExpressionBuilderContext(controlBuilder.VirtualPath)); CodeDomUtility.CreatePropertySetStatements(methodStatements, statements, controlReference, bpe.Name, bpe.Type, codeExpression, linePragma); }
internal override void SetParentBuilder(ControlBuilder parentBuilder) { if (!base.Parser.FInDesigner && !(base.Parser is PageThemeParser)) { if ((parentBuilder.ControlType == null) || !typeof(WizardStepCollection).IsAssignableFrom(parentBuilder.ControlType)) { throw new HttpException(System.Web.SR.GetString("WizardStep_WrongContainment")); } base.SetParentBuilder(parentBuilder); } }
/// <summary> /// 解析完成 /// </summary> /// <param name="rootBuilder"></param> public override void ParseComplete(ControlBuilder rootBuilder) { base.ParseComplete(rootBuilder); // If it's our page ControlBuilder, give it the base type string ViewPageControlBuilder pageBuilder = rootBuilder as ViewPageControlBuilder; if (pageBuilder != null) { pageBuilder.PageBaseType = _viewBaseType; } }
// Informs the filter that the parsing of the page is complete public virtual void ParseComplete(ControlBuilder rootBuilder) { Debug.Assert(_virtualPath != null); }
/// <devdoc> /// Throws an exception - string properties cannot contain other objects. /// </devdoc> public override void AppendSubBuilder(ControlBuilder subBuilder) { throw new HttpException(SR.GetString(SR.StringPropertyBuilder_CannotHaveChildObjects, TagName, (ParentBuilder != null ? ParentBuilder.TagName : String.Empty))); }
public override void OnAppendToParentBuilder(ControlBuilder parentBuilder) { }
public override void AppendSubBuilder(ControlBuilder subBuilder) { throw new HttpException("StringPropertyBuilder should never be called"); }
public override void AppendSubBuilder(ControlBuilder subBuilder) { // Do nothing }
public virtual new void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, System.Collections.IDictionary attribs) { Contract.Requires(parser != null); }
public virtual new void OnAppendToParentBuilder(ControlBuilder parentBuilder) { }
/* * Add a complex property to the setter. */ internal void AddComplexProperty(string name, ControlBuilder builder) { AddPropertyInternal(name, null /*value*/, builder, false /*fItemProp*/); }
/* * Add a complex <item> property to the setter. */ internal void AddCollectionItem(ControlBuilder builder) { AddPropertyInternal(null /*name*/, null /*value*/, builder, true /*fItemProp*/); }
internal bool AllowControlInternal(Type controlType, ControlBuilder builder) { this.OnControlAdded(); return(this.AllowControl(controlType, builder)); }
private void AddPropertyInternal(string name, string value, ControlBuilder builder, bool fItemProp) { PropertySetterEntry entry = new PropertySetterEntry(); bool fTemplate = false; string nameForCodeGen = null; entry._value = value; entry._builder = builder; entry._fItemProp = fItemProp; MemberInfo memberInfo = null; PropertyInfo propInfo = null; FieldInfo fieldInfo = null; // Is the property a template? if (builder != null && builder is TemplateBuilder) { fTemplate = true; } if (_objType != null && name != null) // attempt to locate a public property or field // of given name on this type of object { memberInfo = PropertyMapper.GetMemberInfo(_objType, name, out nameForCodeGen); } if (memberInfo != null) // memberInfo may be a PropertyInfo or FieldInfo { if (memberInfo is PropertyInfo) // public property { propInfo = (PropertyInfo)memberInfo; entry._propType = propInfo.PropertyType; if (propInfo.GetSetMethod() == null) // property is readonly { if (builder == null && !_fSupportsAttributes) // only complex property is allowed to be readonly { throw new HttpException( HttpRuntime.FormatResourceString(SR.Property_readonly, name)); } if (builder != null) // complex property is allowed to be readonly // set a flag to note that property is readonly { entry._fReadOnlyProp = true; } else if (_fSupportsAttributes) // allow attribute to be set via SetAttribute { entry._propType = null; entry._name = name; } } } else // public field { fieldInfo = (FieldInfo)memberInfo; entry._propType = fieldInfo.FieldType; } if (entry._propType != null) { entry._propInfo = propInfo; entry._fieldInfo = fieldInfo; entry._name = nameForCodeGen; // If it's a databound prop, we don't want to mess with the value, // since it's a piece of code. if (!_fDataBound) { // check that the property is persistable, i.e., it makes sense to have it in // the aspx template if (_checkPersistable && nameForCodeGen != null) { PropertyDescriptor propDesc = _descriptors[nameForCodeGen]; if (propDesc != null) { if (propDesc.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden)) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Property_Not_Persistable, name)); } } } else { if (_isHtmlControl) { PropertyDescriptor propDesc = _descriptors[nameForCodeGen]; if (propDesc != null) { if (propDesc.Attributes.Contains(HtmlControlPersistableAttribute.No)) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Property_Not_Persistable, name)); } } } } entry._propValue = PropertyConverter.ObjectFromString(entry._propType, memberInfo, entry._value); // use actual property value to get the proper case-sensitive name for enum types if (entry._propType.IsEnum) { if (entry._propValue == null) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Invalid_enum_value, entry._value, name, entry._propType.FullName)); } entry._value = Enum.Format(entry._propType, entry._propValue, "G"); } else if (entry._propType == typeof(Boolean)) { // get the proper case-sensitive value for boolean if (entry._value != null && entry._value.Length > 0) { entry._value = entry._value.ToLower(CultureInfo.InvariantCulture); } else { entry._propValue = true; } } if (fTemplate) { // Check if the property has a TemplateContainerAttribute, and if // it does, get the type out of it. TemplateContainerAttribute templateAttrib = (TemplateContainerAttribute)Attribute.GetCustomAttribute(propInfo, typeof(TemplateContainerAttribute), false); if (templateAttrib != null) { if (!typeof(INamingContainer).IsAssignableFrom(templateAttrib.ContainerType)) { throw new HttpException(HttpRuntime.FormatResourceString( SR.Invalid_template_container, name, templateAttrib.ContainerType.FullName)); } builder._ctrlType = templateAttrib.ContainerType; } } } } } else if (fItemProp) { } else // could not locate a public property or field // determine if there is an event of this name. // do not look for events when running in designer { if (!_fInDesigner && _objType != null && name.Length >= 2 && string.Compare(name.Substring(0, 2), "on", true, CultureInfo.InvariantCulture) == 0) { string eventName = name.Substring(2); if (_eventDescs == null) { _eventDescs = TypeDescriptor.GetEvents(_objType); } EventDescriptor eventFound = _eventDescs.Find(eventName, true); if (eventFound != null) // an Add method has been located { PropertySetterEventEntry eventEntry = new PropertySetterEventEntry(); eventEntry._eventName = eventFound.Name; eventEntry._handlerType = eventFound.EventType; if (value == null || value.Length == 0) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Event_handler_cant_be_empty, name)); } eventEntry._handlerMethodName = value; if (_events == null) { _events = new ArrayList(3); } // add to the list of events _events.Add(eventEntry); return; } } // If attributes are not supported, or the property is a template or a // complex property (which cannot be set through SetAttribute), fail. if (!_fInDesigner && (!_fSupportsAttributes || builder != null)) { if (_objType != null) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Type_doesnt_have_property, _objType.FullName, name)); } if (String.Compare(name, "name", true, CultureInfo.InvariantCulture) != 0) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Templates_cannot_have_properties)); } else { return; } } // use the original property name for generic SetAttribute entry._name = name; } if (_entries == null) { _entries = new ArrayList(3); } // add entry to the list _entries.Add(entry); }
public ObjectPersistData(ControlBuilder builder, System.Collections.IDictionary builtObjects) { }
public SkinBuilder(ThemeProvider provider, Control control, ControlBuilder skinBuilder, string themePath) { }
public static ControlBuilder CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, System.Collections.IDictionary attribs, int line, string sourceFileName) { Contract.Ensures(Contract.Result <System.Web.UI.ControlBuilder>() != null); return(default(ControlBuilder)); }
ControlBuilder CreatePropertyBuilder(string propName, TemplateParser parser, IDictionary atts) { int idx; string propertyName; if ((idx = propName.IndexOf(':')) >= 0) { propertyName = propName.Substring(idx + 1); } else { propertyName = propName; } PropertyInfo prop = type.GetProperty(propertyName, FlagsNoCase); if (prop == null) { string msg = String.Format("Property {0} not found in type {1}", propertyName, type); throw new HttpException(msg); } Type propType = prop.PropertyType; ControlBuilder builder = null; if (typeof(ICollection).IsAssignableFrom(propType)) { builder = new CollectionBuilder(); } else if (typeof(ITemplate).IsAssignableFrom(propType)) { builder = new TemplateBuilder(prop); } else if (typeof(string) == propType) { builder = new StringPropertyBuilder(prop.Name); } else { builder = CreateBuilderFromType(parser, parentBuilder, propType, prop.Name, null, atts, line, fileName); builder.isProperty = true; builder.isPropertyWritable = prop.CanWrite; if (idx >= 0) { builder.originalTagName = propName; } return(builder); } builder.Init(parser, this, null, prop.Name, null, atts); builder.fileName = fileName; builder.line = line; builder.isProperty = true; builder.isPropertyWritable = prop.CanWrite; if (idx >= 0) { builder.originalTagName = propName; } return(builder); }
public virtual new void AppendSubBuilder(ControlBuilder subBuilder) { Contract.Requires(subBuilder != null); }
internal virtual ControlBuilder CreateSubBuilder(string tagid, IDictionary atts, Type childType, TemplateParser parser, ILocation location) { ControlBuilder childBuilder = null; if (childrenAsProperties) { if (defaultPropertyBuilder == null) { childBuilder = CreatePropertyBuilder(tagid, parser, atts); } else { if (String.Compare(defaultPropertyBuilder.TagName, tagid, true, Helpers.InvariantCulture) == 0) { // The child tag is the same what our default property name. Act as if there was // no default property builder, or otherwise we'll end up with invalid nested // builder call. defaultPropertyBuilder = null; childBuilder = CreatePropertyBuilder(tagid, parser, atts); } else { Type ct = ControlType; MemberInfo[] mems = ct != null?ct.GetMember(tagid, MemberTypes.Property, FlagsNoCase) : null; PropertyInfo prop = mems != null && mems.Length > 0 ? mems [0] as PropertyInfo : null; if (prop != null && typeof(ITemplate).IsAssignableFrom(prop.PropertyType)) { childBuilder = CreatePropertyBuilder(tagid, parser, atts); defaultPropertyBuilder = null; } else { childBuilder = defaultPropertyBuilder.CreateSubBuilder(tagid, atts, null, parser, location); } } } return(childBuilder); } if (String.Compare(tagName, tagid, true, Helpers.InvariantCulture) == 0) { return(null); } childType = GetChildControlType(tagid, atts); if (childType == null) { return(null); } childBuilder = CreateBuilderFromType(parser, this, childType, tagid, id, atts, location.BeginLine, location.Filename); return(childBuilder); }
public override void AppendSubBuilder(ControlBuilder subBuilder) { throw new NotImplementedException(); }
public static ControlBuilder CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, System.Collections.IDictionary attribs, int line, string sourceFileName) { return(default(ControlBuilder)); }
public virtual bool AllowControl(Type controlType, ControlBuilder builder) { return(false); }
public virtual void ParseComplete(ControlBuilder rootBuilder) { }
// Ignore all content /// <include file='doc\ObjectTag.uex' path='docs/doc[@for="ObjectTagBuilder.AppendSubBuilder"]/*' /> /// <internalonly/> /// <devdoc> /// </devdoc> public override void AppendSubBuilder(ControlBuilder subBuilder) { }
public ObjectPersistData(ControlBuilder builder, IDictionary builtObjects) { throw new NotImplementedException(); }
private bool _fLateBinding; // Force latebinding when early binding could be done /// <include file='doc\ObjectTag.uex' path='docs/doc[@for="ObjectTagBuilder.Init"]/*' /> /// <internalonly/> /// <devdoc> /// </devdoc> public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs) { if (id == null) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Object_tag_must_have_id)); } _id = id; // Get the scope attribute of the object tag string scope = (string)attribs["scope"]; // Map it to an ObjectTagScope enum if (scope == null) { _scope = ObjectTagScope.Default; } else if (string.Compare(scope, "page", true, CultureInfo.InvariantCulture) == 0) { _scope = ObjectTagScope.Page; } else if (string.Compare(scope, "session", true, CultureInfo.InvariantCulture) == 0) { _scope = ObjectTagScope.Session; } else if (string.Compare(scope, "application", true, CultureInfo.InvariantCulture) == 0) { _scope = ObjectTagScope.Application; } else if (string.Compare(scope, "appinstance", true, CultureInfo.InvariantCulture) == 0) { _scope = ObjectTagScope.AppInstance; } else { throw new HttpException(HttpRuntime.FormatResourceString(SR.Invalid_scope, scope)); } Util.GetAndRemoveBooleanAttribute(attribs, "latebinding", ref _fLateBinding); string tmp = (string)attribs["class"]; // Is there a 'class' attribute? if (tmp != null) { // Get a Type object from the type string _type = parser.GetType(tmp); } // If we don't have a type, check for a classid attribute if (_type == null) { tmp = (string)attribs["classid"]; if (tmp != null) { // Create a Guid out of it Guid clsid = new Guid(tmp); // Turn it into a type _type = Type.GetTypeFromCLSID(clsid); if (_type == null) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Invalid_clsid, tmp)); } // REVIEW: Currently, it is still required to use tlbimp and // comreg in order to use a COM DLL. If this has not // been done, we get an object of type System.__ComObject. // Per ASURT 8737, we will generate a field of type object for this, // and create it at runtime using the progid. if (_fLateBinding || Util.IsLateBoundComClassicType(_type)) { _lateBound = true; _clsid = tmp; } else { // Add a dependency to the type, so that the user can use it without // having to import it parser.AddTypeDependency(_type); } } } // If we don't have a type, check for a progid attribute if (_type == null) { tmp = (string)attribs["progid"]; if (tmp != null) { // Turn it into a type _type = Type.GetTypeFromProgID(tmp); if (_type == null) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Invalid_progid, tmp)); } Debug.Trace("Template", "<object> type: " + _type.FullName); // REVIEW: Currently, it is still required to use tlbimp and // comreg in order to use a COM DLL. If this has not // been done, we get an object of type System.__ComObject. // Per ASURT 8737, we will generate a field of type object for this, // and create it at runtime using the progid. if (_fLateBinding || Util.IsLateBoundComClassicType(_type)) { _lateBound = true; _progid = tmp; } else { // Add a dependency to the type, so that the user can use it without // having to import it parser.AddTypeDependency(_type); } } } // If we still don't have a type, fail if (_type == null) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Object_tag_must_have_class_classid_or_progid)); } }
public virtual new void AppendSubBuilder(ControlBuilder subBuilder) { }