/// <summary> /// Run the application. /// </summary> public override BoolMessageItem Execute() { // 1. Macro service loads classes with attribute "MacroAttribute" and of type IMacro. var macros = new MacroService(); // 2. Register Option 1: Load macro extensions from dll "CommonLibrary" macros.Load("CommonLibrary"); // 3. Register Option 2: Programmactically with macro attributes. macros.Register(new MacroAttribute() { Name = "helloworld" }, new MacroParameterAttribute[] { new MacroParameterAttribute() { Name = "language" } }, (tag) => "hello world using tag: " + tag.Name + ", " + tag.InnerContent); // 3. Register Option 3: Programmactically with simple api. macros.Register("helloworld2", "", "Simple hello world macro", (tag) => "hello world 2 : "); // 4. Now build the content by processing the macros var content = macros.BuildContent(_macroSampleText1); // 5. Render content that has a lamda based macro in it. // NOTE: Render content that has multiple macros involves the same method call. var content2 = macros.BuildContent(_macroSampleText2); return(BoolMessageItem.True); }
public void CanProcess() { var service = new MacroService("$", "[", "]"); service.Load("CommonLibrary.Web.Modules.Tests"); var result = service.BuildContent(@"testing $[hello name=""kishore""]commonlibrary.net.cms[/hello]"); Assert.AreEqual(result, "hello name: kishore, message: commonlibrary.net.cms"); }
public void CanLoad() { var service = new MacroService(); service.Load("CommonLibrary.Web.Modules.Tests"); var macro = service.Create("hello"); Assert.IsTrue(service.Lookup.Count == 1); Assert.IsNotNull(macro); }
public void CanProcessSimple() { var service = new MacroService(Char.MinValue, '[', ']'); service.Load(ContentLoader.TestDllName); var result = service.BuildContent("[hello]kishore[/hello]"); Assert.AreEqual(result, "hello name: kishore"); }
public void CanProcessViaLoad() { var service = new MacroService('$', '[', ']'); service.Load(ContentLoader.TestDllName); var result = service.BuildContent(@"testing $[hello name=""kishore""]commonlibrary.net.cms[/hello]"); Assert.AreEqual(result, "testing hello name: kishore, message: commonlibrary.net.cms"); }
public void CanLoad() { var service = new MacroService(); service.Load(ContentLoader.TestDllName); var macro = service.Create("hello"); Assert.IsTrue(service.Lookup.Count == 1); Assert.IsNotNull(macro); }