Exemplo n.º 1
0
        public Uri GenerateRequestUrl(Type type, string query = "*", int start = 0, int limit = 10)
        {
            string metaTypeName = GetMetaTypeName(type);

            var ftsQueryRequest = new FTSQueryRequest
            {
                Statements = new List <Statement>
                {
                    new Statement {
                        Query = query
                    }
                },
                Start = start,
                Limit = limit
            };

            var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

            var uri = FTSSearchTemplate.BindByName(BaseAddress,
                                                   new Dictionary <string, string>()
            {
                { "metaType", metaTypeName },
                { "query", ftsQueryRequestString }
            });

            return(uri);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Resolve URI UriTemplate with base URI and different types of arguments.
        /// </summary>
        /// <param name="baseUri">Base URI for resolving relative URI templates.</param>
        /// <param name="template">The URI UriTemplate to resolve.</param>
        /// <param name="parameters">Parameters for resolving URI UriTemplate (can be IDictionary<string, string>, NameValueCollection or
        /// any object where property names are used to match parameter names.</param>
        /// <returns></returns>
        public static Uri BindTemplate(Uri baseUri, UriTemplate template, object parameters = null)
        {
            if (baseUri == null)
            {
                throw new InvalidOperationException("It is not possible to bind relative URL templates without a base URL. Make sure session and/or service has been created with a base URL.");
            }
            Condition.Requires(template, "template").IsNotNull();

            if (parameters == null)
            {
                Dictionary <string, string> emptyParameters = new Dictionary <string, string>();
                return(template.BindByName(baseUri, emptyParameters));
            }
            else if (parameters is IDictionary <string, string> dp)
            {
                return(template.BindByName(baseUri, dp));
            }
            else if (parameters is NameValueCollection nvp)
            {
                IDictionary <string, string> dictParameters = nvp.Cast <string>().ToDictionary(p => p, p => nvp[p]);
                return(template.BindByName(baseUri, dictParameters));
            }
            else
            {
                Dictionary <string, string> parameterDictionary = DictionaryConverter.ConvertObjectPropertiesToDictionary(parameters);
                return(template.BindByName(baseUri, parameterDictionary));
            }
        }
Exemplo n.º 3
0
        public void TestPlusOperatorAssociativeMapTemplate()
        {
            string      template    = "{+keys:1}";
            UriTemplate uriTemplate = new UriTemplate(template);

            uriTemplate.BindByName(Variables);
        }
Exemplo n.º 4
0
        public void TestPrefixAssociativeMapTemplate()
        {
            string      template    = "{keys:1}";
            UriTemplate uriTemplate = new UriTemplate(template);

            uriTemplate.BindByName(Variables);
        }
Exemplo n.º 5
0
        public Uri GenerateRequestUrl(Type type, string query = "*", int start = 0, int limit = 10)
        {
            string metaTypeName    = GetMetaTypeName(type);
            var    ftsQueryRequest = new FTSQueryRequest
            {
                Statements = new List <Statement>
                {
                    new Statement {
                        Query = query
                    }
                },
                Start = start,
                Limit = limit
            };

            var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

            if (query.Contains(","))
            {
                string[] s        = query.Split(',');
                string   newQuery = "\"},{\"query\":\"";
                ftsQueryRequestString = ftsQueryRequestString.Replace($",{s[1]}", $"{newQuery}{s[1]}");
            }

            var uri = FTSSearchTemplate.BindByName(BaseAddress,
                                                   new Dictionary <string, string>()
            {
                { "metaType", metaTypeName },
                { "query", ftsQueryRequestString }
            });

            return(uri);
        }
        public Uri GenerateRequestUrl(Type type, string[] query, int start = 0, int limit = 10)
        {
            string metaTypeName = GetMetaTypeName(type);

            var ftsQueryRequest = new FTSQueryRequest();

            ftsQueryRequest.Statements = new List <Statement>();
            foreach (string q in query)
            {
                ftsQueryRequest.Statements.Add(new Statement
                {
                    Query = q
                });
            }
            ftsQueryRequest.Start = start;
            ftsQueryRequest.Limit = limit;

            var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

            var uri = FTSSearchTemplate.BindByName(BaseAddress,
                                                   new Dictionary <string, string>()
            {
                { "metaType", metaTypeName },
                { "query", ftsQueryRequestString }
            });

            return(uri);
        }
        public void TestEscapeSequences1()
        {
            string      template    = "/base{/group_id,first_name}/pages{/page,lang}{?format,q}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables1);

            Assert.AreEqual("/base/12345/John/pages/5/en?format=json&q=URI%20Templates", uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });

            Assert.IsNotNull(match);
            Assert.AreEqual(Variables1["group_id"], match.Bindings["group_id"].Value);
            Assert.AreEqual(Variables1["first_name"], match.Bindings["first_name"].Value);
            Assert.AreEqual(Variables1["page"], match.Bindings["page"].Value);
            Assert.AreEqual(Variables1["lang"], match.Bindings["lang"].Value);
            Assert.AreEqual(Variables1["format"], match.Bindings["format"].Value);
            Assert.AreEqual(Variables1["q"], match.Bindings["q"].Value);

            match = uriTemplate.Match(uri, RequiredVariables1, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });
            Assert.IsNotNull(match);
            Assert.AreEqual(Variables1["group_id"], match.Bindings["group_id"].Value);
            Assert.AreEqual(Variables1["first_name"], match.Bindings["first_name"].Value);
            Assert.AreEqual(Variables1["page"], match.Bindings["page"].Value);
            Assert.AreEqual(Variables1["lang"], match.Bindings["lang"].Value);
            Assert.AreEqual(Variables1["format"], match.Bindings["format"].Value);
            Assert.AreEqual(Variables1["q"], match.Bindings["q"].Value);
        }
		public Uri GenerateRequestUrl(Type type, IList<string> queryStrings, int start = 0, int limit = 10)
		{
			string metaTypeName = GetMetaTypeName(type);

		    var statements = queryStrings.Select(query => new Statement
		    {
		        Query = query
		    }).ToList();

		    var ftsQueryRequest = new FTSQueryRequest
			{
				Statements = statements,
				Start = start,
				Limit = limit
			};

			var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

			var uri = FTSSearchTemplate.BindByName(BaseAddress,
				new Dictionary<string, string>
				{
					{ "metaType", metaTypeName },
					{ "query", ftsQueryRequestString }
				});

			return uri;
		}
        public void TestCompoundPathSegmentExpansionWithQueryString()
        {
            string      template    = "{/id*}{?fields,first_name,last.name,token}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables1);

            string[] allowed =
            {
                "/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345",
                "/person?fields=id,picture,name&first_name=John&last.name=Doe&token=12345",
                "/person?fields=picture,name,id&first_name=John&last.name=Doe&token=12345",
                "/person?fields=picture,id,name&first_name=John&last.name=Doe&token=12345",
                "/person?fields=name,picture,id&first_name=John&last.name=Doe&token=12345",
                "/person?fields=name,id,picture&first_name=John&last.name=Doe&token=12345"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });

            Assert.IsNotNull(match);
            CollectionAssert.AreEqual(new[] { Variables1["id"] }, (ICollection)match.Bindings["id"].Value);
            CollectionAssert.AreEqual((ICollection)Variables1["fields"], (ICollection)match.Bindings["fields"].Value);
            Assert.AreEqual(Variables1["first_name"], match.Bindings["first_name"].Value);
            Assert.AreEqual(Variables1["last.name"], match.Bindings["last.name"].Value);
            Assert.AreEqual(Variables1["token"], match.Bindings["token"].Value);

            match = uriTemplate.Match(uri, RequiredVariables1, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual(new[] { Variables1["id"] }, (ICollection)match.Bindings["id"].Value);
            CollectionAssert.AreEqual((ICollection)Variables1["fields"], (ICollection)match.Bindings["fields"].Value);
            Assert.AreEqual(Variables1["first_name"], match.Bindings["first_name"].Value);
            Assert.AreEqual(Variables1["last.name"], match.Bindings["last.name"].Value);
            Assert.AreEqual(Variables1["token"], match.Bindings["token"].Value);
        }
        public void TestSimpleExpansionWithQueryString()
        {
            string      template    = "/search.{format}{?q,geocode,lang,locale,page,result_type}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables1);

            string[] allowed =
            {
                "/search.json?q=URI%20Templates&geocode=37.76,-122.427&lang=en&page=5",
                "/search.json?q=URI%20Templates&geocode=-122.427,37.76&lang=en&page=5"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });

            Assert.IsNotNull(match);
            Assert.AreEqual(Variables1["format"], match.Bindings["format"].Value);
            Assert.AreEqual(Variables1["q"], match.Bindings["q"].Value);
            CollectionAssert.AreEqual((ICollection)Variables1["geocode"], (ICollection)match.Bindings["geocode"].Value);
            Assert.AreEqual(Variables1["lang"], match.Bindings["lang"].Value);
            Assert.IsFalse(match.Bindings.ContainsKey("locale"));
            Assert.AreEqual(Variables1["page"], match.Bindings["page"].Value);
            Assert.IsFalse(match.Bindings.ContainsKey("result_type"));

            match = uriTemplate.Match(uri, RequiredVariables1, new[] { "fields", "geocode" }, new[] { "assoc_special_chars" });
            Assert.IsNotNull(match);
            Assert.AreEqual(Variables1["format"], match.Bindings["format"].Value);
            Assert.AreEqual(Variables1["q"], match.Bindings["q"].Value);
            CollectionAssert.AreEqual((ICollection)Variables1["geocode"], (ICollection)match.Bindings["geocode"].Value);
            Assert.AreEqual(Variables1["lang"], match.Bindings["lang"].Value);
            Assert.IsFalse(match.Bindings.ContainsKey("locale"));
            Assert.AreEqual(Variables1["page"], match.Bindings["page"].Value);
            Assert.IsFalse(match.Bindings.ContainsKey("result_type"));
        }
        public void TestQueryContinuationExpansionAssociativeMapVariable()
        {
            string      template    = "{&keys}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables);

            string[] allowed =
            {
                "&keys=comma,%2C,dot,.,semi,%3B",
                "&keys=comma,%2C,semi,%3B,dot,.",
                "&keys=dot,.,comma,%2C,semi,%3B",
                "&keys=dot,.,semi,%3B,comma,%2C",
                "&keys=semi,%3B,comma,%2C,dot,.",
                "&keys=semi,%3B,dot,.,comma,%2C"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "list" }, new[] { "keys" });

            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);

            match = uriTemplate.Match(uri, RequiredVariables, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);
        }
        public void TestCompoundQueryExpansionAssociativeMapVariable()
        {
            string      template    = "{?keys*}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables);

            string[] allowed =
            {
                "?comma=%2C&dot=.&semi=%3B",
                "?comma=%2C&semi=%3B&dot=.",
                "?dot=.&comma=%2C&semi=%3B",
                "?dot=.&semi=%3B&comma=%2C",
                "?semi=%3B&comma=%2C&dot=.",
                "?semi=%3B&dot=.&comma=%2C"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "list" }, new[] { "keys" });

            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);

            match = uriTemplate.Match(uri, RequiredVariables, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);
        }
        public void TestCompoundFragmentExpansionAssociativeMapVariable()
        {
            string      template    = "{#keys*}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables);

            string[] allowed =
            {
                "#comma=,,dot=.,semi=;",
                "#comma=,,semi=;,dot=.",
                "#dot=.,comma=,,semi=;",
                "#dot=.,semi=;,comma=,",
                "#semi=;,comma=,,dot=.",
                "#semi=;,dot=.,comma=,"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "list" }, new[] { "keys" });

            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);

            match = uriTemplate.Match(uri, RequiredVariables, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);
        }
        public void TestReservedExpansionAssociativeMapVariable()
        {
            string      template    = "{+keys}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri         uri         = uriTemplate.BindByName(Variables);

            string[] allowed =
            {
                "comma,,,dot,.,semi,;",
                "comma,,,semi,;,dot,.",
                "dot,.,comma,,,semi,;",
                "dot,.,semi,;,comma,,",
                "semi,;,comma,,,dot,.",
                "semi,;,dot,.,comma,,"
            };

            CollectionAssert.Contains(allowed, uri.OriginalString);

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "list" }, new[] { "keys" });

            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);

            match = uriTemplate.Match(uri, RequiredVariables, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)Variables["keys"], (ICollection)match.Bindings["keys"].Value);
        }
