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);
        }
Exemplo n.º 2
0
		public RootBuilder (TemplateParser parser)
		{
			foundry = new AspComponentFoundry ();
			line = 1;
			fileName = parser.InputFile;
			Init (parser, null, null, null, null, null);
		}
        /// <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));
        }
Exemplo n.º 5
0
        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)
 {
     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);
     }
 }
    // Create a PageParserFilter and initialize it
    internal static PageParserFilter Create(PagesSection pagesConfig, VirtualPath virtualPath, TemplateParser parser) {
        PageParserFilter pageParserFilter = pagesConfig.CreateControlTypeFilter();
        if (pageParserFilter != null)
            pageParserFilter.InitializeInternal(virtualPath, parser);

        return pageParserFilter;
    }
		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");
		}
 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;
     }
 }
Exemplo n.º 10
0
		protected override void OverrideAssemblyPrefix (TemplateParser parser, AssemblyBuilder assemblyBuilder)
		{
			if (parser == null || assemblyBuilder == null)
				return;

			string newPrefix = assemblyBuilder.OutputFilesPrefix + parser.ClassName + ".";
			assemblyBuilder.OutputFilesPrefix = newPrefix;
		}
 /// <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) { 
 }
Exemplo n.º 12
0
		public override void Init (TemplateParser parser,
					  ControlBuilder parentBuilder,
					  Type type,
					  string tagName,
					  string ID,
					  IDictionary attribs)
		{
			throw new NotImplementedException ();
		}
 internal BuildResultNoCompileUserControl(Type baseType, TemplateParser parser) : base(baseType, parser)
 {
     UserControlParser parser2 = (UserControlParser) parser;
     OutputCacheParameters outputCacheParameters = parser2.OutputCacheParameters;
     if ((outputCacheParameters != null) && (outputCacheParameters.Duration > 0))
     {
         this._cachingAttribute = new PartialCachingAttribute(outputCacheParameters.Duration, outputCacheParameters.VaryByParam, outputCacheParameters.VaryByControl, outputCacheParameters.VaryByCustom, outputCacheParameters.SqlDependency, parser2.FSharedPartialCaching);
         this._cachingAttribute.ProviderName = parser2.Provider;
     }
 }
		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);
		}
		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 CompileLiteralTextParser(TemplateParser parser, 
                                 ControlBuilder parentBuilder, 
                                 String fileName, 
                                 int lineNumber)
 {
     _parser = parser;
     _parentBuilder = parentBuilder;
     _fileName = fileName;
     _lineNumber = lineNumber;
 }
        public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, System.Collections.IDictionary attribs)
        {
            string dataItemTypeName = attribs["DataItemType"] as string;
            Type dataItemType = typeof(object);
            if (!string.IsNullOrEmpty(dataItemTypeName))
            {
                dataItemType = BuildManager.GetType(dataItemTypeName, true);
            }
            Type repeaterFakeType = new RepeaterFakeType(dataItemType);

            base.Init(parser, parentBuilder, repeaterFakeType, tagName, id, attribs);
        }
 public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs)
 {
     // Nasty hack to get internal property value.
     TypedGridViewControlBuilder typedGridViewControlBuilder = parentBuilder.GetValue("ParentBuilder") as TypedGridViewControlBuilder;
     Type fakeType = type;
     if (typedGridViewControlBuilder != null)
     {
         Type dataItemType = typedGridViewControlBuilder.DataItemType;
         if (dataItemType != null)
             fakeType = new TypedTemplateFieldFakeType(dataItemType);
     }
     base.Init(parser, parentBuilder, fakeType, tagName, id, attribs);
 }
 public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs)
 {
     base.Init(parser, parentBuilder, type, tagName, ID, attribs);
     PropertyInfo info = TargetFrameworkUtil.GetProperty(parentBuilder.ControlType, tagName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase);
     base.SetControlType(info.PropertyType);
     BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Instance;
     info = TargetFrameworkUtil.GetProperty(base.ControlType, "Item", bindingAttr, null, null, new Type[] { typeof(int) }, null);
     if (info == null)
     {
         info = TargetFrameworkUtil.GetProperty(base.ControlType, "Item", bindingAttr);
     }
     if (info != null)
     {
         this._itemType = info.PropertyType;
     }
 }
		public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs)
		{
			IDictionary attributes = new Hashtable(attribs.Count);

			foreach(DictionaryEntry entry in attribs)
			{
				var attributeName = (string)entry.Key;

				if(string.Equals(attributeName, "ID", StringComparison.OrdinalIgnoreCase))
				{
					if(string.IsNullOrEmpty(id))
						id = (string)entry.Value;

					if(Environment.OSVersion.Platform == PlatformID.Unix ||
					   Environment.OSVersion.Platform == PlatformID.MacOSX)
					{
						attributes["$ID"] = id;
						continue;
					}
				}

				var property = type.GetProperty(attributeName, (BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase));

				if(property != null && property.IsDefined(typeof(BindableAttribute), true))
				{
					var attribute = Attribute.GetCustomAttribute(property, typeof(PropertyMetadataAttribute), true);

					if(attribute != null)
					{
						if(((PropertyMetadataAttribute)attribute).Bindable)
							attributeName = "$" + attributeName;
					}
					else
					{
						attribute = Attribute.GetCustomAttribute(property, typeof(BindableAttribute), true);

						if(attribute != null && ((BindableAttribute)attribute).Bindable)
							attributeName = "$" + attributeName;
					}
				}

				attributes[attributeName] = entry.Value;
			}

			base.Init(parser, parentBuilder, type, tagName, id, attributes);
		}
    internal void InitializeInternal(VirtualPath virtualPath, TemplateParser parser) {

        _parser = parser;
        Debug.Assert(_virtualPath == null);
        _virtualPath = virtualPath;

        Initialize();

        // Get the various limits we need to enforce
        _numberOfControlsAllowed = NumberOfControlsAllowed;

        // Add 1 to these two, because internally we count the file itself as a
        // dependency, but we don't want this to be reflected to the PageParserFilter
        // implementor (VSWhidbey 341708)
        _dependenciesAllowed = TotalNumberOfDependenciesAllowed+1;
        _directDependenciesAllowed = NumberOfDirectDependenciesAllowed+1;
        CalledFromParseControl = parser.flags[TemplateParser.calledFromParseControlFlag];
    }
		public override void Init (TemplateParser parser,
					   ControlBuilder parentBuilder,
					   Type type,
					   string tagName,
					   string id,
					   IDictionary attribs)
		{
			base.Init (parser, parentBuilder, type, tagName, id, attribs);

			PropertyInfo prop = parentBuilder.ControlType.GetProperty (tagName, flagsNoCase);
			SetControlType (prop.PropertyType);

			MemberInfo[] mems = ControlType.GetMember ("Item", MemberTypes.Property, flagsNoCase & ~BindingFlags.IgnoreCase);
			if (mems.Length > 0) prop = (PropertyInfo) mems [0];
			else throw new HttpException ("Collection of type '" + ControlType + "' does not have an indexer.");
			
			elementType = prop.PropertyType;
		}
