Exemple #1
0
        public virtual bool IsObservable(Url url)
        {
            if (observeAllExtensions)
            {
                return(true);
            }

            if (url.LocalUrl == Url.ApplicationPath)
            {
                return(true);
            }

            string extension = url.Extension;

            if (rewriteEmptyExtension && string.IsNullOrEmpty(extension))
            {
                return(true);
            }
            foreach (string observed in observedExtensions)
            {
                if (string.Equals(observed, extension, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
            }
            if (url.GetQuery(PathData.PageQueryKey) != null)
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        public virtual PathData ResolveUrl(Url url)
        {
            try
            {
                var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions));

                path.CurrentItem = path.CurrentPage;

                if (draftRepository.Versions.TryParseVersion(url[PathData.VersionQueryKey], url["versionKey"], path))
                {
                    return(path);
                }

                string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString);
                if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem))
                {
                    var draft = draftRepository.Versions.GetVersion(path.CurrentPage);
                    path.TryApplyVersion(draft, url["versionKey"]);
                }

                return(path);
            }
            catch (Exception ex)
            {
                errorHandler.Notify(ex);
            }
            return(PathData.Empty);
        }
Exemple #3
0
        public virtual PathData ResolveUrl(Url url)
        {
            try
            {
                var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions));

                path.CurrentItem = path.CurrentPage;

                if (draftRepository.Versions.TryParseVersion(url[PathData.VersionIndexQueryKey], url[PathData.VersionKeyQueryKey], path))
                    return path;

                string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString);
                if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem))
                {
                    var draft = draftRepository.Versions.GetVersion(path.CurrentPage);
					path.TryApplyVersion(draft, url["versionKey"], draftRepository.Versions);
                }

                return path;
            }
            catch (Exception ex)
            {
                errorHandler.Notify(ex);
            }
            return PathData.Empty;
        }
		public virtual PathData ResolveUrl(Url url)
		{
            // simple cache to help with multiple requests for same URL - PoC
		    if ((lastUrl != null) && (lastUrl.Item1 == url.ToString()))
		    {
		        var result = lastUrl.Item2;
		        lastUrl = null;
		        return result;
		    }

			try
			{
				var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions));

				path.CurrentItem = path.CurrentPage;

				if (draftRepository.Versions.TryParseVersion(url[PathData.VersionIndexQueryKey], url["versionKey"], path))
				{
				    lastUrl = new Tuple<string, PathData>(url, path);
                    return path;
                }

				string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString);
				if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem))
				{
					var draft = draftRepository.Versions.GetVersion(path.CurrentPage);
					path.TryApplyVersion(draft, url["versionKey"]);
				}

                lastUrl = new Tuple<string, PathData>(url, path);
				return path;
			}
			catch (Exception ex)
			{
				errorHandler.Notify(ex);
			}
			return PathData.Empty;
		}
        public virtual PathData ResolveUrl(Url url)
        {
            // simple cache to help with multiple requests for same URL - PoC
            if ((lastUrl != null) && (lastUrl.Item1 == url.ToString()))
            {
                var result = lastUrl.Item2;
                lastUrl = null;
                return(result);
            }

            try
            {
                var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions));

                path.CurrentItem = path.CurrentPage;

                if (draftRepository.Versions.TryParseVersion(url[PathData.VersionIndexQueryKey], url["versionKey"], path))
                {
                    lastUrl = new Tuple <string, PathData>(url, path);
                    return(path);
                }

                string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString);
                if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem))
                {
                    var draft = draftRepository.Versions.GetVersion(path.CurrentPage);
                    path.TryApplyVersion(draft, url["versionKey"]);
                }

                lastUrl = new Tuple <string, PathData>(url, path);
                return(path);
            }
            catch (Exception ex)
            {
                errorHandler.Notify(ex);
            }
            return(PathData.Empty);
        }
Exemple #6
0
 public void Getting_Query_WhenNoQueries_GivesNull()
 {
     Url u = new Url("/hello.aspx");
     var q = u.GetQuery("something");
     Assert.That(q, Is.Null);
 }
Exemple #7
0
 public void Getting_NonExistantQuery_GivesNull()
 {
     Url u = new Url("/hello.aspx?something=someotherthing");
     var q = u.GetQuery("nothing");
     Assert.That(q, Is.Null);
 }
Exemple #8
0
 public void CanGet_Query()
 {
     Url u = new Url("/hello.aspx?something=someotherthing");
     var q = u.GetQuery("something");
     Assert.That(q, Is.EqualTo("someotherthing"));
 }
		public virtual bool IsObservable(Url url)
		{
			if (observeAllExtensions)
				return true;

			if(url.LocalUrl == Url.ApplicationPath)
				return true;

			string extension = url.Extension;
			if (rewriteEmptyExtension && string.IsNullOrEmpty(extension))
				return true;
			foreach (string observed in observedExtensions)
				if (string.Equals(observed, extension, StringComparison.InvariantCultureIgnoreCase))
					return true;
			if (url.GetQuery(PathData.PageQueryKey) != null)
				return true;

			return false;
		}