Exemplo n.º 15
0
        public Uri GenerateRequestUrl(Type type, IEnumerable <string> query = null, int start = 0, int limit = 10)
        {
            query = query ?? new[] { "*" };

            string metaTypeName = GetMetaTypeName(type);

            var ftsQueryRequest = new FTSQueryRequest
            {
                Statements = new List <Statement>(query.Select(queryItem => new Statement {
                    Query = queryItem
                })),
                Start = start,
                Limit = limit
            };

            var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

            var uri = FTSSearchTemplate.BindByName(BaseAddress,
                                                   new Dictionary <string, string>()
            {
                { "metaType", metaTypeName },
                { "query", ftsQueryRequestString }
            });

            return(uri);
        }
        public Stream GetSignedDocuments(string envelopeId)
        {
            var uriTemplate = SignatureApiUriTemplates.BuildUriTemplate(SignatureApiUriTemplates.GetSignedEnvelopeDocuments);
            var parameters  = new NameValueCollection
            {
                { "userId", UserId },
                { "envelopeId", envelopeId }
            };

            var template = new UriTemplate(uriTemplate);

            Uri    url       = template.BindByName(new Uri(BaseAddress), parameters);
            string signedUrl = UrlSignature.Sign(url.AbsoluteUri, PrivateKey);

            var request = new HttpRequestMessage {
                Method = "GET", Uri = new Uri(signedUrl)
            };

            HttpContent content = request.Content;

            _client.DefaultHeaders.ContentLength = (content != null && content.HasLength() ? new long?(content.GetLength()) : null);

            OnSendingRequest(request);

            return(_client.Send(request).Content.ReadAsStream());
        }
