示例#1
0
        public static void HtmlAttributeEncode(string s, TextWriter output)
        {
            if (output == null)
            {
#if NET_4_0
                throw new ArgumentNullException("output");
#else
                throw new NullReferenceException(".NET emulation");
#endif
            }
#if NET_4_0
            HttpEncoderFromMono.Current.HtmlAttributeEncode(s, output);
#else
            output.Write(HttpEncoderFromMono.HtmlAttributeEncode(s));
#endif
        }
示例#2
0
        public static string HtmlAttributeEncode(string s)
        {
#if NET_4_0
            if (s == null)
            {
                return(null);
            }

            using (var sw = new StringWriter()) {
                HttpEncoderFromMono.Current.HtmlAttributeEncode(s, sw);
                return(sw.ToString());
            }
#else
            return(HttpEncoderFromMono.HtmlAttributeEncode(s));
#endif
        }