Esempio n. 1
0
        public override void Write(TextWriter writer)
        {
            IBuildResult result     = this.BuildResult;
            bool         customType = this.Attributes.ContainsKey("type");

            try
            {
                if (!customType)
                {
                    string mimeType;
                    if (result == null)
                    {
                        mimeType = ScriptResourceCodeProvider.MimeType;
                    }
                    else
                    {
                        mimeType = result.ContentType;
                    }
                    this.Attributes["type"] = mimeType;
                }
                string url = this.ResolveUrl();
                this.Attributes["src"] = url;

                writer.Write(ScriptBuildResult.ScriptStart);

                this.WriteAttributes(writer);

                writer.Write(ScriptBuildResult.ScriptEnd);

                if (!this.SuppressLocalization &&
                    this is IGlobalizedBuildResult)
                {
                    string culture = this.UsePageCulture ?
                                     Thread.CurrentThread.CurrentCulture.Name :
                                     String.Empty;

                    this.Attributes["src"] = ResourceHandler.GetLocalizationUrl(url, culture);

                    writer.Write(ScriptBuildResult.ScriptStart);
                    this.WriteAttributes(writer);
                    writer.Write(ScriptBuildResult.ScriptEnd);
                }
            }
            finally
            {
                if (!customType)
                {
                    this.Attributes.Remove("type");
                }
                this.Attributes.Remove("src");
            }
        }