Ejemplo n.º 1
0
        private bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
        {
            if (entry == null)
            {
                return(false);
            }

            var stringValue = entry as string;

            if (stringValue != null)
            {
                // Do not encode the string because encoded value remains whitespace from user's POV.
                if (!string.IsNullOrWhiteSpace(stringValue))
                {
                    return(false);
                }
            }
            else
            {
                // Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
                ((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);
                if (!writer.IsEmptyOrWhiteSpace)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
        {
            if (entry == null)
            {
                return(false);
            }

            var stringValue = entry as string;

            if (stringValue != null)
            {
                if (!string.IsNullOrWhiteSpace(stringValue))
                {
                    return(false);
                }
            }
            else
            {
                ((IHtmlContent)entry).WriteTo(writer, HtmlEncoder.Default);
                if (!writer.IsEmptyOrWhiteSpace)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
    private static bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
    {
        if (entry == null)
        {
            return(true);
        }

        if (entry is string stringValue)
        {
            // Do not encode the string because encoded value remains whitespace from user's POV.
            return(string.IsNullOrWhiteSpace(stringValue));
        }

        // Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
        ((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);

        return(writer.IsEmptyOrWhiteSpace);
    }
Ejemplo n.º 4
0
        private bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
        {
            if (entry == null)
            {
                return false;
            }

            var stringValue = entry as string;
            if (stringValue != null)
            {
                // Do not encode the string because encoded value remains whitespace from user's POV.
                if (!string.IsNullOrWhiteSpace(stringValue))
                {
                    return false;
                }
            }
            else
            {
                // Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
                ((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);
                if (!writer.IsEmptyOrWhiteSpace)
                {
                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 5
0
        private bool IsEmptyOrWhiteSpaceCore(object entry, EmptyOrWhiteSpaceWriter writer)
        {
            if (entry == null)
            {
                return false;
            }

            var stringValue = entry as string;
            if (stringValue != null)
            {
                if (!string.IsNullOrWhiteSpace(stringValue))
                {
                    return false;
                }
            }
            else
            {
                ((IHtmlContent)entry).WriteTo(writer, HtmlEncoder.Default);
                if (!writer.IsEmptyOrWhiteSpace)
                {
                    return false;
                }
            }

            return true;
        }