System.UriTemplate.BindByPosition C# (CSharp) Method

BindByPosition() public method

public BindByPosition ( Uri baseAddress ) : Uri
baseAddress Uri
return Uri
		public Uri BindByPosition (Uri baseAddress, params string [] values)
		{
			CheckBaseAddress (baseAddress);

			if (values.Length != path.Count + query.Count)
				throw new FormatException (String.Format ("Template '{0}' contains {1} parameters but the argument values to bind are {2}", template, path.Count + query.Count, values.Length));

			int src = 0, index = 0;
			StringBuilder sb = new StringBuilder (template.Length);
			BindByPosition (ref src, sb, path, values, ref index);
			BindByPosition (ref src, sb, query, values, ref index);
			sb.Append (template.Substring (src));
			return new Uri (baseAddress.ToString () + TrimRenderedUri (sb));
		}

Same methods

UriTemplate::BindByPosition ( int &src, StringBuilder sb, ReadOnlyCollection names, string values, int &index ) : void

Usage Example

        protected void EncryptionButtonInValidateCard_Click(object sender, EventArgs e)
        {
            Uri baseUri = new Uri("http://webstrar49.fulton.asu.edu/page3/Service1.svc");
            UriTemplate myTemplate = new UriTemplate("encrypt?plainText={plainText}");

            String plainText = PlainText_TextBox1.Text;
            Uri completeUri = myTemplate.BindByPosition(baseUri, plainText);

            System.Net.WebClient webClient = new System.Net.WebClient();
            byte[] content = webClient.DownloadData(completeUri);

            //EncryptionService.Service1Client encryptionClient = new EncryptionService.Service1Client();
            // String cipher=encryptionClient.encrypt(plainText);

            String contentinString = Encoding.UTF8.GetString(content, 0, content.Length);

            String pattern = @"(?<=\>)(.*?)(?=\<)";
            Regex r = new Regex(pattern);
            Match m = r.Match(contentinString);

            String cipher = "";
            if (m.Success)
            {
                cipher = m.Groups[1].ToString();
            }

            cipherTextBox.Enabled = true;
            cipherTextBox.Text = cipher;
            cipherTextBox.Enabled = false;
        }
All Usage Examples Of System.UriTemplate::BindByPosition