コード例 #1
0
    public virtual string GetUrlForRequest(IMediaResourceUploadRequest request)
    {

      string hostUrl = this.GetHostUrlForRequest(request);
      string baseUrl = this.GetCommonPartForRequest(request).ToLowerInvariant();

      hostUrl = hostUrl + baseUrl;

      ItemSourceUrlBuilder sourceBuilder = new ItemSourceUrlBuilder(this.restGrammar, this.webApiGrammar, request.ItemSource);
      string itemSourceArgs = sourceBuilder.BuildUrlQueryString();

      string allParameters = itemSourceArgs;

      allParameters = allParameters + this.SpecificParametersForRequest(request);

      bool shouldTruncateBaseUrl = (!string.IsNullOrEmpty(allParameters) && allParameters.StartsWith(this.restGrammar.FieldSeparator));
      while (shouldTruncateBaseUrl)
      {
        allParameters = allParameters.Substring(1);
        shouldTruncateBaseUrl = (!string.IsNullOrEmpty(allParameters) && allParameters.StartsWith(this.restGrammar.FieldSeparator));
      }

      string result = hostUrl;

      if (!string.IsNullOrEmpty(allParameters))
      {
        result =
          result +
          this.restGrammar.HostAndArgsSeparator + allParameters;
      }

      return result;
    }
コード例 #2
0
        public virtual string GetUrlForRequest(IMediaResourceUploadRequest request)
        {
            string hostUrl = this.GetHostUrlForRequest(request);
            string baseUrl = this.GetCommonPartForRequest(request).ToLowerInvariant();

            hostUrl = hostUrl + baseUrl;

            ItemSourceUrlBuilder sourceBuilder = new ItemSourceUrlBuilder(this.restGrammar, this.webApiGrammar, request.ItemSource);
            string itemSourceArgs = sourceBuilder.BuildUrlQueryString();

            string allParameters = itemSourceArgs;

            allParameters = allParameters + this.SpecificParametersForRequest(request);

            bool shouldTruncateBaseUrl = (!string.IsNullOrEmpty(allParameters) && allParameters.StartsWith(this.restGrammar.FieldSeparator));

            while (shouldTruncateBaseUrl)
            {
                allParameters         = allParameters.Substring(1);
                shouldTruncateBaseUrl = (!string.IsNullOrEmpty(allParameters) && allParameters.StartsWith(this.restGrammar.FieldSeparator));
            }

            string result = hostUrl;

            if (!string.IsNullOrEmpty(allParameters))
            {
                result =
                    result +
                    this.restGrammar.HostAndArgsSeparator + allParameters;
            }

            return(result);
        }
コード例 #3
0
        public void TestUrlBuilderExcapesArgs()
        {
            ItemSource           data    = new ItemSource("{master}", "da???", 123);
            ItemSourceUrlBuilder builder = new ItemSourceUrlBuilder(RestServiceGrammar.ItemWebApiV2Grammar(), WebApiUrlParameters.ItemWebApiV2UrlParameters(), data);

            string expected = "sc_database=%7bmaster%7d&language=da%3f%3f%3f&sc_itemversion=123";

            Assert.AreEqual(expected, builder.BuildUrlQueryString());
        }
コード例 #4
0
        public void TestSerializationSupportsVersion()
        {
            ItemSource           data    = new ItemSource("master", "da", 100500);
            ItemSourceUrlBuilder builder = new ItemSourceUrlBuilder(RestServiceGrammar.ItemWebApiV2Grammar(), WebApiUrlParameters.ItemWebApiV2UrlParameters(), data);

            string expected = "sc_database=master&language=da&sc_itemversion=100500";

            Assert.AreEqual(expected, builder.BuildUrlQueryString());
        }
コード例 #5
0
        public void TestSerializeDafaultSource()
        {
            ItemSource           data    = LegacyConstants.DefaultSource();
            ItemSourceUrlBuilder builder = new ItemSourceUrlBuilder(RestServiceGrammar.ItemWebApiV2Grammar(), WebApiUrlParameters.ItemWebApiV2UrlParameters(), data);

            string expected = "sc_database=web&language=en";

            Assert.AreEqual(expected, builder.BuildUrlQueryString());
        }
コード例 #6
0
        public void TestSerializationSupportsVersion()
        {
            ItemSource           data    = new ItemSource("master", "da", 100500);
            ItemSourceUrlBuilder builder = new ItemSourceUrlBuilder(RestServiceGrammar.ItemSSCV2Grammar(), SSCUrlParameters.ItemSSCV2UrlParameters(), data);

            string expected = "database=master&language=da&version=100500";
            string actual   = builder.BuildUrlQueryString();

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        private string GetCommonPartForRequest(IGetRenderingHtmlRequest request)
        {
            ItemSourceUrlBuilder sourceBuilder = new ItemSourceUrlBuilder(this.restGrammar, this.webApiGrammar, request.ItemSource);
            string itemSourceArgs = sourceBuilder.BuildUrlQueryString();

            string result = string.Empty;

            string[] restSubQueries = { itemSourceArgs };
            foreach (string currentSubQuery in restSubQueries)
            {
                if (!string.IsNullOrEmpty(currentSubQuery))
                {
                    result =
                        result +
                        this.restGrammar.FieldSeparator + currentSubQuery;
                }
            }

            return(result.ToLowerInvariant());
        }
コード例 #8
0
    private string GetCommonPartForRequest(IGetRenderingHtmlRequest request)
    {
      ItemSourceUrlBuilder sourceBuilder = new ItemSourceUrlBuilder(this.restGrammar, this.webApiGrammar, request.ItemSource);
      string itemSourceArgs = sourceBuilder.BuildUrlQueryString();

      string result = string.Empty;

      string[] restSubQueries = { itemSourceArgs };
      foreach (string currentSubQuery in restSubQueries)
      {
        if (!string.IsNullOrEmpty(currentSubQuery))
        {
          result =
            result +
            this.restGrammar.FieldSeparator + currentSubQuery;
        }
      }

      return result.ToLowerInvariant();
    }