Exemplo n.º 17
0
        [Category("NotWorking")]          // not worthy
        public void BindByNameFileUriBaseAddress()
        {
            var t = new UriTemplate("http://localhost:8080/");
            var u = t.BindByName(new Uri("file:///"), new NameValueCollection());

            Assert.AreEqual("file:///http://localhost:8080/", u.ToString());
        }
Exemplo n.º 18
0
        public Uri GenerateRequestUrl(Type type, int start = 0, int limit = 10, params string[] query)
        {
            if (!query.Any())
            {
                query = new[] { "*" }
            }
            ;

            string metaTypeName = GetMetaTypeName(type);

            var ftsQueryRequest = new FTSQueryRequest
            {
                Statements = query.Select(x => new Statement {
                    Query = x
                }).ToList(),
                Start = start,
                Limit = limit
            };

            var ftsQueryRequestString = JsonConvert.SerializeObject(ftsQueryRequest);

            var uri = FTSSearchTemplate.BindByName(BaseAddress,
                                                   new Dictionary <string, string>
            {
                { "metaType", metaTypeName },
                { "query", ftsQueryRequestString }
            });

            return(uri);
        }
Exemplo n.º 19
0
        public string BuildUriString(string prefix, string template, dynamic parameters)
        {
            var newBaseUri  = new Uri(baseUri.TrimEnd('/') + prefix);
            var uriTemplate = new UriTemplate(template, true);

            return(uriTemplate.BindByName(newBaseUri, ToDictionary(parameters ?? new {})).ToString());
        }
