System.UriTemplate.BindByPosition C# (CSharp) Method

BindByPosition() private method

private BindByPosition ( int &src, StringBuilder sb, ReadOnlyCollection names, string values, int &index ) : void
src int
sb StringBuilder
names ReadOnlyCollection
values string
index int
return void
		void BindByPosition (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, string [] values, ref int index)
		{
			for (int i = 0; i < names.Count; i++) {
				int s = template.IndexOf ('{', src);
				int e = template.IndexOf ('}', s + 1);
				sb.Append (template.Substring (src, s - src));
				string value = values [index++];
				if (value == null)
					throw new FormatException (String.Format ("The argument value collection contains null at {0}", index - 1));
				sb.Append (value);
				src = e + 1;
			}
		}

Same methods

UriTemplate::BindByPosition ( Uri baseAddress ) : Uri

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