StringSet

Namespace: Irony
We found 10 examples in language CSharp for this search. You will see 16 fragments of code.

Other methods

        [Test]
        public void Create()
        {
            StringSet ss = new StringSet();
            Assert.AreEqual(0, ss.Count);
            Assert.AreEqual("", ss.ToString());
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Null()
        {
            StringSet ss = new StringSet();
            ss.Add((string)null);
        }
        
        [Test]
        public void Empty()
        {
            StringSet ss = new StringSet(new string[] { "" });
            Assert.AreEqual(1, ss.Count);
            ss = new StringSet((string[])null);
            Assert.AreEqual(0, ss.Count);
        }


        /// <summary>
        /// Add all of the strings from the given set to this set.
        /// </summary>
        /// <param name="set"></param>
        public void Add(StringSet set)
        {
            // Lengthen this one to be able to hold everything in the other set, as well.
            m_bits.Length = set.m_bits.Length = Math.Max(m_bits.Length, set.m_bits.Length);
            m_bits.Or(set.m_bits);
        }

        /// <summary>
        /// Remove all of the strings from the given set from this set.
        /// </summary>
        /// <param name="set"></param>
        public void Remove(StringSet set)
        {
            m_bits.Length = set.m_bits.Length = Math.Max(m_bits.Length, set.m_bits.Length);
            // Not is destructive.  Stupid.
            BitArray os = (BitArray)set.m_bits.Clone();
            os.Not();
            m_bits.And(os);
        }

        #endregion

        #region ICloneable Members

        /// <summary>
        /// Return a copy of this set.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return new StringSet(this);
        }

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}



		/* Function: Equals
		 */
		public override bool Equals (object other)
			{
			if (other == null || !(other is StringSet))
				{  return false;  }
			else
				{  return (this == (StringSet)other);  }
			}
		/* Function: ReadStringSet
		 * An extension method to <BinaryFile> which reads a string set from it.  Call with
		 * "stringSet = binaryFile.ReadStringSet(ignoreCase, normalizeUnicode);"
		 */
		static public StringSet ReadStringSet (this BinaryFile binaryFile, KeySettings keySettings = KeySettings.Literal)
			{
			StringSet stringSet = new StringSet(keySettings);
			stringSet.ReadFrom(binaryFile);
			return stringSet;
			}

		/* Function: WriteStringSet
		 * An extension method to <BinaryFile> which writes the string set to it.  Call with "binaryFile.WriteStringSet(stringSet);"
		 */
		static public void WriteStringSet (this BinaryFile binaryFile, StringSet stringSet)
			{
			stringSet.WriteTo(binaryFile);
			}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.TestCommon;

namespace System.Web.Mvc.Html.Test
{
    public static class EncodedDataSets
    {
        private static readonly List<StringSet> StringSets = new List<StringSet>
        {
            // Needs extra URL-escaping due to routing special cases.
            new StringSet("&'\"", "&amp;&#39;&quot;", "&amp;&#39;&quot;", "___", "%26&#39;%22"),

            // High ASCII
            new StringSet(" ¡ÿĀ", " ¡ÿĀ", "&#160;&#161;&#255;Ā", "____"),

            // Surrogate pair, Ugaritic letter beta, &x10381;
            new StringSet("\xD800\xDF81", "𐎁", "&#66433;", "__"),

            new StringSet(
                "<blink>text</blink>",
                "&lt;blink>text&lt;/blink>",
                "&lt;blink&gt;text&lt;/blink&gt;",
                "_blink_text__blink_"),

            // Remaining examples are only id-sanitized, not attribute- or HTML-encoded.
            new StringSet("Simple Display Text", "Simple Display Text", "Simple Display Text", "Simple_Display_Text"),
            new StringSet("Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese西雅图Chars", "Chinese___Chars"), // Seattle
            new StringSet(
                "Unicode؃Format؃Char", // class Cf
                "Unicode؃Format؃Char",
                "Unicode؃Format؃Char",
                "Unicode_Format_Char"),
            new StringSet(
                "UnicodeῼTitlecaseῼChar", // class Lt
                "UnicodeῼTitlecaseῼChar",
                "UnicodeῼTitlecaseῼChar",
                "Unicode_Titlecase_Char"),
            new StringSet(
                "UnicodeःCombiningःChar", // class Mc
                "UnicodeःCombiningःChar",
                "UnicodeःCombiningःChar",
                "Unicode_Combining_Char"),
        };

