private static void InitializeStyleCollection(DefaultResourceHandlerFactory factory)
        {
            styleCollection.Add("packages/bootstrap/content/bootstrap.css");
            styleCollection.Add("packages/bootstrap/content/bootstrap-theme.css");
            styleCollection.Add("packages/angular-loading-bar/content/loading-bar.css");
            styleCollection.Add("packages/angular-loading-bar/content/loading-bar.min.css");
            styleCollection.Add("packages/angular-bootstrap/content/ui-bootstrap-csp.css");
            styleCollection.Add("packages/kendo/styles/kendo.common-material.css");
            styleCollection.Add("packages/kendo/styles/kendo.material.css");
            styleCollection.Add("css/_context-menu.css");
            styleCollection.Add("css/_utilities.css");
            styleCollection.Add("css/edit-questionnaire.css");
            styleCollection.Add("css/form.css");
            styleCollection.Add("css/kendo-editor-override.css");
            styleCollection.Add("css/main.css");
            styleCollection.Add("css/sub-header.css");
            styleCollection.Add("css/toggle-switch.css");
            styleCollection.Add("css/dm.css");
            styleCollection.Add("css/question-preview.css");

            foreach (var item in styleCollection)
            {
                var filePath = Path.Combine(baseFilePath, item);
                factory.RegisterHandler(basePath + "/" + item, ResourceHandler.FromFilePath(filePath));
            }
        }
        /// <summary>
        /// If the file requested is within the rootFolder then a IResourceHandler reference to the file requested will be returned
        /// otherwise a 404 ResourceHandler will be returned.
        /// </summary>
        /// <param name="browser">the browser window that originated the
        /// request or null if the request did not originate from a browser window
        /// (for example, if the request came from CefURLRequest).</param>
        /// <param name="frame">frame that originated the request
        /// or null if the request did not originate from a browser window
        /// (for example, if the request came from CefURLRequest).</param>
        /// <param name="schemeName">the scheme name</param>
        /// <param name="request">The request. (will not contain cookie data)</param>
        /// <returns>
        /// A IResourceHandler
        /// </returns>
        IResourceHandler ISchemeHandlerFactory.Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            if (this.schemeName != null && !schemeName.Equals(this.schemeName, StringComparison.OrdinalIgnoreCase))
            {
                return(ResourceHandler.ForErrorMessage(string.Format("SchemeName {0} does not match the expected SchemeName of {1}.", schemeName, this.schemeName), HttpStatusCode.NotFound));
            }

            var uri = new Uri(request.Url);

            if (this.hostName != null && !uri.Host.Equals(this.hostName, StringComparison.OrdinalIgnoreCase))
            {
                return(ResourceHandler.ForErrorMessage(string.Format("HostName {0} does not match the expected HostName of {1}.", uri.Host, this.hostName), HttpStatusCode.NotFound));
            }

            //Get the absolute path and remove the leading slash
            var asbolutePath = uri.AbsolutePath.Substring(1);

            if (string.IsNullOrEmpty(asbolutePath))
            {
                asbolutePath = defaultPage;
            }

            var filePath = Path.GetFullPath(Path.Combine(rootFolder, asbolutePath));

            //Check the file requested is within the specified path and that the file exists
            if (filePath.StartsWith(rootFolder, StringComparison.OrdinalIgnoreCase) && File.Exists(filePath))
            {
                var fileExtension = Path.GetExtension(filePath);
                var mimeType      = ResourceHandler.GetMimeType(fileExtension);
                return(ResourceHandler.FromFilePath(filePath, mimeType));
            }


            return(ResourceHandler.ForErrorMessage("File Not Found - " + filePath, HttpStatusCode.NotFound));
        }
        private static void InitializeTypeScriptCollection(DefaultResourceHandlerFactory factory)
        {
            typeScriptCollection.Add("jsout/base/app.js");
            typeScriptCollection.Add("jsout/base/app.config.js");
            typeScriptCollection.Add("jsout/base/app.run.js");
            typeScriptCollection.Add("jsout/base/app.controller.js");
            typeScriptCollection.Add("Js/ExpandCollapseBehaviour.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-helper.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-resources.js");
            typeScriptCollection.Add("jsout/typescripts/document-manager-resources.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-constants.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-entity.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-helper.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-item-type.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-item.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-kendo-wrapper.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-preview-base.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-preview-components.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-preview-controller.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-question.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-resources.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-rule-engine.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-rule.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-section.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-table.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-text-help.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-text-instruction.js");
            typeScriptCollection.Add("jsout/typescripts/questionnaire-text-warning.js");

            foreach (var item in typeScriptCollection)
            {
                var filePath = Path.Combine(baseFilePath, item);
                factory.RegisterHandler(basePath + "/" + item, ResourceHandler.FromFilePath(filePath));
            }
        }
        private static void InitializeImageCollection(DefaultResourceHandlerFactory factory)
        {
            imageCollection.Add("images/icon-close.svg");
            imageCollection.Add("images/icon-refresh.svg");
            imageCollection.Add("images/icon-arrow-right.svg");
            imageCollection.Add("images/icon-dots.svg");
            imageCollection.Add("images/icon-questionnaire-warning.svg");

            imageCollection.Add("css/Material/sprite_2x.png");
            imageCollection.Add("css/Material/sprite.png");
            imageCollection.Add("css/Material/loading.gif");

            imageCollection.Add("css/fonts/proximanova-regularit.ttf");
            imageCollection.Add("css/fonts/proximanova-regular.woff");
            imageCollection.Add("packages/kendo/styles/fonts/glyphs/WebComponentsIcons.woff");
            imageCollection.Add("packages/kendo/styles/fonts/glyphs/WebComponentsIcons.ttf");

            foreach (var item in imageCollection)
            {
                var filePath = Path.Combine(baseFilePath, item);
                if (Path.GetExtension(filePath).Equals(".svg", StringComparison.OrdinalIgnoreCase))
                {
                    factory.RegisterHandler(basePath + "/" + item, ResourceHandler.FromFilePath(filePath, "image/svg+xml"));
                }
                else
                {
                    factory.RegisterHandler(basePath + "/" + item, ResourceHandler.FromFilePath(filePath));
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Create an instance of FileSystemResourceHandler.
        /// </summary>
        /// <param name="browser">The browser window that originated the request or null if the request did not originate from a browser window (for example, if the request came from CefURLRequest).</param>
        /// <param name="frame">Frame that originated the request or null if the request did not originate from a browser window (for example, if the request came from CefURLRequest).</param>
        /// <param name="schemeName">The scheme name</param>
        /// <param name="request">The request. (will not contain cookie data)</param>
        /// <returns>Return a new FileSystemResourceHandler instance to handle the request or an empty reference to allow default handling of the request.</returns>
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            // Only handle fs scheme.
            if (string.Compare(schemeName, SchemeName, true) != 0)
            {
                return(ResourceHandler.ForErrorMessage($"Invalid scheme [{schemeName}].", HttpStatusCode.BadRequest));
            }

            var uri  = new Uri(request.Url);
            var root = uri.Authority;

            // If the root of the path is a system volume then add the volume separator ":"
            // else it will be consider as just another directory.
            if (_volumes.Any(v => v.StartsWith(root)))
            {
                root = root + Path.VolumeSeparatorChar;
            }
            var filepath = WebUtility.UrlDecode(root + uri.AbsolutePath);

            if (File.Exists(filepath))
            {
                return(ResourceHandler.FromFilePath(filepath, ResourceHandler.GetMimeType(Path.GetExtension(filepath))));
            }

            return(ResourceHandler.ForErrorMessage("File not found.", HttpStatusCode.NotFound));
        }
Exemple #6
0
        private void RegisterResourceHandlers()
        {
            var validResources = new[] { "WasmScripts", "WasmCSS" };

            foreach (var file in Directory.GetFiles(_distFolder, "*.*"))
            {
                if (file.EndsWith("mono.js"))
                {
                    _handlerFactory.RegisterHandler(
                        "http://localhost/mono.js",
                        ResourceHandler.FromString("")
                        );
                }
                else
                {
                    string url = "http://localhost/" + file.Replace(_distFolder, "").TrimStart('\\');
                    _handlerFactory.RegisterHandler(
                        url,
                        ResourceHandler.FromFilePath(file, autoDisposeStream: true)
                        );

                    Debug.WriteLine($"Registered handler for {url}");
                }
            }
        }
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            if (string.Compare(schemeName, GlobalConfig.Domain.Scheme, true) != 0)
            {
                return(null);
            }

            try
            {
                var filePath = new Uri(request.Url).AbsolutePath.Substring(1);
                if (Path.IsPathRooted(filePath))
                {
                    filePath = filePath.ToAppPath(true);
                    if (filePath.FileExists())
                    {
                        return(ResourceHandler.FromFilePath(filePath, ResourceHandler.GetMimeType(Path.GetExtension(filePath))));
                    }
                    return(null);
                }
                else
                {
                    return(new EmbeddedResHandler());
                }
            }
            catch (Exception ex)
            {
                //AppLogger.Instance.Log("error when create IResourceHandler", ex);
                return(null);
            }
        }
        private static void InitializeScriptCollection(DefaultResourceHandlerFactory factory)
        {
            var currentCulture = CultureInfo.CurrentCulture;

            scriptCollection.Add("packages/jquery/jquery-1.9.1.js");
            scriptCollection.Add("packages/bootstrap/scripts/bootstrap.js");
            scriptCollection.Add("packages/angular-core/angular.js");
            scriptCollection.Add("packages/angular-route/angular-route.js");
            scriptCollection.Add("packages/angular-ui-router/angular-ui-router.js");
            scriptCollection.Add("packages/ng-storage/ngStorage.min.js");
            scriptCollection.Add("packages/angular-bootstrap/scripts/angular-ui/ui-bootstrap.js");
            scriptCollection.Add("packages/angular-bootstrap/scripts/angular-ui/ui-bootstrap-tpls.js");
            scriptCollection.Add("packages/misc/jquery.mCustomScrollbar.concat.min.js");
            scriptCollection.Add("packages/misc/scrollbars.js");
            scriptCollection.Add("packages/angular-loading-bar/scripts/loading-bar.js");
            scriptCollection.Add("packages/misc/ocLazyLoad.js");
            scriptCollection.Add("packages/kendo/js/kendo.all.min.js");
            scriptCollection.Add("packages/kendo/js/kendo.grid.min.js");
            if (currentCulture != null && currentCulture.ToString() != "en-US")
            {
                scriptCollection.Add("packages/kendo/cultures/kendo.culture." + currentCulture + ".min.js");
            }

            foreach (var item in scriptCollection)
            {
                var filePath = Path.Combine(baseFilePath, item);
                factory.RegisterHandler(basePath + "/" + item, ResourceHandler.FromFilePath(filePath));
            }
        }
 public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
 {
     if (schemeName == SchemeName && request.Url.EndsWith("CefSharp.Core.xml", System.StringComparison.OrdinalIgnoreCase))
     {
         //Display the debug.log file in the browser
         return(ResourceHandler.FromFilePath($"{AppDomain.CurrentDomain.BaseDirectory}\\CefSharp.Core.xml", ".xml"));
     }
     return(new CefSharpSchemeHandler());
 }
        /// <summary>
        /// Creates a resourceHandler for the request.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="frame"></param>
        /// <param name="schemeName"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            var uri           = new Uri(request.Url);
            var fileName      = uri.AbsolutePath;
            var resource      = $"{_root}build{fileName.Replace('/', '\\')}";
            var fileExtension = Path.GetExtension(fileName);

            return(ResourceHandler.FromFilePath(resource, new[] { ".woff", ".woff2", ".ttf" }.Contains(fileExtension) ?
                                                "text/html" : ResourceHandler.GetMimeType(fileExtension)));
        }
 public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
 {
     if (schemeName == SchemeName && request.Url.EndsWith("CefSharp.Core.xml", System.StringComparison.OrdinalIgnoreCase))
     {
         //Convenient helper method to lookup the mimeType
         var mimeType = ResourceHandler.GetMimeType(".xml");
         //Load a resource handler for CefSharp.Core.xml
         //mimeType is optional and will default to text/html
         return(ResourceHandler.FromFilePath("CefSharp.Core.xml", mimeType));
     }
     return(new CefSharpSchemeHandler());
 }
