public bool InvokeTest()
        {
            Template tp = new Template("$replace($hello$,',\\')$");
            tp.SetAttribute("hello", "Hi y'all");
            Console.WriteLine(tp.ToString());


            return true;
        }
        bool ITest.InvokeTest()
        {
            Template tp = new Template("$TypeName(fred)$");
            tp.SetAttribute("fred", new BasicTypeNameTests());
            if (tp.ToString() != "StringTemplateTester.TestCases.Basic.BasicTypeNameTests")
            {
                Console.WriteLine("Basic type name test failed with result: " + tp.ToString());
                return false;
            }

            tp = new Template("$(TypeName(fred) eq basicTypeString)$");
            tp.SetAttribute("fred", new BasicTypeNameTests());
            tp.SetAttribute("basicTypeString", "StringTemplateTester.TestCases.Basic.BasicTypeNameTests");
            if (tp.ToString() != "True")
            {
                Console.WriteLine("Basic type name test using equal failed with result: " + tp.ToString());
                return false;
            }

            tp = new Template("$(TypeName(fred) eq 'StringTemplateTester.TestCases.Basic.BasicTypeNameTests')$");
            tp.SetAttribute("fred", new BasicTypeNameTests());
            tp.SetAttribute("basicTypeString", "StringTemplateTester.TestCases.Basic.BasicTypeNameTests");
            if (tp.ToString() != "True")
            {
                Console.WriteLine("Basic type name test using equal failed with result: " + tp.ToString());
                return false;
            }

            tp = new Template("$if((TypeName(fred) eq basicTypeString))$Yes it is$else$No its not$endif$");
            tp.SetAttribute("fred", new BasicTypeNameTests());
            tp.SetAttribute("basicTypeString", "StringTemplateTester.TestCases.Basic.BasicReplaceTest");
            if (tp.ToString() != "No its not")
            {
                Console.WriteLine("Basic type name test using equal if failed with result: " + tp.ToString());
                return false;
            }

            return true;
        }
 internal static sFreeSwitchModuleFile FixSofiaFile(sFreeSwitchModuleFile file)
 {
     string confSection = file.ConfigurationSectionString;
     if (confSection.Contains("<profiles>")){
         string pre = confSection.Substring(0,confSection.IndexOf("<profiles>"));
         confSection = pre + confSection.Substring(confSection.IndexOf("</profiles>") + "</profiles>".Length);
     }
     Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.UserModules.XmlCurl.resources.sip_profile.st"));
     CoreGenerator.Lock();
     st.SetAttribute("profiles",CoreGenerator.Profiles);
     confSection = confSection.Replace("</configuration>",st.ToString()+"</configuration>");
     CoreGenerator.UnLock();
     return new sFreeSwitchModuleFile(file.Name,file.Description,confSection);
 }
        bool ITest.InvokeTest()
        {
            Template t = new Template("$DECLARE(name as String = \"bob\")$$name$");
            if (t.ToString() != "bob")
            {
                Console.WriteLine("Testing basic variable failed with results: " + t.ToString());
                return false;
            }

            t = new Template("$DECLARE(names as String[] = {\"bob\",\"fred\",$jack$})$$names:{name|$name$,}$");
            t.SetAttribute("jack","jack");
            if (t.ToString() != "bob,fred,jack,")
            {
                Console.WriteLine("Testing basic array declaration with variable failed with results: " + t.ToString());
                return false;
            }

            t = new Template("$DECLARE(myname as StringTemplateTester.TestCases.Basic.Name = StringTemplateTester.TestCases.Basic.Name.ConstructNew($bob$,$jack$))$$myname.FirstName$,$myname.LastName$");
            t.SetAttribute("jack", "jack");
            t.SetAttribute("bob", "bob");
            if (t.ToString() != "bob,jack")
            {
                Console.WriteLine("Testing basic static call with variable failed with results: " + t.ToString());
                return false;
            }

            t = new Template("$DECLARE(myname as StringTemplateTester.TestCases.Basic.Name = NEW StringTemplateTester.TestCases.Basic.Name($bob$,$jack$))$$myname.FirstName$,$myname.LastName$");
            t.SetAttribute("jack", "jack");
            t.SetAttribute("bob", "bob");
            if (t.ToString() != "bob,jack")
            {
                Console.WriteLine("Testing basic constructor call with variable failed with results: " + t.ToString());
                return false;
            }
            return true;
        }
 public void DeploySipProfile(sDeployedProfile profile)
 {
     string str = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.BaseConfigurations.sip_profile.st");
     Template st = new Template(str);
     st.SetAttribute("profile", profile);
     DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
         Path.DirectorySeparatorChar + Constants.DEFAULT_SIP_PROFILES_PATH + Path.DirectorySeparatorChar + profile.Name);
     if (!di.Exists)
     {
         Log.Trace("Creating SIP profile directory " + profile.Name + " for gateways");
         di.Create();
     }
     FileInfo fi = new FileInfo(di.FullName + ".xml");
     if (fi.Exists)
         fi.Delete();
     Log.Trace("Deploying SIP profile configuration file for sip_profile " + profile.Name);
     FileStream fs = fi.OpenWrite();
     st.WriteToStream(fs);
     fs.Close();
 }
 public void DeployDomain(sDeployedDomain domain)
 {
     DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
         Path.DirectorySeparatorChar + Constants.DEFAULT_EXTENSIONS_DIRECTORY + Path.DirectorySeparatorChar + domain.Name);
     if (!di.Exists)
     {
         Log.Trace("Creating domain directory " + domain.Name + " for extensions");
         di.Create();
     }
     FileInfo fi = new FileInfo(di.FullName + ".xml");
     if (fi.Exists)
         fi.Delete();
     Log.Trace("Deploying domain configuration file for domain " + domain.Name);
     string str = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.BaseConfigurations.domain.st");
     Template st = new Template(str);
     st.SetAttribute("domain", domain);
     FileStream fs = fi.OpenWrite();
     st.WriteToStream(fs);
     fs.Close();
 }
        public bool InvokeTest()
        {
            Template t = new Template("$format(mydate,dd-MMM-yyyy HH:mm:ss)$");
            DateTime tmp = DateTime.Now;
            t.SetAttribute("mydate", tmp);
            if (t.ToString() != tmp.ToString("dd-MMM-yyyy HH:mm:ss"))
            {
                Console.WriteLine("Failed basic format test using a datetime variable with result: " + t.ToString());
                return false;
            }

            t = new Template("$format(myNumber,'#,###.00')$");
            t.SetAttribute("myNumber", 9999.99);
            if (t.ToString() != ((double)9999.99).ToString("#,###.00"))
            {
                Console.WriteLine("Failed basic format test using a double variable with result: "+t.ToString());
                return false;
            }

            return true;
        }
 public void ProcessRequest(HttpRequest request, Org.Reddragonit.EmbeddedWebServer.Interfaces.Site site)
 {
     request.ResponseHeaders["Cache-Control"] = "max-age = " + (60 * 60).ToString();
     List<string> paths = new List<string>();
     string ext = request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf("."));
     string bPath = "scripts";
     if (ext == ".css")
         bPath = "styles";
     switch (request.URL.AbsolutePath)
     {
         case "/resources/scripts/core.js":
         case "/resources/styles/core.css":
             paths.AddRange(_CORE_PATHS);
             break;
         case "/resources/scripts/setup.js":
         case "/resources/styles/setup.css":
             paths.AddRange(_SETUP_PATHS);
             break;
         case "/resources/scripts/user.js":
             paths.AddRange(_USER_PATHS);
             foreach (MainMenuItem mmi in MainMenuItem.LoadAll())
             {
                 if (mmi.JavascriptURLs != null)
                     paths.AddRange(mmi.JavascriptURLs);
                 if (mmi.CombinedURLs != null)
                     paths.AddRange(mmi.CombinedURLs);
                 if (mmi.SubMenuItems != null)
                 {
                     foreach (SubMenuItem smi in mmi.SubMenuItems)
                     {
                         if (smi.JavascriptURLs != null)
                             paths.AddRange(smi.JavascriptURLs);
                         if (smi.CombinedURLs != null)
                             paths.AddRange(smi.CombinedURLs);
                     }
                 }
                 foreach (IHomePageComponent ihp in parts)
                 {
                     if (ihp.JSUrls != null)
                         paths.AddRange(ihp.JSUrls);
                 }
             }
             break;
         case "/resources/styles/user.css":
             paths.AddRange(_USER_PATHS);
             foreach (MainMenuItem mmi in MainMenuItem.LoadAll())
             {
                 if (mmi.CssURLs != null)
                     paths.AddRange(mmi.CssURLs);
                 if (mmi.CombinedURLs != null)
                     paths.AddRange(mmi.CombinedURLs);
                 if (mmi.SubMenuItems != null)
                 {
                     foreach (SubMenuItem smi in mmi.SubMenuItems)
                     {
                         if (smi.CssURLs != null)
                             paths.AddRange(smi.CssURLs);
                         if (smi.CombinedURLs != null)
                             paths.AddRange(smi.CombinedURLs);
                     }
                 }
                 foreach (IHomePageComponent ihp in parts)
                 {
                     if (ihp.CSSUrls != null)
                         paths.AddRange(ihp.CSSUrls);
                 }
             }
             break;
     }
     request.ResponseHeaders.ContentType = HttpUtility.GetContentTypeForExtension(request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf(".")));
     foreach (string str in paths)
     {
         if (str.StartsWith("TYPE=")||str.StartsWith("/EmbeddedJSGenerator.js?TYPE="))
         {
             if (ext != ".css")
             {
                 request.ResponseWriter.WriteLine("/* " + str + " */");
                 foreach (IRequestHandler irh in site.Handlers)
                 {
                     if (irh is EmbeddedServiceHandler)
                     {
                         request.ResponseWriter.WriteLine(((EmbeddedServiceHandler)irh).GenerateJSForServiceType(str.Substring(str.IndexOf("=") + 1)));
                     }
                 }
             }
         }
         else
         {
             List<string> tpaths = new List<string>();
             if (str.StartsWith("/"))
             {
                 if (str.EndsWith(".min" + ext))
                 {
                     tpaths.Add(str);
                     tpaths.Add(str.Substring(0, str.LastIndexOf(".min")) + ext);
                 }
                 else
                 {
                     tpaths.Add(str);
                     tpaths.Add(str.Substring(0, str.LastIndexOf(ext)) + ".min" + ext);
                 }
             }
             else
             {
                 tpaths.AddRange(new string[]{
                     "/resources/" + bPath + "/" + str.Replace(".", "/") + ext,
                     "/resources/" + bPath + "/base/" + str.Replace(".", "/") + ext,
                     "/resources/" + bPath + "/" + (request.IsMobile ? "mobile" : "desktop") + "/" + str.Replace(".", "/") + ext,
                     "Org.Reddragonit.FreeSwitchConfig.Site." + bPath + ".base." + str + ext,
                     "Org.Reddragonit.FreeSwitchConfig.Site." + bPath + "." + (request.IsMobile ? "mobile" : "desktop") + "." + str + ext,
                     "/resources/" + bPath + "/" + str.Replace(".", "/")+".min" + ext,
                     "/resources/" + bPath + "/base/" + str.Replace(".", "/")+".min" + ext,
                     "/resources/" + bPath + "/" + (request.IsMobile ? "mobile" : "desktop") + "/" + str.Replace(".", "/")+".min" + ext,
                     "Org.Reddragonit.FreeSwitchConfig.Site." + bPath + ".base." + str+".min" + ext,
                     "Org.Reddragonit.FreeSwitchConfig.Site." + bPath + "." + (request.IsMobile ? "mobile" : "desktop") + "." + str+".min" + ext
                 });
             }
             foreach (string path in tpaths)
             {
                 if (path.StartsWith("/"))
                 {
                     request.ResponseWriter.WriteLine("/* " + path + " */");
                     VirtualMappedRequest vmp = new VirtualMappedRequest(new Uri("http://" + request.URL.Host + ":" + request.URL.Port.ToString() + path), request.Headers["Accept-Language"]);
                     Org.Reddragonit.BackBoneDotNet.RequestHandler.HandleRequest(vmp);
                     request.ResponseWriter.WriteLine(vmp.ToString());
                     if (site.EmbeddedFiles != null)
                     {
                         if (site.EmbeddedFiles.ContainsKey(path))
                         {
                             if (ModelHandler.CompressJS)
                                 request.ResponseWriter.WriteLine((request.URL.AbsolutePath.EndsWith(".js") ? JSMinifier.Minify(Utility.ReadEmbeddedResource(site.EmbeddedFiles[path].DLLPath)) : CSSMinifier.Minify(Utility.ReadEmbeddedResource(site.EmbeddedFiles[path].DLLPath))));
                             else
                                 request.ResponseWriter.WriteLine(Utility.ReadEmbeddedResource(site.EmbeddedFiles[path].DLLPath));
                         }
                     }
                     string tmpStr = Utility.ReadEmbeddedResource(_ReverseURL(path));
                     if (tmpStr != null)
                     {
                         if (ModelHandler.CompressJS)
                             request.ResponseWriter.WriteLine((request.URL.AbsolutePath.EndsWith(".js") ? JSMinifier.Minify(tmpStr) : CSSMinifier.Minify(tmpStr)));
                         else
                             request.ResponseWriter.WriteLine(tmpStr);
                     }
                 }
                 else
                 {
                     request.ResponseWriter.WriteLine("/* " + _ExtractURL(path) + " */");
                     request.ResponseWriter.WriteLine(Utility.ReadEmbeddedResource(path));
                 }
             }
         }
     }
     if (request.URL.AbsolutePath=="/resources/scripts/core.js")
         _WriteConstants(request);
     else if (request.URL.AbsolutePath == "/resources/scripts/setup.js")
     {
     }
     else if (request.URL.AbsolutePath == "/resources/scripts/user.js")
     {
         Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.Site.Deployments.home.js"));
         st.SetAttribute("components", parts);
         request.ResponseWriter.WriteLine(st.ToString());
     }
 }
        public bool InvokeTest()
        {
            //testing string variable
            Template tp = new Template("This is my string: $mystring$");
            tp.SetParameter("mystring", "Hello world");
            if (tp.ToString() != "This is my string: Hello world")
            {
                Console.WriteLine("Basic string test failed with results: "+tp.ToString());
                return false;
            }

            //testing string array
            tp = new Template("This is my string array: $mystringarray$");
            tp.SetParameter("mystringarray", new string[] { "Bob", "Lob", "Law" });
            if (tp.ToString() != "This is my string array: BobLobLaw")
            {
                Console.WriteLine("Basic string array test failed with results: " + tp.ToString());
                return false;
            }

            //testing List<string> object
            tp.ClearParameters();
            tp.SetParameter("mystringarray", new List<string>(new string[] { "Bob", "Lob", "Law" }));
            if (tp.ToString() != "This is my string array: BobLobLaw")
            {
                Console.WriteLine("Basic List<string> array test failed with results: " + tp.ToString());
                return false;
            }

            //testing Hashtable object
            tp = new Template("This is my hashtable: $myhashtable$");
            Hashtable ht = new Hashtable();
            ht.Add("FirstName", "Bob");
            ht.Add("LastName", "LobLaw");
            tp.SetParameter("myhashtable", ht);
            if (tp.ToString() != "This is my hashtable: LastName-->LobLaw, FirstName-->Bob")
            {
                Console.WriteLine("Basic hashtable test failed with results: " + tp.ToString());
                return false;
            }

            //testing Dictionary object
            tp = new Template("This is my dictionary: $mydictionary$");
            Dictionary<string, string> dc = new Dictionary<string, string>();
            dc.Add("FirstName", "Bob");
            dc.Add("LastName", "LobLaw");
            tp.SetParameter("mydictionary",dc);
            if (tp.ToString() != "This is my dictionary: FirstName-->Bob, LastName-->LobLaw")
            {
                Console.WriteLine("Basic Dictionary test failed with results: " + tp.ToString());
                return false;
            }

            //testing Complex Dictionary
            tp = new Template("This is the subelement $mydictionary.name1.FirstName$");
            Dictionary<string, Dictionary<string, string>> cdc = new Dictionary<string, Dictionary<string, string>>();
            cdc.Add("name1", dc);
            tp.SetAttribute("mydictionary", cdc);
            if (tp.ToString() != "This is the subelement Bob")
            {
                Console.Write("Complex Dictionary test failed with results: " + tp.ToString());
                return false;
            }

            //testing Complex Class Dictionary
            tp = new Template("This is the subelement $myteir.Child.Name$");
            tp.SetAttribute("myteir", new teir1(new teir2("Bob")));
            if (tp.ToString() != "This is the subelement Bob")
            {
                Console.Write("Complex Dictionary test failed with results: " + tp.ToString());
                return false;
            }

            //testing access to single dictionary object
            tp = new Template("This is my dictionaries first name value: $mydictionary.FirstName$");
            tp.SetParameter("mydictionary", dc);
            if (tp.ToString() != "This is my dictionaries first name value: Bob")
            {
                Console.WriteLine("Basic Dictionary accessing single value test failed with results: " + tp.ToString());
                return false;
            }

            //testing escape character
            tp = new Template("This is my escape character test worth \\$$money$");
            tp.SetParameter("money", 1000);
            if (tp.ToString() != "This is my escape character test worth $1000")
            {
                Console.WriteLine("Basic escape character test failed with results: " + tp.ToString());
                return false;
            }

            //testing accessing a class object within a dictionary
            tp = new Template("This is my last name value: $mydictionary.FirstPerson.Name$");
            Dictionary<string, teir2> mydc = new Dictionary<string, teir2>();
            mydc.Add("FirstPerson", new teir2("LobLaw"));
            tp.SetAttribute("mydictionary", mydc);
            if (tp.ToString() != "This is my last name value: LobLaw")
            {
                Console.WriteLine("Complex access to object property from within dictionary failed with results: " + tp.ToString());
                return false;
            }

            return true;
        }
        public bool InvokeTest()
        {
            //test non parametered call
            Template tp = new Template("$bob:CreateJavascriptElem()$",Program.TestGroup);
            tp.SetParameter("bob", "Hello World");
            if (tp.ToString() != "'Hello World'")
            {
                Console.WriteLine("The basic template group code test failed with results: " + tp.ToString());
                return false;
            }

            //test parametered call by defining variables in full
            tp = new Template("$GenerateLargeForm(content=con,id=ID,title=TITLE,OnClose=Clos,OnMinimize=Min,scriptID=SCID)$", Program.TestGroup);
            tp.SetParameter("con", "TEST CONTENT");
            tp.SetParameter("TITLE", "TESTING");
            tp.SetParameter("SCID", "'test'");
            tp.SetParameter("ID", "test");
            if (tp.ToString() != "<div id=\"test\" onBlur=\"UnHighlightTaskBar('test');\" class=\"Form transparent\" style=\"max-width:800px;max-height:600px;\"><div class=\"tl\"><div class=\"tr\"><div class=\"ControlButtons\"><img src=\"./FormParts/minimize.png\" alt=\"minimize\" onclick=\"MinimizeForm('test');\"><img src=\"./FormParts/cancel.png\" alt=\"close\" onclick=\"CloseForm('test');\"></div></div><div class=\"top\" id=\"test_top\"><center>TESTING</center></div></div><div class=\"left\"><div class=\"right\"><div style=\"overflow:auto;max-width:794px;max-height:552px;background-color:White;padding:5px;color:Black;\">TEST CONTENT</div></div></div><div class=\"bl\"><div class=\"br\"></div><div class=\"bottom\"><div class=\"status\"><div id=\"test_status\" class=\"statusContainer\"></div></div><div style=\"clear:right;\"></div></div></div></div>")
            {
                Console.WriteLine("The basic template group code test failed with results: " + tp.ToString());
                return false;
            }

            //test parametered call without defining variables in full
            tp = new Template("$GenerateLargeForm(con,ID,TITLE,Clos,Min,SCID)$", Program.TestGroup);
            tp.SetParameter("con", "TEST CONTENT");
            tp.SetParameter("TITLE", "TESTING");
            tp.SetParameter("SCID", "'test'");
            tp.SetParameter("ID", "test");
            if (tp.ToString() != "<div id=\"test\" onBlur=\"UnHighlightTaskBar('test');\" class=\"Form transparent\" style=\"max-width:800px;max-height:600px;\"><div class=\"tl\"><div class=\"tr\"><div class=\"ControlButtons\"><img src=\"./FormParts/minimize.png\" alt=\"minimize\" onclick=\"MinimizeForm('test');\"><img src=\"./FormParts/cancel.png\" alt=\"close\" onclick=\"CloseForm('test');\"></div></div><div class=\"top\" id=\"test_top\"><center>TESTING</center></div></div><div class=\"left\"><div class=\"right\"><div style=\"overflow:auto;max-width:794px;max-height:552px;background-color:White;padding:5px;color:Black;\">TEST CONTENT</div></div></div><div class=\"bl\"><div class=\"br\"></div><div class=\"bottom\"><div class=\"status\"><div id=\"test_status\" class=\"statusContainer\"></div></div><div style=\"clear:right;\"></div></div></div></div>")
            {
                Console.WriteLine("The basic template group code test failed with results: " + tp.ToString());
                return false;
            }

            //test parametered call without defining variables in full and specifying group prefix
            tp = new Template("$skin/GenerateLargeForm(con,ID,TITLE,Clos,Min,SCID)$", Program.TestGroup);
            tp.SetParameter("con", "TEST CONTENT");
            tp.SetParameter("TITLE", "TESTING");
            tp.SetParameter("SCID", "'test'");
            tp.SetParameter("ID", "test");
            if (tp.ToString() != "<div id=\"test\" onBlur=\"UnHighlightTaskBar('test');\" class=\"Form transparent\" style=\"max-width:800px;max-height:600px;\"><div class=\"tl\"><div class=\"tr\"><div class=\"ControlButtons\"><img src=\"./FormParts/minimize.png\" alt=\"minimize\" onclick=\"MinimizeForm('test');\"><img src=\"./FormParts/cancel.png\" alt=\"close\" onclick=\"CloseForm('test');\"></div></div><div class=\"top\" id=\"test_top\"><center>TESTING</center></div></div><div class=\"left\"><div class=\"right\"><div style=\"overflow:auto;max-width:794px;max-height:552px;background-color:White;padding:5px;color:Black;\">TEST CONTENT</div></div></div><div class=\"bl\"><div class=\"br\"></div><div class=\"bottom\"><div class=\"status\"><div id=\"test_status\" class=\"statusContainer\"></div></div><div style=\"clear:right;\"></div></div></div></div>")
            {
                Console.WriteLine("The basic template group code test failed with results: " + tp.ToString());
                return false;
            }

            //test parametered call without defining variables in full and specifying group prefix
            tp = new Template("$skin/GenerateLargeForm(con,ID,TITLE,Clos,Min,SCID):CreateJavascriptElem()$", Program.TestGroup);
            tp.SetParameter("con", "TEST CONTENT");
            tp.SetParameter("TITLE", "TESTING");
            tp.SetParameter("SCID", "'test'");
            tp.SetParameter("ID", "test");
            if (tp.ToString() != "'<div id=\"test\" onBlur=\"UnHighlightTaskBar('test');\" class=\"Form transparent\" style=\"max-width:800px;max-height:600px;\"><div class=\"tl\"><div class=\"tr\"><div class=\"ControlButtons\"><img src=\"./FormParts/minimize.png\" alt=\"minimize\" onclick=\"MinimizeForm('test');\"><img src=\"./FormParts/cancel.png\" alt=\"close\" onclick=\"CloseForm('test');\"></div></div><div class=\"top\" id=\"test_top\"><center>TESTING</center></div></div><div class=\"left\"><div class=\"right\"><div style=\"overflow:auto;max-width:794px;max-height:552px;background-color:White;padding:5px;color:Black;\">TEST CONTENT</div></div></div><div class=\"bl\"><div class=\"br\"></div><div class=\"bottom\"><div class=\"status\"><div id=\"test_status\" class=\"statusContainer\"></div></div><div style=\"clear:right;\"></div></div></div></div>'")
            {
                Console.WriteLine("The basic template group code test failed with results: " + tp.ToString());
                return false;
            }

            //testing recur calling template in string template group
            tp = new Template("$GenerateMenu(items)$", Program.TestGroup);
            List<MenuEntry> items = new List<MenuEntry>();
            items.Add(new MenuEntry("test1",
                new MenuEntry[]{
                    new MenuEntry("test1.1",null),
                    new MenuEntry("test1.2",null)
                }));
            items.Add(new MenuEntry("test2",
                            new MenuEntry[]{
                    new MenuEntry("test2.1",null),
                    new MenuEntry("test2.2",null)
                }));
            tp.SetAttribute("items", items);

            System.Diagnostics.Debug.WriteLine(tp.ToString());

            return true;
        }
 public void DeployOutgoingSipTrunk(sDeployedOutgoingSipTrunk trunk)
 {
     DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
         Path.DirectorySeparatorChar + Constants.DEFAULT_SIP_PROFILES_PATH + Path.DirectorySeparatorChar + trunk.ProfileName);
     string str = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.SIPTrunk.External.st");
     Log.Trace("Generating config file for outgoing sip trunk " + trunk.Name);
     Template st = new Template(str);
     st.SetAttribute("trunk", trunk);
     FileStream fs = new FileStream(di.FullName + Path.DirectorySeparatorChar + trunk.Name + ".xml", FileMode.Create, FileAccess.Write, FileShare.None);
     st.WriteToStream(fs);
     fs.Close();
 }
 public void DeployIncomingSipTrunk(sDeployedIncomingSIPTrunk trunk)
 {
     string intTrunkTemplate = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.SIPTrunk.Internal.st");
     Template st = new Template(intTrunkTemplate);
     st.SetAttribute("trunk", trunk);
     DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
         Path.DirectorySeparatorChar + Constants.DEFAULT_EXTENSIONS_DIRECTORY + Path.DirectorySeparatorChar + trunk.DomainName);
     FileStream fs = new FileStream(di.FullName + Path.DirectorySeparatorChar + trunk.Number + ".xml", FileMode.Create, FileAccess.Write, FileShare.None);
     st.WriteToStream(fs);
     fs.Close();
 }
 public void DeployExtension(sDeployedExtension extension)
 {
     DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
         Path.DirectorySeparatorChar + Constants.DEFAULT_EXTENSIONS_DIRECTORY + Path.DirectorySeparatorChar + extension.DomainName);
     string str = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.Extension.st");
     Log.Trace("Generating config file for extension " + extension.Number);
     Template st = new Template(str);
     st.SetAttribute("ext", extension);
     FileStream fs = new FileStream(di.FullName + Path.DirectorySeparatorChar + extension.Number + ".xml", FileMode.Create, FileAccess.Write, FileShare.None);
     st.WriteToStream(fs);
     fs.Close();
 }
        public bool InvokeTest()
        {
            //basic forloop
            Template tp = new Template("$entries:{entry |$entry$\n}$");
            tp.SetParameter("entries", new string[] { "line1", "line2", "line3" });
            if (tp.ToString() != "line1\nline2\nline3\n")
            {
                Console.WriteLine("Basic foreach loop test failed with results: " + tp.ToString());
                return false;
            }

            //basic dictionary forloop
            tp = new Template("$entries:{entry|$entry.Key$=$entry.Value$\n}$");
            Dictionary<string, string> vars = new Dictionary<string, string>();
            vars.Add("FirstName", "Bob");
            vars.Add("LastName", "LobLaw");
            tp.SetParameter("entries", vars);
            if (tp.ToString() != "FirstName=Bob\nLastName=LobLaw\n")
            {
                Console.WriteLine("Basic foreach using dictionary test failed with results: " + tp.ToString());
                return false;
            }

            //dictionary array test
            tp = new Template("$entries:{entry |$entry.FirstName$ $entry.LastName$\n}$");
            List<Dictionary<string, string>> arVars = new List<Dictionary<string, string>>();
            arVars.Add(vars);
            vars = new Dictionary<string, string>();
            vars.Add("FirstName", "Amanda");
            vars.Add("LastName", "Hugnkiss");
            arVars.Add(vars);
            tp.SetParameter("entries", arVars);
            if (tp.ToString() != "Bob LobLaw\nAmanda Hugnkiss\n")
            {
                Console.WriteLine("Basic foreach using array of dictionaries failed with results: " + tp.ToString());
                return false;
            }

            //testing for in for
            tp = new Template("$entries:{entry |$entry.Names:{name|$name$\n}$}$");
            List<Dictionary<string, List<string>>> compVars = new List<Dictionary<string, List<string>>>();
            Dictionary<string, List<string>> ent = new Dictionary<string, List<string>>();
            ent.Add("Names", new List<string>(new string[] { "test1", "test2" }));
            compVars.Add(ent);
            vars = new Dictionary<string, string>();
            tp.SetParameter("entries", compVars);
            if (tp.ToString().Trim() != "test1\ntest2")
            {
                Console.WriteLine("Basic foreach For in For failed with results: " + tp.ToString());
                return false;
            }

            tp = new Template(Program.ReadEmbeddedResource("StringTemplateTester.resources.test.st"));
            arVars = new List<Dictionary<string, string>>();
            Dictionary<string, string> file = new Dictionary<string, string>();
            file.Add("Name", "MyFile");
            file.Add("JScriptName", "MyFile");
            arVars.Add(file);
            file = new Dictionary<string, string>();
            file.Add("Name", "My Name's");
            file.Add("JScriptName", "My Name\\'s");
            arVars.Add(file);
            tp.SetAttribute("files", arVars);
            System.Diagnostics.Debug.WriteLine(tp.ToString());

            return true;
        }
        public bool InvokeTest()
        {
            Template tp = new Template("$if(bob)$Hello Bob$elseif(fred)$Hello Fred$else$GET OUT STRANGER DANGER$endif$");

            //testing basic if
            tp.SetParameter("bob", true);
            if (tp.ToString() != "Hello Bob")
            {
                Console.WriteLine("Basic If statement test failed with result: " + tp.ToString());
                return false;
            }

            //testing else if 
            tp.RemoveParameter("bob");
            tp.SetParameter("bob", false);
            tp.SetParameter("fred", true);
            if (tp.ToString() != "Hello Fred")
            {
                Console.WriteLine("Basic elseif statement test failed with result: " + tp.ToString());
                return false;
            }

            //testing else using nulls
            tp.ClearParameters();
            if (tp.ToString() != "GET OUT STRANGER DANGER")
            {
                Console.WriteLine("Basic else statement test failed with result: " + tp.ToString());
                return false;
            }

            //testing using complex parameter
            tp = new Template("$if(bob.IsHere)$YAY I found bob$else$BOO bob is dead$endif$");
            Dictionary<string, object> vars = new Dictionary<string, object>();
            vars.Add("IsHere", true);
            tp.SetParameter("bob", vars);
            if (tp.ToString() != "YAY I found bob")
            {
                Console.WriteLine("Basic if using complex parameter failed with result: " + tp.ToString());
                return false;
            }

            //testing compare in if statement
            tp = new Template("$if(equal(bob,fred))$Bob is Fred$else$Bob is not Fred$endif$");
            tp.SetParameter("bob", "bob");
            tp.SetParameter("fred", "bob");
            if (tp.ToString() != "Bob is Fred")
            {
                Console.WriteLine("Basic if test using equal function inside failed with result: " + tp.ToString());
                return false;
            }

            //testing not compare in if statement
            tp = new Template("$if(notequal(bob,fred))$Bob is Fred$else$Bob is not Fred$endif$");
            tp.SetParameter("bob", "bob");
            tp.SetParameter("fred", "bob");
            if (tp.ToString() != "Bob is not Fred")
            {
                Console.WriteLine("Basic if test using notequal function inside failed with result: " + tp.ToString());
                return false;
            }
            
            //testing compare alt format in if statement
            tp = new Template("$if((bob eq fred))$Bob is Fred$else$Bob is not Fred$endif$");
            tp.SetParameter("bob", "bob");
            tp.SetParameter("fred", "bob");
            if (tp.ToString() != "Bob is Fred")
            {
                Console.WriteLine("Basic if test using equal function inside failed with result: " + tp.ToString());
                return false;
            }

            //testing odd function
            tp = new Template("$if(odd(world))$OddBall$else$NotWeird$endif$");
            tp.SetAttribute("world", "1");
            Console.WriteLine(tp.ToString());
            tp.RemoveParameter("world");
            tp.SetAttribute("world", "hello");
            Console.WriteLine(tp.ToString());
            tp.RemoveParameter("world");
            tp.SetAttribute("world", "2");
            Console.WriteLine(tp.ToString());

            return true;
        }