1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace InABox.Poster.Custom;
- public class CustomPosterSettings : PosterSettings
- {
- public override string DefaultScript(Type TPostable)
- {
- var tName = TPostable.Name;
- var decapital = tName[0..1].ToLower() + tName[1..];
- var ns = TPostable.Namespace;
- return @"
- using " + ns + @";
- using InABox.Core;
- using System.Collections.Generic;
- public class Module
- {
- // Output Results
- public IPostResult<" + tName + @"> Results { get; set; }
- // Customise 'model' before loading data. Return false if the post needs to be cancelled.
- public bool BeforePost(IDataModel<" + tName + @"> model)
- {
- return true;
- }
- public bool Process(IDataModel<" + tName + @"> model)
- {
- Results = new PostResult<" + tName + @">();
- foreach(var " + decapital + @" in model.GetTable<" + tName + @">().ToObjects<" + tName + @">())
- {
- // Do processing
- Results.AddSuccess(decapital);
- }
- return true; // return true for success.
- }
- // Perform any post-processing. All the items of type '" + tName + @" will be saved after this function is called.
- public void AfterPost(IDataModel<" + tName + @"> model)
- {
- }
- }";
- }
- }
|