public TestScriptClassTemplate(ITestApi testApi) { Usings.Add("System"); Usings.Add("System.Linq"); Usings.Add("System.Threading.Tasks"); ImplementsInterfaces.Add(nameof(ITextScript)); Members.AddRawContent("$$code$$"); Injections.AddProperty("Api", () => testApi); Members.AddMethod("CallApi", "Api.DoSomething(\"Call\");"); Members.AddProperty("TestText", "string", "return \"SomeText\";", "Api.DoSomething(value);"); Members.AddProperty("IntValue", "int", "return 12345;"); }
public ActionScriptClassTemplate(IClassFactory classFactory) { Usings.Add("System"); Usings.Add("System.Linq"); Usings.Add("System.Threading.Tasks"); Usings.Add("CreativeCoders.SmartHal.Kernel.Base.Items"); Usings.Add("CreativeCoders.SmartHal.Kernel.Base.Items.DataTypes"); Usings.Add("CreativeCoders.SmartHal.Scripting.ActionScripts"); Usings.Add("CreativeCoders.SmartHal.Scripting.Base.Api"); Usings.Add("CreativeCoders.SmartHal.Scripting.Base.ActionScripts.Triggers"); Usings.Add("CreativeCoders.SmartHal.Scripting.Base.ActionScripts"); ImplementsInterfaces.Add(nameof(IActionScriptObject)); Members.AddRawContent("$$code$$"); Injections.AddProperty("Items", classFactory.Create <IItemsScriptApi>); Injections.AddProperty("Trigger", classFactory.Create <ITriggerApi>); Members.AddRawContent("public IItemApi Item(string itemName) => Items.GetItem(itemName);"); }