示例#1
0
        private TmplParser SearchInPool(string tmplName, bool adjust)
        {
            TmplParser tmpl = null;

            IIterator iter = list.IterBegin;

            for (; iter != list.IterEnd; iter = iter.IterNext)
            {
                tmpl = (TmplParser)iter.Value;
                if (tmpl.IsName(tmplName))
                {
                    if (adjust)
                    {
                        lock (this)
                        {
                            list.Remove(iter);
                            list.AddFirst(iter);
                        }
                    }
                    return(tmpl);
                }
            }

            return(null);
        }
示例#2
0
 private void Put2Pool(TmplParser tmpl)
 {
     lock (this)
     {
         if (SearchInPool(tmpl.TmplName, false) == null)
         {
             if (list.Count == capacity)
             {
                 list.RemoveLast();
             }
             list.AddFirst(tmpl);
         }
     }
 }
示例#3
0
        public ITemplate GetTemplate(string tmplFileName)
        {
            TmplParser tmpl = null;

            // do not use cached templates
            //if((tmpl = SearchInPool(tmplFileName, true)) != null)
            //	return (ITemplate)tmpl.Clone();

            tmpl = new TmplParser(tmplFileName);
            if (tmpl.Initialize(this) == false)
            {
                return(null);
            }

            Put2Pool(tmpl);

            return((ITemplate)tmpl.Clone());
        }
示例#4
0
        public TmplParser Clone()
        {
            TmplParser tmplParser = new TmplParser();

            tmplParser.EndPrefix    = endPrefix;
            tmplParser.EndSuffix    = endSuffix;
            tmplParser.StartPrefix  = startPrefix;
            tmplParser.StartSuffix  = startSuffix;
            tmplParser.tmplBuf      = tmplBuf;
            tmplParser.tmplFileName = tmplFileName;

            if (blockVec != null && blockVec.Count > 0)
            {
                tmplParser.blockVec = new ArrayList(blockVec.Count);
                for (int index = 0; index < blockVec.Count; index++)
                {
                    tmplParser.blockVec.Add(((BlockParser)blockVec[index]).Clone());
                    ((BlockParser)tmplParser.blockVec[index]).Parent =
                        tmplParser.ItemAt(GetIndex(((BlockParser)blockVec[index]).Parent));
                }
            }

            return(tmplParser);
        }