Exemple #12
0
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            //Notes:
            // - The 'host' portion is entirely ignored by this scheme handler.
            // - If you register a ISchemeHandlerFactory for http/https schemes you should also specify a domain name
            // - Avoid doing lots of processing in this method as it will affect performance.
            // - Use the Default ResourceHandler implementation

            var uri      = new Uri(request.Url);
            var fileName = uri.AbsolutePath;

            //Load a file directly from Disk
            if (fileName.EndsWith("CefSharp.Core.xml", StringComparison.OrdinalIgnoreCase))
            {
                //Convenient helper method to lookup the mimeType
                var mimeType = Cef.GetMimeType("xml");
                //Load a resource handler for CefSharp.Core.xml
                //mimeType is optional and will default to text/html
                return(ResourceHandler.FromFilePath("CefSharp.Core.xml", mimeType, autoDisposeStream: true));
            }

            if (fileName.EndsWith("Logo.png", StringComparison.OrdinalIgnoreCase))
            {
                //Convenient helper method to lookup the mimeType
                var mimeType = Cef.GetMimeType("png");
                //Load a resource handler for Logo.png
                //mimeType is optional and will default to text/html
                return(ResourceHandler.FromFilePath("..\\..\\..\\..\\CefSharp.WinForms.Example\\Resources\\chromium-256.png", mimeType, autoDisposeStream: true));
            }

            if (uri.Host == "cefsharp.com" && schemeName == "https" && (string.Equals(fileName, "/PostDataTest.html", StringComparison.OrdinalIgnoreCase) ||
                                                                        string.Equals(fileName, "/PostDataAjaxTest.html", StringComparison.OrdinalIgnoreCase)))
            {
                return(new CefSharpSchemeHandler());
            }

            if (string.Equals(fileName, "/EmptyResponseFilterTest.html", StringComparison.OrdinalIgnoreCase))
            {
                return(ResourceHandler.FromString("", mimeType: ResourceHandler.DefaultMimeType));
            }

            string resource;

            if (ResourceDictionary.TryGetValue(fileName, out resource) && !string.IsNullOrEmpty(resource))
            {
                var fileExtension = Path.GetExtension(fileName);
                return(ResourceHandler.FromString(resource, includePreamble: true, mimeType: Cef.GetMimeType(fileExtension)));
            }

            return(null);
        }
