Beispiel #1
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 #2
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);
        }