/// <summary> /// Called when the logic sheets are checked for correctness, in order to check /// this node's correct configuration. /// </summary> /// <param name="language"> /// The language key which is used for localizing the validation message. /// </param> /// public override sealed ValidationResult Validate(string language) { mLanguage = language; // memorize for localization in Execute ValidationResult result = validateSeparators(language); if (result.HasError) { return(result); } TemplateTokenFactory ttf = TemplateTokenFactory.Instance; ttf.restart(); foreach (var template in mTemplates) { result = validateTemplate(template, language, doFullCheck: true); if (result.HasError) { return(result); } int binCountDummy = 0; int intCountDummy = 0; int numCountDummy = 0; int strCountDummy = 0; List <TokenBase> localTokensDummy = new List <TokenBase>(10); result = validateInternal(template, ref localTokensDummy, ref binCountDummy, ref intCountDummy, ref numCountDummy, ref strCountDummy, language, doFullCheck: true); if (result.HasError) { return(result); } } return(base.Validate(language)); }
/// <summary> /// Called when the logic sheets are checked for correctness, in order to check /// this node's correct configuration. /// </summary> /// <param name="language"> /// The language key which is used for localizing the validation message. /// </param> /// public override sealed ValidationResult Validate(string language) { TemplateTokenFactory ttf = TemplateTokenFactory.Instance; ttf.restart(); foreach (var template in mTemplates) { int binCountDummy = 0; int intCountDummy = 0; int numCountDummy = 0; int strCountDummy = 0; List <TokenBase> localTokens = new List <TokenBase>(10); ValidationResult result = validateInternal(template, ref localTokens, ref binCountDummy, ref intCountDummy, ref numCountDummy, ref strCountDummy, language); if (result.HasError) { return(result); } } return(base.Validate(language)); }
/// <summary> /// This method has been added as a ValueSet handler to the template /// parameters. It will therefore be called whenever a template string /// is edited, in order to update the tokens and inputs. /// </summary> private void updateTemplate(object sender = null, ValueChangedEventArgs evArgs = null) { // Even though only one template has changed we must re-evaluate all // templates, because these depend on each other because of their // placeholder re-use. TemplateTokenFactory ttf = TemplateTokenFactory.Instance; ttf.restart(); int binCount = 0; int intCount = 0; int numCount = 0; int strCount = 0; List <TokenBase> allTokens = new List <TokenBase>(100); for (int i = 0; i < mTemplates.Count; i++) { // Check parameter. // Along the way fill mTemplateTokens and count numbers of inputs List <TokenBase> localTokens = new List <TokenBase>(10); ValidationResult res = validateInternal(mTemplates[i], ref localTokens, ref binCount, ref intCount, ref numCount, ref strCount, "en"); if (res.HasError) { return; } mTokensPerTemplate[i] = localTokens; allTokens.AddRange(localTokens); } // Update the input counts if successful mBinInputCount.Value = binCount; mIntInputCount.Value = intCount; mNumInputCount.Value = numCount; mStrInputCount.Value = strCount; int binIdx = 0; int intIdx = 0; int numIdx = 0; int strIdx = 0; foreach (TokenBase token in allTokens) { if (token is VarTokenBase varToken) { switch (varToken.getType()) { case TokenType.VarBoolean: mBinInputs[binIdx].Name = varToken.getName(); varToken.setInput(mBinInputs[binIdx]); binIdx++; break; case TokenType.VarInteger: mIntInputs[intIdx].Name = varToken.getName(); varToken.setInput(mIntInputs[intIdx]); intIdx++; break; case TokenType.VarNumber: mNumInputs[numIdx].Name = varToken.getName(); varToken.setInput(mNumInputs[numIdx]); numIdx++; break; case TokenType.VarString: mStrInputs[strIdx].Name = varToken.getName(); varToken.setInput(mStrInputs[strIdx]); strIdx++; break; default: // Nothing to do break; } } } updateTemplateHelpers(); }