Exemplo n.º 23
0
        public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs)
        {
            string dataItemTypeName = attribs["DataItemTypeName"] as string;

            Type dataItemType;
            if (this.InDesigner)
            {
                ITypeResolutionService typeResolutionService = (ITypeResolutionService) this.ServiceProvider.GetService(typeof(ITypeResolutionService));
                dataItemType = typeResolutionService.GetType(dataItemTypeName);
            }
            else
            {
                dataItemType = BuildManager.GetType(dataItemTypeName, true);
            }

            Type listViewFakeType = new TypedListViewFakeType(dataItemType);

            base.Init(parser, parentBuilder, listViewFakeType, tagName, id, attribs);
        }
Exemplo n.º 24
0
		internal ControlBuilder (TemplateParser parser,
					 ControlBuilder parentBuilder,
					 Type type,
					 string tagName,
					 string id,
					 IDictionary attribs,
					 int line,
					 string sourceFileName)

		{
			this.parser = parser;
			this.parentBuilder = parentBuilder;
			this.type = type;
			this.tagName = tagName;
			this.id = id;
			this.attribs = attribs;
			this.line = line;
			this.fileName = sourceFileName;
		}
        public override void PreControlBuilderInit(ControlBuilder controlBuilder, TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attributes, IDictionary additionalState)
        {
            if (type != typeof(Panel))
            {
                return;
            }

            var autoBind = attributes["AutoBind"];
            if (autoBind == null)
            {
                return;
            }

            attributes.Remove("AutoBind");

            bool autoBindValue;
            Boolean.TryParse(autoBind.ToString(), out autoBindValue);
            additionalState.Add("AutoBind", autoBindValue);
        }
