Example #1
0
        /// <summary>
        /// Fill the <paramref name="emptyCollection"/> with all the browser templates in the current application. The return value is the same reference
        /// as the parameter.
        /// </summary>
        /// <param name="emptyCollection">An empty <see cref="IBrowserTemplateCollection"/> object to populate with the list of browser templates in the current
        /// application. This parameter is required because the library that implements this interface does not have
        /// the ability to directly instantiate any object that implements <see cref="IBrowserTemplateCollection"/>.</param>
        /// <returns>
        /// Returns an <see cref="IBrowserTemplateCollection" /> representing the browser templates in the current application. The returned object is the
        /// same object in memory as the <paramref name="emptyCollection"/> parameter.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>
        internal static IBrowserTemplateCollection GetBrowserTemplates(IBrowserTemplateCollection emptyCollection)
        {
            if (emptyCollection == null)
            {
                throw new ArgumentNullException("emptyCollection");
            }

            if (emptyCollection.Count > 0)
            {
                emptyCollection.Clear();
            }

            using (IDataReader dr = GetDataReaderBrowserTemplates())
            {
                // SQL:
                // SELECT BrowserTemplateId, MimeType, BrowserId, HtmlTemplate, ScriptTemplate
                // FROM gs_BrowserTemplate
                // ORDER BY MimeType";
                while (dr.Read())
                {
                    IBrowserTemplate bt = emptyCollection.CreateEmptyBrowserTemplateInstance();
                    bt.MimeType       = Convert.ToString(dr["MimeType"].ToString().Trim(), CultureInfo.InvariantCulture);
                    bt.BrowserId      = Convert.ToString(dr["BrowserId"].ToString().Trim(), CultureInfo.InvariantCulture);
                    bt.HtmlTemplate   = Convert.ToString(dr["HtmlTemplate"].ToString().Trim(), CultureInfo.InvariantCulture);
                    bt.ScriptTemplate = Convert.ToString(dr["ScriptTemplate"].ToString().Trim(), CultureInfo.InvariantCulture);

                    emptyCollection.Add(bt);
                }
            }

            return(emptyCollection);
        }
        /// <summary>
        /// Gets the ECMA script template information from the configuration file. If the configuration file
        /// does not specify an ECMA script template for the MIME type of this media object, an empty string is returned.
        /// </summary>
        /// <returns>Returns the ECMA script template information from the configuration file.</returns>
        private string GetScriptOutputFromConfig()
        {
            IBrowserTemplate browserTemplate = this.MimeType.GetBrowserTemplate(this.Browsers);

            return(browserTemplate == null ? String.Empty : browserTemplate.ScriptTemplate);
        }