コード例 #1
0
        /// <summary>
        /// Creates a JavaScript class to use the TextManager's texts client-side
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="clientClassName">Name of the class.</param>
        /// <param name="language">The language for the generated texts (if different from current language).</param>
        /// <param name="defaultNamespace">The default namespace for texts. (Set this to your assembly's namespace in plugins)</param>
        /// <param name="filter">Specify this to only include a subset of the TextManager's texts.</param>
        /// <param name="includeScriptTags">Wraps the generated script in &lt;script&gt; blocks if <c>true</c>.</param>
        /// <returns></returns>
        public static HtmlString WriteScript(this TextManager manager, string clientClassName, LanguageInfo language = null,
                                             string defaultNamespace = null, Func <string, string, bool> filter = null, bool includeScriptTags = true)
        {
            var generator = new JavaScriptGenerator();

            using (var s = new StringWriter())
            {
                generator.WriteScript(manager, clientClassName, s, language, defaultNamespace, filter, includeScriptTags);
                return(new HtmlString(s.ToString()));
            }
        }
コード例 #2
0
 /// <summary>
 /// Creates a JavaScript class to use the TextManager's texts client-side
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="clientClassName">Name of the class.</param>
 /// <param name="language">The language for the generated texts (if different from current language).</param>
 /// <param name="defaultNamespace">The default namespace for texts. (Set this to your assembly's namespace in plugins)</param>
 /// <param name="filter">Specify this to only include a subset of the TextManager's texts.</param>
 /// <param name="includeScriptTags">Wraps the generated script in &lt;script&gt; blocks if <c>true</c>.</param>
 /// <returns></returns>
 public static HtmlString WriteScript(this TextManager manager, string clientClassName, LanguageInfo language = null,
     string defaultNamespace = null, Func<string, string, bool> filter = null, bool includeScriptTags = true)
 {
     var generator = new JavaScriptGenerator();
     using (var s = new StringWriter())
     {
         generator.WriteScript(manager, clientClassName, s, language, defaultNamespace, filter, includeScriptTags);
         return new HtmlString(s.ToString());
     }
 }