Exemple #13
0
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            string url      = request.Url;
            string path     = GetPath(url);
            string pathFile = LookupFile(path);

            if (pathFile != "")
            {
                string extension = new FileInfo(pathFile).Extension;
                string mimeType  = ResourceHandler.GetMimeType(extension);

                return(ResourceHandler.FromFilePath(pathFile, mimeType));
            }

            return(ResourceHandler.FromString(""));
        }
        /// <summary>
        /// Creates a resourceHandler for the request.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="frame"></param>
        /// <param name="schemeName"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            var uri      = new Uri(request.Url);
            var fileName = uri.AbsolutePath;

            string resource = _root + "Web\\Scripts\\Build\\" + fileName.Replace('/', '\\');

            var fileExtension = Path.GetExtension(fileName);

            if ((new string[] { ".woff", ".woff2", ".ttf" }).Contains(fileExtension))
            {
                return(ResourceHandler.FromFilePath(resource, "text/html"));
            }

            return(ResourceHandler.FromFilePath(resource, ResourceHandler.GetMimeType(fileExtension)));
        }
Exemple #15
0
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            if (schemeName == SchemeName)
            {
                var slice = SchemeName.Length + 4;
                if (slice >= request.Url.Length)
                {
                    return(null);
                }

                var filename = $@"{request.Url[slice - 1].ToInvariantString()}:{request.Url.Substring(slice)}";
                var mimeType = ResourceHandler.GetMimeType(Path.GetExtension(filename));
                return(ResourceHandler.FromFilePath(filename, mimeType));
            }

            return(null);
        }