        public static TheoryDataSet<string, bool, string, string> AttributeAndHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(
                        stringSet.Text,
                        false,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                    result.Add(
                        stringSet.Text,
                        true,
                        stringSet.AttributeEncodedText,
                        stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> AttributeEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.AttributeEncodedText);
                    result.Add(stringSet.Text, true, stringSet.AttributeEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> ConditionallyHtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    result.Add(stringSet.Text, false, stringSet.Text);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> HtmlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var stringSet in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(stringSet.Text, false, stringSet.HtmlEncodedText);
                    result.Add(stringSet.Text, true, stringSet.HtmlEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> IdEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    // Add leading 'a' to avoid sanitizing to an empty string.
                    result.Add("a" + encodedString.Text, false, "a" + encodedString.IdEncodedText);
                    result.Add("a" + encodedString.Text, true, "a" + encodedString.IdEncodedText);
                }

                return result;
            }
        }

        public static TheoryDataSet<string, bool, string> UrlEncodedData
        {
            get
            {
                var result = new TheoryDataSet<string, bool, string>();
                foreach (var encodedString in StringSets)
                {
                    // Same results whether ModelMetadata.HtmlEncode is true or false.
                    result.Add(encodedString.Text, false, encodedString.UrlEncodedText);
                    result.Add(encodedString.Text, true, encodedString.UrlEncodedText);
                }

                return result;
            }
        }

        private class StringSet
        {
            public StringSet(string text, string attributeEncodedText, string htmlEncodedText, string idEncodedText)
                : this(text, attributeEncodedText, htmlEncodedText, idEncodedText, Uri.EscapeUriString(text))
            {
            }

            public StringSet(
                string text,
                string attributeEncodedText,
                string htmlEncodedText,
                string idEncodedText,
                string urlEncodedText)
            {
                Contract.Assert(!String.IsNullOrEmpty(text));
                Contract.Assert(!String.IsNullOrEmpty(attributeEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(htmlEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(idEncodedText));
                Contract.Assert(!String.IsNullOrEmpty(urlEncodedText));

                // Override default UrlEncodedText.
                Text = text;
                AttributeEncodedText = attributeEncodedText;
                HtmlEncodedText = htmlEncodedText;
                IdEncodedText = idEncodedText;
                UrlEncodedText = urlEncodedText;
            }

            public string Text { get; private set; }

            public string AttributeEncodedText { get; private set; }

            public string HtmlEncodedText { get; private set; }

            public string IdEncodedText { get; private set; }

            public string UrlEncodedText { get; private set; }
        }
    }
}

Irony.StringSet : ICollection

Constructors :

public StringSet()
public StringSet(StringComparer comparer = )

Methods :

public String ToString()
public Void AddRange(String[] items = )
public String ToString(String separator = )
public Void Clear()
public Boolean Contains(String item = )
public Boolean Remove(String item = )
public Int32 get_Count()
public Enumerator<String> GetEnumerator()
public Void GetObjectData(SerializationInfo info = , StreamingContext context = )
public Void OnDeserialization(Object sender = )
public Boolean Add(String item = )
public Boolean TryGetValue(String equalValue = , String& actualValue = )
public Void UnionWith(IEnumerable<String> other = )
public Void IntersectWith(IEnumerable<String> other = )
public Void ExceptWith(IEnumerable<String> other = )
public Void SymmetricExceptWith(IEnumerable<String> other = )
public Boolean IsSubsetOf(IEnumerable<String> other = )
public Boolean IsProperSubsetOf(IEnumerable<String> other = )
public Boolean IsSupersetOf(IEnumerable<String> other = )
public Boolean IsProperSupersetOf(IEnumerable<String> other = )
public Boolean Overlaps(IEnumerable<String> other = )
public Boolean SetEquals(IEnumerable<String> other = )
public Void CopyTo(String[] array = )
public Void CopyTo(String[] array = , Int32 arrayIndex = )
public Void CopyTo(String[] array = , Int32 arrayIndex = , Int32 count = )
public Int32 RemoveWhere(Predicate<String> match = )
public IEqualityComparer<String> get_Comparer()
public Int32 EnsureCapacity(Int32 capacity = )
public Void TrimExcess()
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()