WithFragment() public méthode

Withes the fragment.
Depending on the existing fragment and the fragment being set, output may differ. Setting a null value will remove the fragment regardless the handledAs setting.
public WithFragment ( string fragment, ExistingFragment handledAs = ExistingFragment.Throw ) : HttpUrl
fragment string The fragment.
handledAs ExistingFragment Instructs on how to behave when an URL has already a fragment.
Résultat HttpUrl
Exemple #1
0
 public void should_give_same_instance_if_no_fragments_are_given()
 {
     var expected = new HttpUrl(true, "http://temp.uri/", "http", "temp.uri", 80, "/", null, null);
     expected.WithFragment(null).Should().BeSameAs(expected);
 }
Exemple #2
0
        private static IApiDocumentation GetApiDocumentation(HttpUrl url)
        {
            string contentType;
            var responseStream = new UnclosableStream(GetResponse(Method, url, out contentType));
            var container = UrsaConfigurationSection.InitializeComponentProvider();
            container.Register<IHttpServerConfiguration>(new StaticHttpServerConfiguration((Uri)url));
            var headers = new HeaderCollection();
            if (!String.IsNullOrEmpty(contentType))
            {
                ((IDictionary<string, string>)headers)[Header.Accept] = contentType;
                ((IDictionary<string, string>)headers)[Header.ContentType] = contentType;
            }

            var apiDocumentationId = url.WithFragment(String.Empty);
            var httpRequest = new RequestInfo(Verb.Parse(Method), apiDocumentationId, responseStream, new BasicClaimBasedIdentity(), headers);
            var converterProvider = container.Resolve<IConverterProvider>();
            var converter = converterProvider.FindBestInputConverter<IApiDocumentation>(httpRequest);
            if (converter == null)
            {
                throw new NotSupportedException(String.Format("Content type of '{0}' is not supported.", contentType));
            }

            converter.ConvertTo<IApiDocumentation>(httpRequest);
            return _container.Resolve<IEntityContext>().Load<IApiDocumentation>((Uri)apiDocumentationId);
        }