Exemplo n.º 20
0
		public void BindByName3 ()
		{
			var t = new UriTemplate ("Login?clientLoginData={clientLoginData}&credentials={credentials}");
			var n = new NameValueCollection ();
			var u = t.BindByName (new Uri ("http://localhost"), n);
			Assert.AreEqual ("http://localhost/Login", u.ToString (), "#1");
		}
Exemplo n.º 21
0
		[Test] // it is allowed.
		public void BindByNameFileExtraNames ()
		{
			var t = new UriTemplate ("http://localhost:8080/");
			var n = new NameValueCollection ();
			n.Add ("name", "value");
			t.BindByName (new Uri ("http://localhost/"), n);
		}
Exemplo n.º 22
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            string url1   = "http://webstrar74.fulton.asu.edu/page7";
            string userid = TextBox9.Text;

            //Check if user id is empty
            if (userid == "")
            {
                Label36.Text = "Enter User ID"; return;
            }

            // Create the base address to the Cart Total Service
            Uri baseUri = new Uri(url1);
            // Define UriTemplate for passing parameter
            UriTemplate myTemplate = new UriTemplate("/api/Order/{userid}/");

            NameValueCollection parameters = new NameValueCollection();

            // Assign values to the parameters
            parameters.Add("userid", userid);
            //Build complete URI
            Uri completeUri = myTemplate.BindByName(baseUri, parameters);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(completeUri.ToString());

            request.Method = "GET";
            //Make the REST call
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            // Check the Response Status Code
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream       receiveStream = response.GetResponseStream();
                StreamReader readStream    = null;

                if (response.CharacterSet == "")
                {
                    readStream = new StreamReader(receiveStream);
                }
                else
                {
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                }

                // Convert to string and assign to the output label
                string str = readStream.ReadToEnd();
                //Check if there is any error
                if (str == "-1.0")
                {
                    Label36.Text = "Error in processing";
                }
                else
                {
                    Label36.Text = str;
                }
                return;
            }
            Label36.Text = "Error";
        }
Exemplo n.º 23
0
		public void DictContainsNullValue ()
		{
			var t = new UriTemplate ("/id-{foo}/{bar}");
			var dic = new Dictionary<string,string> ();
			dic ["foo"] = null;
			dic ["bar"] = "bbb";
			t.BindByName (new Uri ("http://localhost:8080"), dic);
		}
