123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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)
- {
- }
- }";
- }
- }
- }
|