Exemple #16
0
        IResourceHandler ISchemeHandlerFactory.Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            var filePath = Path.GetFullPath(@"Resources\big-buck-bunny_trailer.webm");

            if (File.Exists(filePath))
            {
                var fileExtension = Path.GetExtension(filePath);
                var mimeType      = ResourceHandler.GetMimeType(fileExtension);
                return(ResourceHandler.FromFilePath(filePath, mimeType));
            }

            var fileNotFoundResourceHandler = ResourceHandler.FromString("File Not Found - " + filePath);

            fileNotFoundResourceHandler.StatusCode = (int)HttpStatusCode.NotFound;

            return(fileNotFoundResourceHandler);
        }
        public static IResourceHandler CreateFileHandler(string path)
        {
            string mimeType;

            switch (Path.GetExtension(path))
            {
            case ".weba":
            case ".webm": mimeType = "audio/webm"; break;

            case ".wav": mimeType = "audio/wav"; break;

            case ".ogg": mimeType = "audio/ogg"; break;

            case ".mp3": mimeType = "audio/mp3"; break;

            case ".flac": mimeType = "audio/flac"; break;

            case ".opus": mimeType = "audio/ogg; codecs=opus"; break;

            default: mimeType = null; break;
            }

            try{
                return(ResourceHandler.FromFilePath(path, mimeType));
            }catch {
                FormBrowser browser = FormManager.TryFind <FormBrowser>();

                browser?.InvokeAsyncSafe(() => {
                    using (FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error)){
                        form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);

                        Button btnViewOptions   = form.AddButton("View Options");
                        btnViewOptions.Width   += 16;
                        btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);

                        if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions)
                        {
                            browser.OpenSettings(typeof(TabSettingsSounds));
                        }
                    }
                });

                return(null);
            }
        }
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            var uri = request.Url;

            // 删除协议部分
            uri = uri.Substring(SchemeName.Length + 3);

            // 删除多余的斜线
            uri = uri.Trim('/');

            // 合并路径
            var fileName = Path.Combine(Environment.CurrentDirectory, webroot, uri);

            // 检查路径信息
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, "index.html");
            }
            ;

            return(ResourceHandler.FromFilePath(fileName));
        }
