public static T4ParameterDescription FromDirective([NotNull] IT4Directive directive)
        {
            var    typeToken = directive.GetAttributeValueToken(T4DirectiveInfoManager.Parameter.TypeAttribute.Name);
            string typeText  = typeToken?.GetText();
            var    nameToken = directive.GetAttributeValueToken(T4DirectiveInfoManager.Parameter.NameAttribute.Name);
            string nameText  = nameToken?.GetText();

            if (string.IsNullOrEmpty(typeText))
            {
                return(null);
            }
            if (string.IsNullOrEmpty(nameText))
            {
                return(null);
            }
            return(new T4ParameterDescription(typeToken, nameToken, nameText));
        }
Example #2
0
        public static Pair <IT4Token, string> GetAttributeValueIgnoreOnlyWhitespace([CanBeNull] this IT4Directive directive, [CanBeNull] string attributeName)
        {
            IT4Token valueToken = directive.GetAttributeValueToken(attributeName);

            if (valueToken == null)
            {
                return(new Pair <IT4Token, string>());
            }

            string value = valueToken.GetText();

            if (value.Trim().Length == 0)
            {
                return(new Pair <IT4Token, string>());
            }

            return(new Pair <IT4Token, string>(valueToken, value));
        }
Example #3
0
        public static Pair <IT4TreeNode, string> GetAttributeValueIgnoreOnlyWhitespace(
            [NotNull] this IT4Directive directive,
            [NotNull] string attributeName
            )
        {
            var valueToken = directive.GetAttributeValueToken(attributeName);

            if (valueToken == null)
            {
                return(new Pair <IT4TreeNode, string>());
            }

            string value = valueToken.GetText();

            if (value.IsNullOrWhitespace())
            {
                return(new Pair <IT4TreeNode, string>());
            }

            return(new Pair <IT4TreeNode, string>(valueToken, value));
        }
Example #4
0
 public static string GetAttributeValue([CanBeNull] this IT4Directive directive, [CanBeNull] string attributeName)
 => directive.GetAttributeValueToken(attributeName)?.GetText();
Example #5
0
        public static string GetAttributeValue([CanBeNull] this IT4Directive directive, [CanBeNull] string attributeName)
        {
            IT4Token token = directive.GetAttributeValueToken(attributeName);

            return(token != null?token.GetText() : null);
        }