Exemplo n.º 26
0
        public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attribs)
        {
            string dataItemTypeName = attribs["DataItemTypeName"] as string;
            if (!string.IsNullOrEmpty(dataItemTypeName))
            {
                if (InDesigner)
                {
                    ITypeResolutionService typeResolutionService = ServiceProvider.GetService<ITypeResolutionService>();
                    DataItemType = typeResolutionService.GetType(dataItemTypeName);
                }
                else
                {
                    DataItemType = BuildManager.GetType(dataItemTypeName, true);
                }
            }

            Type fakeType = new TypedGridViewFakeType(DataItemType);
            base.Init(parser, parentBuilder, fakeType, tagName, id, attribs);
        }
Exemplo n.º 27
0
        internal static ParseRecorder CreateRecorders(TemplateParser parser) {
            if (_factories == null) {
                return ParseRecorder.Null;
            }

            List<ParseRecorder> recorders = new List<ParseRecorder>();
            foreach (Func<ParseRecorder> factory in _factories) {
                ParseRecorder recorder = factory();

                if (recorder != null) {
                    recorders.Add(recorder);
                }
            }

            ParseRecorderList list = new ParseRecorderList(recorders);

            list.Initialize(parser);

            return list;
        }
		/// <summary>
		/// Called before the <see cref="System.Web.UI.ControlBuilder"/> of 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</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">The ID of the element in the markup</param>
		/// <param name="attributes">The list of attributes of the element in the markup</param>
		/// <param name="additionalState">The additional state which can be used to store and retrieve data within
		/// several methods of the <see cref="System.Web.Compilation.ControlBuilderInterceptor"/> class</param>
		public override void PreControlBuilderInit(ControlBuilder controlBuilder, TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, IDictionary attributes, IDictionary additionalState)
		{
			if (attributes != null)
			{
				Match navigationDataBindingMatch;
				Dictionary<string, Tuple<string, bool, NavigationDirection?, bool>> navigationDataBindings = new Dictionary<string, Tuple<string, bool, NavigationDirection?, bool>>();
				foreach (DictionaryEntry entry in attributes)
				{
					navigationDataBindingMatch = _NavigationDataBindingExpression.Match(((string)entry.Value).Trim());
					if (navigationDataBindingMatch.Success)
					{
						navigationDataBindings.Add((string)entry.Key, Tuple.Create(navigationDataBindingMatch.Groups["key"].Value.Trim(), navigationDataBindingMatch.Groups["off"].Value.Length != 0, GetNavigationDirection(navigationDataBindingMatch.Groups["type"].Value), StringComparer.OrdinalIgnoreCase.Compare(navigationDataBindingMatch.Groups["type"].Value, "RefreshPostBack") == 0));
					}
				}
				if (navigationDataBindings.Count > 0)
				{
					additionalState.Add("__NavigationData", navigationDataBindings);
					foreach (string key in navigationDataBindings.Keys)
						attributes.Remove(key);
				}
			}
		}
 public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs)
 {
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     foreach (FilteredAttributeDictionary dictionary2 in ControlBuilder.ConvertDictionaryToParsedAttributeCollection(attribs).GetFilteredAttributeDictionaries())
     {
         string filter = dictionary2.Filter;
         foreach (DictionaryEntry entry in (IEnumerable) dictionary2)
         {
             string key = (string) entry.Key;
             if (StringUtil.EqualsIgnoreCase(key, "ContentPlaceHolderID"))
             {
                 if (this._contentPlaceHolder != null)
                 {
                     throw new HttpException(System.Web.SR.GetString("Content_only_one_contentPlaceHolderID_allowed"));
                 }
                 this._contentPlaceHolder = entry.Value.ToString();
                 this._contentPlaceHolderFilter = filter;
             }
             else if (attributesToPreserve.Contains<string>(key, StringComparer.OrdinalIgnoreCase))
             {
                 dictionary[key] = entry.Value.ToString();
             }
         }
     }
     if (!parser.FInDesigner)
     {
         if (this._contentPlaceHolder == null)
         {
             throw new HttpException(System.Web.SR.GetString("Control_Missing_Attribute", new object[] { "ContentPlaceHolderID", type.Name }));
         }
         attribs.Clear();
         foreach (KeyValuePair<string, string> pair in dictionary)
         {
             attribs[pair.Key] = pair.Value;
         }
     }
     base.Init(parser, parentBuilder, type, tagName, ID, attribs);
 }
