void IHttpHandler.ProcessRequest(HttpContext context) { var url = EwfApp.GetRequestAppRelativeUrl(context.Request); // We assume that all URL version strings will have the same length as the format string. var prefixedVersionStringIndex = url.LastIndexOf(".") - (urlVersionStringPrefix.Length + EwfSafeResponseWriter.UrlVersionStringFormat.Length); if (prefixedVersionStringIndex < 0) { throw new ResourceNotAvailableException("Failed to find the version and extension in the URL.", null); } var cssInfo = EwfApp.GlobalType.Assembly.CreateInstance( CombineNamespacesAndProcessEwfIfNecessary( EwfApp.GlobalType.Namespace, url.Remove(prefixedVersionStringIndex).Separate("/", false).Select(StandardLibraryMethods.GetCSharpIdentifier).Aggregate((a, b) => a + "." + b) + "+Info")) as StaticCssInfo; if (cssInfo == null) { throw new ResourceNotAvailableException("Failed to create an Info object for the request.", null); } var urlVersionString = url.Substring(prefixedVersionStringIndex + urlVersionStringPrefix.Length, EwfSafeResponseWriter.UrlVersionStringFormat.Length); if (EwfSafeResponseWriter.GetUrlVersionString(cssInfo.GetResourceLastModificationDateAndTime()) != urlVersionString) { throw new ResourceNotAvailableException("The URL version string does not match the last-modification date/time of the resource.", null); } new EwfSafeResponseWriter( () => File.ReadAllText(cssInfo.FilePath), urlVersionString, () => new ResponseMemoryCachingSetup(cssInfo.GetUrl(false, false, false), cssInfo.GetResourceLastModificationDateAndTime())).WriteResponse(); }
/// <summary> /// Development Utility use only. /// </summary> public static string GetUrlVersionString(DateTimeOffset dateAndTime) { return(urlVersionStringPrefix + EwfSafeResponseWriter.GetUrlVersionString(dateAndTime)); }