Exemplo n.º 24
0
		public void BindByNameWithDefaults2 ()
		{
			var d = new Dictionary<string,string> ();
			d.Add ("Bar", "value1"); // case insensitive
			d.Add ("FOO", "value2"); // case insensitive
			var t = new UriTemplate ("/{foo}/{bar}/{baz}", d);
			t.BindByName (new Uri ("http://localhost/"), new NameValueCollection ()); // missing baz
		}
Exemplo n.º 25
0
        public string BuildUriString(NancyContext context, string routeName, dynamic parameters)
        {
            var baseUri      = new Uri(context.Request.BaseUri().TrimEnd('/'));
            var pathTemplate = AllRoutes.Single(r => r.Name == routeName).Path;
            var uriTemplate  = new UriTemplate(pathTemplate, true);

            return(uriTemplate.BindByName(baseUri, ToDictionary(parameters ?? new {})).ToString());
        }
Exemplo n.º 26
0
        private static Uri CreateAccentResourceUri(Accent.SpecifiedColor accent)
        {
            var param = new Dictionary <string, string>
            {
                { "accent", accent.ToString() },
            };

            return(accentTemplate.BindByName(templateBaseUri, param));
        }
Exemplo n.º 27
0
        private static Uri CreateThemeResourceUri(Theme.SpecifiedColor theme)
        {
            var param = new Dictionary <string, string>
            {
                { "theme", theme.ToString() },
            };

            return(themeTemplate.BindByName(templateBaseUri, param));
        }
Exemplo n.º 28
0
            public virtual Message SerializeRequest(MessageVersion messageVersion, object [] parameters)
            {
                if (parameters == null)
                {
                    throw new ArgumentNullException("parameters");
                }
                CheckMessageVersion(messageVersion);

                var c = new Dictionary <string, string> ();

                MessageDescription md = GetMessageDescription(MessageDirection.Input);

                if (parameters.Length != md.Body.Parts.Count)
                {
                    throw new ArgumentException("Parameter array length does not match the number of message body parts");
                }

                for (int i = 0; i < parameters.Length; i++)
                {
                    var    p    = md.Body.Parts [i];
                    string name = p.Name.ToUpper(CultureInfo.InvariantCulture);
                    if (UriTemplate.PathSegmentVariableNames.Contains(name) ||
                        UriTemplate.QueryValueVariableNames.Contains(name))
                    {
                        c.Add(name, parameters [i] != null ? Converter.ConvertValueToString(parameters [i], parameters [i].GetType()) : null);
                    }
                    else
                    {
                        // FIXME: bind as a message part
                        throw new NotImplementedException(String.Format("parameter {0} is not contained in the URI template {1} {2} {3}", p.Name, UriTemplate, UriTemplate.PathSegmentVariableNames.Count, UriTemplate.QueryValueVariableNames.Count));
                    }
                }

                Uri to = UriTemplate.BindByName(Endpoint.Address.Uri, c);

                Message ret = Message.CreateMessage(messageVersion, (string)null);

                ret.Headers.To = to;

                var hp = new HttpRequestMessageProperty();

                hp.Method = Info.Method;

#if !NET_2_1
                if (WebOperationContext.Current != null)
                {
                    WebOperationContext.Current.OutgoingRequest.Apply(hp);
                }
#endif
                // FIXME: set hp.SuppressEntityBody for some cases.
                ret.Properties.Add(HttpRequestMessageProperty.Name, hp);

                var wp = new WebBodyFormatMessageProperty(ToContentFormat(Info.IsRequestFormatSetExplicitly ? Info.RequestFormat : Behavior.DefaultOutgoingRequestFormat));
                ret.Properties.Add(WebBodyFormatMessageProperty.Name, wp);

                return(ret);
            }
Exemplo n.º 29
0
		public void DictContainsCaseInsensitiveKey ()
		{
			var t = new UriTemplate ("/id-{foo}/{bar}");
			var dic = new Dictionary<string,string> ();
			dic ["foo"] = "aaa";
			dic ["Bar"] = "bbb";
			var uri = t.BindByName (new Uri ("http://localhost:8080"), dic);
			Assert.AreEqual ("http://localhost:8080/id-aaa/bbb", uri.ToString ());
		}
Exemplo n.º 30
0
		public void BindByNameWithDefaults ()
		{
			var d = new Dictionary<string,string> ();
			d.Add ("Bar", "value1"); // case insensitive
			d.Add ("FOO", "value2"); // case insensitive
			var t = new UriTemplate ("/{foo}/{bar}/", d);
			var u = t.BindByName (new Uri ("http://localhost/"), new NameValueCollection ());
			Assert.AreEqual ("http://localhost/value2/value1/", u.ToString ());
		}