Create() приватный Метод

private Create ( string urlRoot, string path ) : StaticFile
urlRoot string
path string
Результат StaticFile
Пример #1
0
        /// <summary>
        /// Initializes a new instance of the Index class.
        /// </summary>
        /// <param name="applicationName">The name of the current application.</param>
        /// <param name="file">The <see cref="StaticFile"/> instance representing the index XSLT stylesheet.</param>
        /// <param name="counts">The counts record to initialize this instance with.</param>
        public Index(string applicationName, StaticFile file, CountsRecord counts)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException("applicationName", "applicationName must contain a value.");
            }

            if (file == null)
            {
                throw new ArgumentNullException("file", "file cannot be null.");
            }

            if (!"index.xslt".Equals(file.OriginalPath, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("file must represent index.xslt.", "file");
            }

            if (counts == null)
            {
                throw new ArgumentNullException("counts", "counts cannot be null.");
            }

            this.ApplicationName = applicationName;
            this.file            = file;

            this.CountsJson    = JsonConvert.SerializeObject(counts);
            this.CssUrl        = StaticFile.Create(this.file.UrlRoot, "css/collar.css").Url;
            this.Html5JSUrl    = StaticFile.Create(this.file.UrlRoot, "js/html5.js").Url;
            this.JSApiUrl      = "//www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}";
            this.JSUrl         = StaticFile.Create(this.file.UrlRoot, "js/collar.js").Url;
            this.LogoHeaderUrl = StaticFile.Create(this.file.UrlRoot, "img/logo-header.png").Url;
            this.TemplatesHtml = GetTemplatesHtml();
            this.UrlRoot       = file.UrlRoot;
            this.Version       = typeof(Index).Assembly.GetName().Version.ToString(2);
        }
Пример #2
0
        /// <summary>
        /// Performs the concrete request operation and returns the output as a byte array.
        /// </summary>
        /// <param name="context">The HTTP context to perform the request for.</param>
        /// <param name="file">The static file to return the contents of.</param>
        /// <returns>The response to write.</returns>
        protected override byte[] PerformRequest(HttpContextBase context, StaticFile file)
        {
            string contents = Regex.Replace(
                Encoding.UTF8.GetString(file.Contents),
                @"url\(('|"")?([^'""#?\)]+)((#|\?)[^""'\)]+)?('|"")?\)",
                m =>
            {
                try
                {
                    return(string.Format(
                               CultureInfo.InvariantCulture,
                               "url({0}{1}{2}{3})",
                               m.Groups[1].Value,
                               StaticFile.Create(file.UrlRoot, m.Groups[2].Value).Url,
                               m.Groups[3].Value,
                               m.Groups[5].Value));
                }
                catch (FileNotFoundException)
                {
                    return(m.Groups[0].Value);
                }
            });

            return(EncodeString(contents));
        }
Пример #3
0
        /// <summary>
        /// Creates a <see cref="StaticFile"/> instance corresponding with the current request.
        /// </summary>
        /// <param name="context">The HTTP context to create the file for.</param>
        /// <returns>A <see cref="StaticFile"/> instance.</returns>
        protected virtual StaticFile CreateFile(HttpContextBase context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context", "context cannot be null.");
            }

            return(StaticFile.Create(HandlerUrl, this.RequestedFileName));
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the Index class.
 /// </summary>
 public Index()
     : this(BlueCollarSection.Section.ApplicationName, StaticFile.Create(BlueCollarSection.Section.Dashboard.HandlerUrl, "index.xslt"), new CountsRecord())
 {
 }