Example #1
0
        /// <summary>
        /// Make the 'to' template look exactly like the 'from' template
        /// except for the attributes.
        /// </summary>
        override protected void  dup(StringTemplate from, StringTemplate to)
        {
            base.dup(from, to);
            ViewComponentStringTemplate fromST = (ViewComponentStringTemplate)from;
            ViewComponentStringTemplate toST   = (ViewComponentStringTemplate)to;

            toST.viewComponent        = fromST.viewComponent;
            toST.viewComponentName    = fromST.viewComponentName;
            toST.viewComponentContext = fromST.viewComponentContext;
        }
		public override StringTemplate LookupTemplate(StringTemplate enclosingInstance, string name)
		{
			if (name.StartsWith("super."))
			{
				if (superGroup != null)
				{
					int dot = name.IndexOf('.');
					name = name.Substring(dot + 1, (name.Length) - (dot + 1));
					StringTemplate superScopeST =
						superGroup.LookupTemplate(enclosingInstance,name);
					return superScopeST;
				}
				throw new StringTemplateException(Name + " has no super group; invalid template: " + name);
			}

			StringTemplate st = (StringTemplate) templates[name];
			bool foundCachedWrappingTemplate = (st is ViewComponentStringTemplate);
			if ((st == null) || foundCachedWrappingTemplate)
			{
				if (enclosingInstance != null)
				{
					string prefix;
					int index = name.IndexOf('/');
					if (index == -1)
						prefix = name;
					else
						prefix = name.Substring(0, index);

					if ("blockcomponent".Equals(prefix))
					{
						if (st == null)
							st = new ViewComponentStringTemplate(name, this);
						((ViewComponentStringTemplate)st).ViewComponentName = name.Substring(index+1);
					}
					else if ("component".Equals(prefix))
					{
						if (st == null)
							st = new ViewComponentStringTemplate(name, this);
						((ViewComponentStringTemplate)st).ViewComponentName = name.Substring(index+1);
					}
					else if ("capturefor".Equals(prefix))
					{
						if (st == null)
							st = new ViewComponentStringTemplate(name, this);
						((ViewComponentStringTemplate)st).ViewComponentName = "CaptureFor";
					}

					if ((!foundCachedWrappingTemplate) && (st != null))
					{
							templates[name] = st;
					}
				}

				if (st == null && superGroup != null)
				{
					st = superGroup.GetInstanceOf(enclosingInstance, name);
					if (st != null)
					{
						st.Group = this;
					}
				}
				if (st == null)
				{
					templates[name] = NOT_FOUND_ST;
				}
			}
			else if (st == NOT_FOUND_ST)
			{
				return null;
			}
			return st;
		}
Example #3
0
        public override StringTemplate LookupTemplate(StringTemplate enclosingInstance, string name)
        {
            if (name.StartsWith("super."))
            {
                if (superGroup != null)
                {
                    int dot = name.IndexOf('.');
                    name = name.Substring(dot + 1, (name.Length) - (dot + 1));
                    StringTemplate superScopeST =
                        superGroup.LookupTemplate(enclosingInstance, name);
                    return(superScopeST);
                }
                throw new StringTemplateException(Name + " has no super group; invalid template: " + name);
            }

            StringTemplate st = (StringTemplate)templates[name];
            bool           foundCachedWrappingTemplate = (st is ViewComponentStringTemplate);

            if ((st == null) || foundCachedWrappingTemplate)
            {
                if (enclosingInstance != null)
                {
                    string prefix;
                    int    index = name.IndexOf('/');
                    if (index == -1)
                    {
                        prefix = name;
                    }
                    else
                    {
                        prefix = name.Substring(0, index);
                    }

                    if ("blockcomponent".Equals(prefix))
                    {
                        if (st == null)
                        {
                            st = new ViewComponentStringTemplate(name, this);
                        }
                        ((ViewComponentStringTemplate)st).ViewComponentName = name.Substring(index + 1);
                    }
                    else if ("component".Equals(prefix))
                    {
                        if (st == null)
                        {
                            st = new ViewComponentStringTemplate(name, this);
                        }
                        ((ViewComponentStringTemplate)st).ViewComponentName = name.Substring(index + 1);
                    }
                    else if ("capturefor".Equals(prefix))
                    {
                        if (st == null)
                        {
                            st = new ViewComponentStringTemplate(name, this);
                        }
                        ((ViewComponentStringTemplate)st).ViewComponentName = "CaptureFor";
                    }

                    if ((!foundCachedWrappingTemplate) && (st != null))
                    {
                        templates[name] = st;
                    }
                }

                if (st == null && superGroup != null)
                {
                    st = superGroup.GetInstanceOf(enclosingInstance, name);
                    if (st != null)
                    {
                        st.Group = this;
                    }
                }
                if (st == null)
                {
                    templates[name] = NOT_FOUND_ST;
                }
            }
            else if (st == NOT_FOUND_ST)
            {
                return(null);
            }
            return(st);
        }