Example #1
0
        public SemanticResultValue(string phrase, object value)
        {
            Helpers.ThrowIfEmptyOrNull(phrase, nameof(phrase));
            Helpers.ThrowIfNull(value, nameof(value));

            _tag = new TagElement(new GrammarBuilderPhrase(phrase), value);
        }
        public override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode)
        {
            /*Criando os options...*/
            string options = "";

            TagBuilder option;

            foreach (SelectListItem item in this.selectListItems)
            {
                option = new TagBuilder("input");
                option.AddInputAttributeStaticValue("type", "radio");
                option.AddInputAttributeStaticValue("name", this.ComponentBase.SanitizedId);
                if (this.Value != null && (item.Value.ToString().Trim() == this.Value.ToString().Trim()))
                {
                    option.MergeAttribute("checked", null);
                }
                option.MergeAttribute("value", item.Value.ToString());
                option.MergeAttribute("data-value", item.Value.ToString());
                if (item.Disabled)
                {
                    option.MergeAttribute("disabled", null);
                }
                option.SetInnerText($" {item.Text}");
                options += option.ToString(TagRenderMode.Normal) + "\n";
            }

            TagElement.InnerHtml = options;

            return(TagElement.ToMvcHtmlString(TagRenderMode.Normal));
        }
        public TagBuilder_TextArea(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("textarea", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeIsNotNull("type", CustomAttributesHelpers.ConvertDataTypeToHtmlType((DataType)this.ComponentBase.MetadataAttributes.GetValue <DataType>("DataType", "DataType"), this.ComponentBase.FieldType));
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("OnlyNumber", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("NoEspecialChars", "ClassDecorator"));
            TagElement.AddInputAttributeIsNotNull("cols", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Cols"));
            TagElement.AddInputAttributeIsNotNull("rows", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Rows"));
            TagElement.AddInputAttributeIsNotNull("wrap", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "Wrap"));
            TagElement.AddInputAttributeIsNotNull("minlength", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "MinLength"));
            TagElement.AddInputAttributeIsNotNull("maxlength", this.ComponentBase.MetadataAttributes.GetValue <object>("TextArea", "MaxLength"));

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("type", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("cols", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("rows", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("wrap", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
            TagElement.InnerHtml = this.Value?.ToString();
        }
Example #4
0
        private void TryCreateTokenAndAddToList(string text, TagElement element,
                                                List <TagElement> tagsCandidates, List <Token> tokens)
        {
            if (element.TagUsability == TagUsability.Start)
            {
                tagsCandidates.Add(element);
                return;
            }

            var token = TryCreateUsableToken(text, element, tagsCandidates);

            if (token == null)
            {
                if (element.TagUsability == TagUsability.All)
                {
                    tagsCandidates.Add(element);
                }
                else
                {
                    tokens.Add(CreateTextToken(text, element.StartIndex, element.Length));
                }
            }
            else
            {
                DeleteOtherNestedTokens(tokens, token);
                tokens.Add(token);
            }
        }
Example #5
0
        public SemanticResultValue(GrammarBuilder builder, object value)
        {
            Helpers.ThrowIfNull(builder, nameof(builder));
            Helpers.ThrowIfNull(value, nameof(value));

            _tag = new TagElement(builder.Clone(), value);
        }
Example #6
0
        public TagBuilder_Progress(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("progress", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            //TagElement.DeleteValueInAttribute("class", "form-control");
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            double?maxValue = this.ComponentBase.MetadataAttributes.GetValue <double>("ProgressAttribute", "MaxValue");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("max", maxValue, maxValue != null);
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("value", this.Value, this.Value != null);
        }
Example #7
0
        public TagBuilder_Password(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("input", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeStaticValue("type", "password");
            int?minimumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Minimum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MinimumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("minlength", minimumLength, minimumLength.HasValue && minimumLength.Value > 0);
            int?maximumLength = (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("Maximum", "Length") ?? (int?)this.ComponentBase.MetadataAttributes.GetValue <DataType>("StringLength", "MaximumLength");

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("maxlength", maximumLength, maximumLength.HasValue && maximumLength.Value > 0);
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("OnlyNumber", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("Currency", "ClassDecorator"));
            TagElement.MergeInputAttributeIsNotNull("pattern", this.ComponentBase.MetadataAttributes.GetValue <object>("Currency", "Pattern"));
            TagElement.MergeInputAttributeIsNotNull("class", this.ComponentBase.MetadataAttributes.GetValue <object>("NoEspecialChars", "ClassDecorator"));

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("minlength", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("maxlength", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
        }
Example #8
0
        public override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode)
        {
            /*Criando os options...*/
            string options = "";

            TagBuilder option;

            if (this.optionLabel != null)
            {
                option = new TagBuilder("option");
                option.SetInnerText(this.optionLabel.Text);
                options += option.ToString(TagRenderMode.Normal) + "\n";
            }

            foreach (SelectListItem item in this.selectListItems)
            {
                option = new TagBuilder("option");
                if (this.Value != null && (item.Value.ToString().Trim() == this.Value.ToString().Trim()))
                {
                    option.MergeAttribute("selected", null);
                }
                option.MergeAttribute("value", item.Value.ToString());
                option.MergeAttribute("data-value", item.Value.ToString());
                if (item.Disabled)
                {
                    option.MergeAttribute("disabled", null);
                }
                option.SetInnerText(item.Text);
                options += option.ToString(TagRenderMode.Normal) + "\n";
            }

            TagElement.InnerHtml = options;

            return(TagElement.ToMvcHtmlString(TagRenderMode.Normal));
        }
Example #9
0
        private Token TryCreateUsableToken(string text, TagElement endTag, List <TagElement> startTags)
        {
            if (startTags.Count == 0)
            {
                return(null);
            }

            var candidateIndex = startTags.Count - 1;

            while (startTags[candidateIndex].Type != endTag.Type)
            {
                if (candidateIndex == 0)
                {
                    return(null);
                }
                candidateIndex--;
            }

            var startTag = startTags[candidateIndex];

            if (startTag.EndIndex + 1 == endTag.StartIndex)
            {
                return(null);
            }

            startTags.RemoveRange(candidateIndex, startTags.Count - candidateIndex);
            return(CreateTokenFromTags(text, startTag, endTag));
        }
 public TagBuilder_RadioGroup(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
     : base("fieldset", dynamicComponentBase)
 {
     /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
     TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
     TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);
 }
Example #11
0
        private static Token CreateTokenFromTags(string text, TagElement startTag, TagElement endTag)
        {
            var startSubstrIndex = startTag.EndIndex + 1;
            var substrLength     = endTag.StartIndex - startTag.EndIndex - 1;

            var tagText = text.Substring(startSubstrIndex, substrLength);

            return(new Token(tagText, endTag.Type, startTag.StartIndex, endTag.EndIndex));
        }
Example #12
0
        public TagBuilder_Select(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("select", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
        }
        private void InicializeTagElement()
        {
            this.TagElement = new TagBuilder(TagElementType);
            //TagElement.GenerateId(fieldFullName);
            TagElement.AddInputAttributeIsNotNull("id", this.ComponentBase.SanitizedId);
            TagElement.AddInputAttributeIsNotNull("name", this.ComponentBase.FieldFullName);

            //...............................................................................................................................................................\\
            bool _IsRequired = !this.ComponentBase.FieldIsNullable || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsRequired");

            if (_IsRequired)
            {
                TagElement.AddInputAttributeStaticValue("required", null);
            }
            bool _IsNullable = this.ComponentBase.FieldIsNullable || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsNullable") || this.ComponentBase.MetadataAttributes.GetValue <bool>("Common", "IsNullableValueType");

            //...............................................................................................................................................................\\


            /* Adicionar os atributos de acordo com o que for obtido no MetaData... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeStaticValue("class", "form-control");
            TagElement.AddInputAttributeIsNotNull("autofocus", this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Autofocus"));
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("required", null, (bool)this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "IsRequired"));
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("readonly", null, this.ComponentBase.FieldIsReadOnly || (bool)this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "IsReadOnly"));
            TagElement.AddInputAttributeIsNotNull("title", this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Description"));
            TagElement.AddInputAttributeIsNotNull("placeholder", this.ComponentBase.MetadataAttributes.GetValue <object>("PlaceHolder", "Text") ?? this.ComponentBase.MetadataAttributes.GetValue <object>("Common", "Watermark"));

            //...............................................................................................................................................................\\

            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("required", null, !this.ComponentBase.FieldIsNullable);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("readonly", null, this.ComponentBase.FieldIsReadOnly);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("disabled", null, this.ComponentBase.FieldIsDisabled);

            //...............................................................................................................................................................\\

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.AddInputAttributeHtmlAttributes("autofocus", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("required", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("readonly", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("disabled", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("title", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("placeholder", this.ComponentBase.HtmlAttributes);

            //...............................................................................................................................................................\\

            /* Adicionar os atributos de acordo com o que for obtido no Data-Val... */
            //TagElement.AddInputAttributeStaticValue("data-val", "true");
            TagElement.AddInputAttributeIsNotNull("data-val-required", this.ComponentBase.MetadataAttributes.GetValue <object>("Required", "ErrorMessage"));
            //TagElement.AddInputAttributeStaticValue("data-val-regex-pattern", "");
            //TagElement.AddInputAttributeStaticValue("data-val-regex", "");

            this.Value = this.ComponentBase.FieldValue;
        }
Example #14
0
        public TagBuilder_Checkbox(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base(CustomAttributesHelpers.GetInputElementTypeByDataType((DataType)dynamicComponentBase.MetadataAttributes.GetValue <DataType>("DataType", "DataType")), dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            TagElement.AddInputAttributeStaticValue("type", "checkbox");

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
        }
        private static string GetTagValue(CompositeTag Tags, string key)
        {
            String     tempValue = null;
            TagElement tempTag   = null;

            tempTag = Tags.FindTag(key);
            if (tempTag == null)
            {
                return(null);
            }
            else
            {
                return(tempTag.TryGetAttributeValueAt("value"));
            }
        }
        public TagBuilder_Range(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase)
            : base("input", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com o que for obtido no Metadata... */
            //TagElement.AddInputTypeAttribute(fieldType);
            TagElement.AddInputAttributeIsNotNull("type", "range");
            TagElement.AddInputAttributeIsNotNull("min", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "MinValue"));
            TagElement.AddInputAttributeIsNotNull("max", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "MaxValue"));
            TagElement.AddInputAttributeIsNotNull("step", this.ComponentBase.MetadataAttributes.GetValue <double>("Progress", "Step"));

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.MergeInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.MergeInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            this.Value = this.ComponentBase.FieldValue;
            TagElement.AddInputAttributeIsNotNull("value", this.Value);
        }
        private Task <(TaskReturnKind, TagElement?)> CreateTags()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Input tag:");
            string tag = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(tag))
            {
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("Tag cant be empty try again!");
                return(Task.FromResult((TaskReturnKind.Continue, (TagElement?)null)));
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Replace text:");
            string text = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(text))
            {
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("Replace text cant be empty try again!");
                return(Task.FromResult((TaskReturnKind.Continue, (TagElement?)null)));
            }

            Console.WriteLine($"Tag {tag}");
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine($"Replace text {text}");
            Console.WriteLine(Environment.NewLine);

            var element = new TagElement($"{tag}", text);

            Console.WriteLine("Continue creating tags y/n?");
            string response = Console.ReadLine();

            if (response == "y")
            {
                return(Task.FromResult((TaskReturnKind.Continue, (TagElement?)element)));
            }

            return(Task.FromResult((TaskReturnKind.Exit, (TagElement?)element)));
        }
        public TagBuilder_Label(DynamicComponentBaseFor <TModel, TProperty> dynamicComponentBase, string id, string caption, string forInput, string tooltip = null)
            : base("label", dynamicComponentBase)
        {
            /* Adicionar os atributos de acordo com os parĂ¢metros informados... */
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("id", id ?? $"label.{forInput}", (id ?? $"label.{forInput}") != null);
            TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("for", forInput, forInput != null);
            if (tooltip != null && !string.IsNullOrEmpty(tooltip))
            {
                TagElement.AddInputAttributeStaticValue("data-toggle", "tooltip");
                TagElement.AddInputAttributeStaticValue("data-placement", "top");
                TagElement.AddInputAttributeIsNotNullAndExpressionIsTrue("data-original-title", tooltip, tooltip != null);
            }

            /* Adicionar os atributos de acordo com o que for obtido no HtmlAttributes... */
            TagElement.AddInputAttributeHtmlAttributes("class", this.ComponentBase.HtmlAttributes);
            TagElement.AddInputAttributeHtmlAttributes("style", this.ComponentBase.HtmlAttributes);

            /* Injetando o Valor no Input... */
            TagElement.InnerHtml = caption;
        }
        public static void InitialDatabaseConfigs(string dbConfigFile)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("~/DBHelper.config");
            IEbfConfig   dbConfigs     = ConfigFactory.GetConfigOf(dbConfigFile);
            TagElement   rootTag       = dbConfigs.RootTag;
            CompositeTag dataSourceTag = (CompositeTag)dbConfigs.FindTag("dblinks");

            GetDataSource(dataSourceTag);
            BrokerFactory.InitDataSource(DataSourceList);
            if (rootTag is CompositeTag)
            {
                foreach (CompositeTag dbConfig in ((CompositeTag)rootTag).SubTags)
                {
                    if (!dbConfig.Name.Equals("dslist"))
                    {
                        InitalizeDatabaseConfig(dbConfig);
                    }
                }
            }
        }
Example #20
0
 public SemanticResultValue(string phrase, object value)
 {
     Helpers.ThrowIfEmptyOrNull(phrase, "phrase");
     Helpers.ThrowIfNull(value, "value");
     _tag = new TagElement(new GrammarBuilderPhrase((string)phrase.Clone()), value);
 }
Example #21
0
        public SemanticResultValue(object value)
        {
            Helpers.ThrowIfNull(value, nameof(value));

            _tag = new TagElement(value);
        }
 public override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode)
 {
     return(TagElement.ToMvcHtmlString(renderMode));
 }
Example #23
0
        public static bool TryToGetUsableTagInAssociations(string text, int startIndex, out TagElement resultTag)
        {
            if (text == null)
            {
                throw new NullReferenceException("text can't be null");
            }

            if (startIndex < 0 || startIndex >= text.Length)
            {
                throw new ArgumentOutOfRangeException($"{nameof(startIndex)} not included in the array bounds");
            }

            var parseVariants = new List <(TagElement tag, int priority)>();
            var substrLength  = 1;

            while (substrLength <= MaximumTagLength && substrLength + startIndex <= text.Length)
            {
                var key = text.Substring(startIndex, substrLength);
                if (TagAssociations.ContainsKey(key))
                {
                    var(type, priority) = TagAssociations[key];
                    var tagUsability = GetTagUsability(text, startIndex, startIndex + substrLength - 1, type);

                    if (tagUsability != TagUsability.None)
                    {
                        parseVariants.Add((new TagElement(type, tagUsability, startIndex, substrLength), priority));
                    }
                }
                substrLength++;
            }

            if (parseVariants.Count == 0)
            {
                resultTag = null;
                return(false);
            }

            resultTag = parseVariants.OrderByDescending(x => x.priority).First().tag;
            return(true);
        }