public static NSAttributedString ToAttributedString(
            this NoEntityInfoMessage noEntityInfoMessage,
            nfloat fontCapHeight)
        {
            if (string.IsNullOrEmpty(noEntityInfoMessage.ImageResource))
            {
                return(new NSAttributedString(noEntityInfoMessage.Text));
            }

            var result            = new NSMutableAttributedString(noEntityInfoMessage.Text);
            var rangeToBeReplaced = new NSRange(
                noEntityInfoMessage
                .Text
                .IndexOf(noEntityInfoMessage.CharacterToReplace.Value),
                len: 1);
            var imageAttachment = noEntityInfoMessage
                                  .ImageResource
                                  .GetAttachmentString(
                fontCapHeight,
                UIImageRenderingMode.AlwaysOriginal);

            result.Replace(rangeToBeReplaced, imageAttachment);

            return(result);
        }
        private IList <SectionModel <string, AutocompleteSuggestion> > addStaticElements(IEnumerable <SectionModel <string, AutocompleteSuggestion> > sections)
        {
            var suggestions = sections.SelectMany(section => section.Items);
            IEnumerable <SectionModel <string, AutocompleteSuggestion> > collections = sections;

            if (isSuggestingProjects.Value)
            {
                if (shouldAddProjectCreationSuggestion())
                {
                    sections = sections
                               .Prepend(
                        SectionModel <string, AutocompleteSuggestion> .SingleElement(
                            new CreateEntitySuggestion(Resources.CreateProject, currentQuery)
                            )
                        );
                }

                if (!hasAnyProjects)
                {
                    sections = sections.Append(SectionModel <string, AutocompleteSuggestion> .SingleElement(
                                                   NoEntityInfoMessage.CreateProject())
                                               );
                }
            }

            if (isSuggestingTags.Value)
            {
                if (shouldAddTagCreationSuggestion())
                {
                    sections = sections
                               .Prepend(
                        SectionModel <string, AutocompleteSuggestion> .SingleElement(
                            new CreateEntitySuggestion(Resources.CreateTag, currentQuery)
                            )
                        );
                }

                if (!hasAnyTags)
                {
                    sections = sections.Append(SectionModel <string, AutocompleteSuggestion> .SingleElement(
                                                   NoEntityInfoMessage.CreateTag())
                                               );
                }
            }

            return(sections.ToList());

            bool shouldAddProjectCreationSuggestion()
            => canCreateProjectsInWorkspace && !textFieldInfo.Value.HasProject &&
            currentQuery.LengthInBytes() <= MaxProjectNameLengthInBytes &&
            !string.IsNullOrEmpty(currentQuery);

            bool shouldAddTagCreationSuggestion()
            => !string.IsNullOrEmpty(currentQuery) && currentQuery.IsAllowedTagByteSize() &&
            suggestions.None(item =>
                             item is TagSuggestion tagSuggestion &&
                             tagSuggestion.Name.IsSameCaseInsensitiveTrimedTextAs(currentQuery));
        }