Exemplo n.º 1
0
        public void FindFilesWithcaseinsensitiveFileExtensions()
        {
            var    path     = Path.GetTempPath();
            string filePath = Path.Combine(path, "SaveFile.txt");

            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write("test");
            }

            Assert.AreEqual(filePath, DocumentationServices.FindFileInPaths("SaveFile", ".txt", new String[] { path }));
            File.Delete(filePath);
            filePath = Path.Combine(path, "SaveFile.TXT");
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write("test");
            }

            Assert.AreEqual(filePath, DocumentationServices.FindFileInPaths("SaveFile", ".txt", new String[] { path }));
            File.Delete(filePath);
            filePath = Path.Combine(path, "SaveFile.tXt");
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write("test");
            }

            Assert.AreEqual(filePath, DocumentationServices.FindFileInPaths("SaveFile", ".txt", new String[] { path }));
            File.Delete(filePath);
        }
Exemplo n.º 2
0
        public void FindFilesRespectsPathOrder()
        {
            var path1 = Path.Combine(Path.GetTempPath(), "firstFindFile");
            var path2 = Path.Combine(Path.GetTempPath(), "secondFindFile");

            Directory.CreateDirectory(path1);
            Directory.CreateDirectory(path2);

            string filePath1 = Path.Combine(path1, "SaveFile.txt");
            string filePath2 = Path.Combine(path2, "SaveFile.TXT");

            using (StreamWriter sw = new StreamWriter(filePath1))
            {
                sw.Write("test");
            }
            using (StreamWriter sw = new StreamWriter(filePath2))
            {
                sw.Write("test");
            }


            Assert.AreEqual(filePath1, DocumentationServices.FindFileInPaths("SaveFile", ".txt", new String[] { path1, path2 }));
            Assert.AreEqual(filePath2, DocumentationServices.FindFileInPaths("SaveFile", ".txt", new String[] { path2, path1 }));

            Directory.Delete(path1, true);
            Directory.Delete(path2, true);
        }
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            HttpPageHelper.CurrentItem = null;
            //var p = new HRR.Core.Domain.Page();
            //if (HttpPageHelper.CurrentUser == null)
            //    p = new PageServices().GetByNameAccessLevel(VirtualPath, 0, Convert.ToInt16(ConfigurationManager.AppSettings["APPLICATIONID"]));
            //else
            //    p = new PageServices().GetByNameAccessLevel(VirtualPath, HttpPageHelper.CurrentUser.AccessLevel, Convert.ToInt16(ConfigurationManager.AppSettings["APPLICATIONID"]));
            //HttpPageHelper.CurrentPage = p
            string name = HttpUtility.HtmlDecode((string)requestContext.RouteData.Values["name"]);
            var    d    = new DocumentationServices().GetByName(name.Replace("-", " "));

            if (d != null)
            {
                HttpPageHelper.CurrentDocumentation = d;
            }
            //var item = new Item();
            //item.Description = p.Name;
            //item.Name = p.Name;
            //item.SEOTitle = p.SEOTitle;
            //item.ItemReference = item;
            //HttpPageHelper.CurrentItem = item;

            HRRBasePage page;

            if (!string.IsNullOrEmpty(name))
            {
                page = (HRRBasePage)BuildManager.CreateInstanceFromVirtualPath(ResourceStrings.Page_Documentation, typeof(System.Web.UI.Page));
            }
            else
            {
                page = null;
            }

            HttpPageHelper.IsValidRequest = true;
            return(page);
        }