Beispiel #1
0
 private static string MergeTextMarked(string textOld, string textNew,bool overWrite)
 {
     if (overWrite)
     {
         return HParser.BuildBlockMarked(textNew);
     }
     else
     {
         HParser pOld = new HParser(textOld);
         string codigo = HParser.BuildBlockMarked(textNew);
         pOld.ReplaceInsertBlockMarked(codigo);
         return pOld.Text;
     }
 }
Beispiel #2
0
 private static void MergeEventCode(Dictionary<string, string> eNew, Dictionary<string, string> eOld, string tipo, HParser pNew, HParser pOld,bool overwrite)
 {
     foreach (string eNome in eNew.Keys)
     {
         string evento = HParser.BuildBlockMarked(eNew[eNome]);
         if (eOld.ContainsKey(eNome) && overwrite == false)
         {
             HParser ep = new HParser(eOld[eNome]);
             ep.ReplaceInsertBlockMarked(evento);
             evento = ep.Text;
         }
         evento = HParser.BuildBlock(tipo + " " + eNome, "End" + tipo + " // " + eNome, evento);
         HParser p = (overwrite ? pNew : pOld);
         p.ReplaceInsertBlock(new string[] { tipo, eNome }, new string[] { "End" + tipo }, evento);
     }
 }
Beispiel #3
0
        internal static int MergeEvents(EventsPart obj, string novo, bool overwrite)
        {
            string oldValue = obj.Source;
            HParser pNew = new HParser(novo);
            HParser pOld = new HParser(obj.Source);

            Dictionary<string, string> eNew = null;
            Dictionary<string, string> eOld = null;

            try
            {

                // Eventos
                eNew = pNew.GetEvents();
                eOld = pOld.GetEvents(true, eNew.Keys);
                MergeEventCode(eNew, eOld, "Event", pNew, pOld, overwrite);

                // Subs
                eNew = pNew.GetSubs();
                eOld = pOld.GetSubs(true, eNew.Keys);
                MergeEventCode(eNew, eOld, "Sub", pNew, pOld, overwrite);

                obj.Source = (overwrite ? pNew.Text : pOld.Text);
            }
            catch (Exception e)
            {
                throw new TemplateException("MergeEvents: "+e.Message, (e.InnerException != null ? e.InnerException : e), obj.KBObject.Name);
            }
            return (oldValue != obj.Source ? 1 : 0);
        }
Beispiel #4
0
        internal int MergeProcedureSource(ProcedurePart obj, PatternInstanceElement c, string template, bool overwrite)
        {
            string oldValue = obj.Source;
            if (!String.IsNullOrEmpty(template))
            {
                try
                {
                    HParser pOld = new HParser(obj.Source);
                    HParser pNew = new HParser(AppendTemplateOutput(obj.KBObject, obj, c, template));
                    Dictionary<string, string> sNew = pNew.GetSubs();
                    Dictionary<string, string> sOld = pOld.GetSubs(true, sNew.Keys);
                    pOld.DeleteBlocks(new string[] { "Sub" }, new string[] { "EndSub" });
                    pNew.DeleteBlocks(new string[] { "Sub" }, new string[] { "EndSub" });

                    HParser p = (overwrite ? pNew : pOld);
                    p.ReplaceInsertBlockMarked(HParser.BuildBlockMarked(pNew.Text));
                    p.ClearCode();

                    MergeEventCode(sNew, sOld, "Sub", pNew, pOld, overwrite);

                    obj.Source = p.Text;
                }
                catch (Exception ex)
                {
                    throw new TemplateException(obj.KBObject.Name, ex);
                }

            }
            return (oldValue != obj.Source ? 1 : 0);
        }
Beispiel #5
0
 internal bool isBlockEmpty(string block)
 {
     bool ret = false;
     HParser hp = new HParser(block);
     if (hp.DeleteBlock(new string[] { k_GeneratedMarkerStart }, new string[] { k_GeneratedMarkerEnd }))
     {
         if (String.IsNullOrEmpty(hp.Text))
         {
             ret = true;
         }
     }
     return ret;
 }