Exemplo n.º 30
0
        public override void Init(TemplateParser parser, ControlBuilder parentBuilder,
                                  Type type, string tagName, string ID, IDictionary attribs) {
            
            Dictionary<string, string> preservedAttributes = new Dictionary<string, string>();

            ParsedAttributeCollection parsedAttributes = ConvertDictionaryToParsedAttributeCollection(attribs);
            foreach (FilteredAttributeDictionary filteredAttributes in parsedAttributes.GetFilteredAttributeDictionaries()) {
                string filter = filteredAttributes.Filter;
                foreach (DictionaryEntry entry in filteredAttributes) {
                    string key = (string)entry.Key;
                    if (StringUtil.EqualsIgnoreCase(key, _contentPlaceHolderIDPropName)) {
                        if (_contentPlaceHolder != null) {
                            throw new HttpException(SR.GetString(SR.Content_only_one_contentPlaceHolderID_allowed));
                        }

                        _contentPlaceHolder = entry.Value.ToString();
                        _contentPlaceHolderFilter = filter;
                    }
                    else if (attributesToPreserve.Contains(key, StringComparer.OrdinalIgnoreCase)) {
                        // Save the attribute if it is in our list
                        preservedAttributes[key] = entry.Value.ToString();
                    }
                }
            }

            if (!parser.FInDesigner) {
                if (_contentPlaceHolder == null)
                    throw new HttpException(SR.GetString(SR.Control_Missing_Attribute, _contentPlaceHolderIDPropName, type.Name));

                attribs.Clear();
                // Add the preserevd attributes back to the control
                foreach (var pair in preservedAttributes) {
                    attribs[pair.Key] = pair.Value;
                }
            }

            base.Init(parser, parentBuilder, type, tagName, ID, attribs);
        }
Exemplo n.º 31
0
        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);
        }
Exemplo n.º 32
0
        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 virtual new void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string id, System.Collections.IDictionary attribs)
 {
     Contract.Requires(parser != null);
 }
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public RootBuilder(TemplateParser parser)
 {
 }
        internal static PageParserFilter Create(PagesSection pagesConfig, System.Web.VirtualPath virtualPath, TemplateParser parser)
        {
            PageParserFilter filter = pagesConfig.CreateControlTypeFilter();

            if (filter != null)
            {
                filter.InitializeInternal(virtualPath, parser);
            }
            return(filter);
        }
Exemplo n.º 36
0
 /// <include file='doc\TemplateBuilder.uex' path='docs/doc[@for="TemplateBuilder.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, tagName, ID, attribs);
 }
        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);
        }
Exemplo n.º 38
0
 public Control ParseControl(string content, bool ignoreParserFilter)
 {
     return(TemplateParser.ParseControl(content, VirtualPath.Create(AppRelativeVirtualPath), ignoreParserFilter));
 }
Exemplo n.º 39
0
 internal void Initialize(TemplateParser parser)
 {
     this.parser = parser;
     Initialize();
 }
        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));
        }
Exemplo n.º 41
0
 /// <devdoc>
 ///    <para> Parse the input string into an ITemplate.</para>
 /// </devdoc>
 internal ITemplate ParseTemplate(string content)
 {
     return(TemplateParser.ParseTemplate(content, AppRelativeTemplateSourceDirectory));
 }
 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));
 }
Exemplo n.º 43
0
        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));
            }
        }