Exemple #19
0
        protected override IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
        {
            //Notes:
            // - The 'host' portion is entirely ignored by this scheme handler.
            // - If you register a ISchemeHandlerFactory for http/https schemes you should also specify a domain name
            // - Avoid doing lots of processing in this method as it will affect performance.
            // - Uses the Default ResourceHandler implementation
            if (request.Url == "disk://background")
            {
                return(ResourceHandler.FromByteArray(GetBitmapAsByteArray(Resources.notification_background)));
            }

            if (request.Url == "disk://achievement-notification")
            {
                if (AlertsController.Instance.CustomAchievementEnabled)
                {
                    return(ResourceHandler.FromFilePath(Settings.Default.notification_custom_achievement_file, null, true));
                }
                else
                {
                    return(ResourceHandler.FromFilePath("video/achievement-notification.webm", null, true));
                }
            }

            if (request.Url == "disk://mastery-notification")
            {
                if (AlertsController.Instance.CustomMasteryEnabled)
                {
                    return(ResourceHandler.FromFilePath(Settings.Default.notification_custom_mastery_file));
                }
                else
                {
                    return(ResourceHandler.FromFilePath("video/mastery-notification.webm"));
                }
            }

            return(ResourceHandler.FromFilePath("" + request.Url.Replace("disk://", "")));
        }
Exemple #20
0
        public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
        {
            Uri    uri = new Uri(request.Url);
            string location;
            string extension;

            if (uri.AbsolutePath == "/")
            {
                location  = uri.Host;
                extension = Path.GetExtension(uri.Host);
            }
            else
            {
                string[] dirs = { uri.Host, uri.AbsolutePath };
                extension = Path.GetExtension(uri.AbsolutePath.Split('/').Last());
                location  = $"{uri.Host}/{uri.AbsolutePath}";
            }

            string mime = ResourceHandler.GetMimeType(extension);
            string path = FSHelper.NormalizeLocation($"{Root}/{location}");

            return(ResourceHandler.FromFilePath(path, mime));
        }
Exemple #21
0
            protected override IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
            {
                if (request.Url.StartsWith("http://epub.zyfdroid.com/static"))
                {
                    String fileName = request.Url.Replace("http://epub.zyfdroid.com/static", Program.staticPath);
                    if (!File.Exists(fileName))
                    {
                        return(ResourceHandler.ForErrorMessage("404 Not Found", System.Net.HttpStatusCode.NotFound));
                    }
                    return(ResourceHandler.FromFilePath(fileName, Cef.GetMimeType(Path.GetExtension(fileName).Replace(".", "").ToLower())));
                }
                if (request.Url.StartsWith("http://epub.zyfdroid.com/book"))
                {
                    String fileName = request.Url.Replace("http://epub.zyfdroid.com/book", Program.openingPath);
                    if (!File.Exists(fileName))
                    {
                        return(ResourceHandler.ForErrorMessage("404 Not Found", System.Net.HttpStatusCode.NotFound));
                    }
                    return(ResourceHandler.FromFilePath(fileName, Cef.GetMimeType(Path.GetExtension(fileName).Replace(".", "").ToLower())));
                }

                return(base.GetResourceHandler(chromiumWebBrowser, browser, frame, request));
            }
 public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
 {
     return(ResourceHandler.FromFilePath(@"..\..\..\Data\memtest.html"));
 }
        public static string RegisterResources(DefaultResourceHandlerFactory factory, string title)
        {
            if (factory == null)
            {
                return(null);
            }

            var previewPath = "http://test/resource/load/questionnaire_preview.html";

            baseFilePath = Path.Combine(RetrieveAppLocation(), "Web");

            Initialize(factory);

            var templateCollection = Directory.GetFiles(Path.Combine(baseFilePath, "templates"), "*.*", SearchOption.AllDirectories);

            foreach (var item in templateCollection)
            {
                factory.RegisterHandler(string.Format(CultureInfo.InvariantCulture, "{0}", item.Replace(baseFilePath, basePath).Replace("\\", "/")), ResourceHandler.FromFilePath(item));
            }

            var htmlPage = GetQuestionnaireHtml(title);

            factory.RegisterHandler(previewPath, ResourceHandler.FromString(htmlPage));
            ClearAll();

            return(previewPath);
        }