예제 #1
0
            private void ValidateOneCore(IMarkdownToken token, Match m, MarkdownTagValidationRule validator)
            {
                switch (validator.Behavior)
                {
                case TagValidationBehavior.Warning:
                    Logger.LogWarning(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.SourceInfo.Markdown), line: token.SourceInfo.LineNumber.ToString());
                    return;

                case TagValidationBehavior.Error:
                    Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.SourceInfo.Markdown), line: token.SourceInfo.LineNumber.ToString());
                    return;

                case TagValidationBehavior.None:
                default:
                    return;
                }
            }
예제 #2
0
            private void ValidateOneCore(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator)
            {
                switch (validator.Behavior)
                {
                case TagValidationBehavior.Warning:
                    Logger.LogWarning(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown));
                    return;

                case TagValidationBehavior.Error:
                    Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown));
                    return;

                case TagValidationBehavior.None:
                default:
                    return;
                }
            }
예제 #3
0
 private void ValidateOne(IMarkdownToken token, Match m, MarkdownTagValidationRule validator)
 {
     if (!string.IsNullOrEmpty(validator.CustomValidatorContractName))
     {
         if (Container == null)
         {
             Logger.LogWarning($"Unable to validate tag by contract({validator.CustomValidatorContractName}): CompositionHost is null.");
             return;
         }
         var customValidators = GetCustomMarkdownTagValidators(validator);
         if (customValidators.Count == 0)
         {
             Logger.LogWarning($"Cannot find custom markdown tag validator by contract name: {validator.CustomValidatorContractName}.");
             return;
         }
         if (customValidators.TrueForAll(av => av.Validate(token.SourceInfo.Markdown)))
         {
             return;
         }
     }
     ValidateOneCore(token, m, validator);
 }
예제 #4
0
 private List <ICustomMarkdownTagValidator> GetCustomMarkdownTagValidators(MarkdownTagValidationRule validator)
 {
     return(Container
            ?.GetExports <ICustomMarkdownTagValidator>(validator.CustomValidatorContractName)
            .Cast <ICustomMarkdownTagValidator>()
            .ToList());
 }
예제 #5
0
 private List <ICustomMarkdownTagValidator> GetCustomMarkdownTagValidators(MarkdownTagValidationRule validator)
 {
     return(CompositionHost
            .GetExports(typeof(ICustomMarkdownTagValidator), validator.CustomValidatorContractName)
            .Cast <ICustomMarkdownTagValidator>()
            .ToList());
 }
예제 #6
0
 private void ValidateOneCore(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator)
 {
     switch (validator.Behavior)
     {
         case TagValidationBehavior.Warning:
             Logger.LogWarning(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown));
             return;
         case TagValidationBehavior.Error:
             Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown));
             return;
         case TagValidationBehavior.None:
         default:
             return;
     }
 }
예제 #7
0
 private List<ICustomMarkdownTagValidator> GetCustomMarkdownTagValidators(MarkdownTagValidationRule validator)
 {
     return CompositionHost
         .GetExports(typeof(ICustomMarkdownTagValidator), validator.CustomValidatorContractName)
         .Cast<ICustomMarkdownTagValidator>()
         .ToList();
 }
예제 #8
0
 private void ValidateOne(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator)
 {
     if (!string.IsNullOrEmpty(validator.CustomValidatorContractName))
     {
         if (CompositionHost == null)
         {
             Logger.LogWarning($"Unable to validate tag by contract({validator.CustomValidatorContractName}): CompositionHost is null.");
             return;
         }
         var customValidators = GetCustomMarkdownTagValidators(validator);
         if (customValidators.Count == 0)
         {
             Logger.LogWarning($"Cannot find custom markdown tag validator by contract name: {validator.CustomValidatorContractName}.");
             return;
         }
         if (customValidators.TrueForAll(av => av.Validate(token.RawMarkdown)))
         {
             return;
         }
     }
     ValidateOneCore(token, m, validator);
 }