public static Uri MakeUri(string scheme, string host, int? port, string path, UriQueryParameters queryParams)
		{
			var portValue = port.HasValue ? port.Value : NoPortSpecified;
			var encodedQueryParams = queryParams.EncodeQueryString();
			const string SCHEME_DELIMITER = "://";
			var uri = String.Format("{0}{1}{2}:{3}{4}?{5}", scheme, SCHEME_DELIMITER, host, portValue, path, encodedQueryParams);
			return new Uri(uri);
		}
示例#2
0
        protected Uri FindByIdUri(TQ query, Config config)
        {
            Uri serviceRoot   = config.ServiceRoot;
            var entityUriPath = EntityUriPathRoot + "/" + query.Id + TypeSuffixJson;
            UriQueryParameters queryParams = GetDefaultQueryParams(config);

            return(UriEncoder.MakeUri(serviceRoot, entityUriPath, queryParams));
        }
示例#3
0
        protected Uri FindEntitiesUri(TQ query, Config config)
        {
            Uri                serviceRoot = config.ServiceRoot;
            String             uriPath     = GetUriPath();
            UriQueryParameters queryParams = QueryParams(query, config);

            return(UriEncoder.MakeUri(serviceRoot, uriPath, queryParams));
        }
示例#4
0
        private static UriQueryParameters ExtractUriQueryParameters(Uri uri)
        {
            var result = new UriQueryParameters();

            var query = uri.Query;

            if (query == null || query.Length <= 1)
            {
                return(result);
            }

            query = query.Substring(1); // skip '?'

            result.query         = query;
            result.hasQuery      = true;
            result.hasValidQuery = true;

            // no access to System.Web.dll here
            var queryParameters = query.Split(s_Separator);

            // all 3 parameters must be found in the query string for the asset reference to be valid
            foreach (var queryParameter in queryParameters)
            {
                var splitIndex = queryParameter.IndexOf('=');
                if (splitIndex > 0 && splitIndex < queryParameter.Length - 1)
                {
                    var key   = queryParameter.Substring(0, splitIndex);
                    var value = queryParameter.Substring(splitIndex + 1);

                    switch (key)
                    {
                    case k_AttrGuid:
                        result.guid    = value;
                        result.hasGuid = !string.IsNullOrEmpty(result.guid);
                        break;

                    case k_AttrFileId:
                        result.hasFileId = long.TryParse(value, out result.fileId);
                        break;

                    case k_AttrType:
                        result.hasType = int.TryParse(value, out result.type);
                        break;

                    default:
                        result.hasExtraQueryParams = true;
                        break;
                    }
                }
                else
                {
                    result.hasValidQuery = false;
                    return(result);
                }
            }

            return(result);
        }
示例#5
0
        protected UriQueryParameters GetDefaultQueryParams(Config config)
        {
            var parms = new UriQueryParameters(new ProApi20ParamValueFormatter());

            if (config != null)
            {
                parms.Put(ApiKeyKey, config.ApiKey);
            }
            return(parms);
        }
示例#6
0
 protected void AddWhereQueryParams(ref UriQueryParameters parms, WhereQuery query)
 {
     if (query != null)
     {
         parms.Put(StreetLine1Key, query.StreetLine1);
         parms.Put(StreetLine2Key, query.StreetLine2);
         parms.Put(CityKey, query.City);
         parms.Put(StateCodeKey, query.StateCode);
         parms.Put(PostalCodeKey, query.PostalCode);
         parms.Put(CountryCodeKey, query.CountryCode);
         parms.Put(LatitudeKey, query.Latitude);
         parms.Put(LongitudeKey, query.Longitude);
         parms.Put(RadiusKey, query.Radius);
     }
 }
		public static Uri MakeUri(Uri serviceRoot, string path, UriQueryParameters queryParams)
		{
			return MakeUri(serviceRoot.Scheme, serviceRoot.Host, serviceRoot.Port, path, queryParams);
		}