当前位置: 首页>>代码示例>>C#>>正文


C# UriTemplate.BindByPosition方法代码示例

本文整理汇总了C#中System.UriTemplate.BindByPosition方法的典型用法代码示例。如果您正苦于以下问题:C# UriTemplate.BindByPosition方法的具体用法?C# UriTemplate.BindByPosition怎么用?C# UriTemplate.BindByPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.UriTemplate的用法示例。


在下文中一共展示了UriTemplate.BindByPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncryptionButtonInValidateCard_Click

        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;
        }
开发者ID:jvutukur,项目名称:DistributedSoftwareDevelopmentProject,代码行数:30,代码来源:Payment.aspx.cs

示例2: SerializedCompetition

 public SerializedCompetition(Competition x, Uri Prefix, UriTemplate CompetitionTemplate, UriTemplate CompetitionResultTemplate)
 {
     ID = x.CompetitionID;
     Title = x.Title;
     Venue = x.Venue;
     ReferenceURI = CompetitionTemplate.BindByPosition(Prefix, ID.ToString());
     CompetitionResultsURI = CompetitionResultTemplate.BindByPosition(Prefix, ID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:8,代码来源:SerializedCompetition.cs

示例3: SerializedResult

 public SerializedResult(Result x, Uri Prefix, UriTemplate ResultResourceTemplate, UriTemplate FencerResourceTemplate,UriTemplate CompetitionResourceTemplate)
 {
     ID = x.ResultID;
     Placing = x.Placing;
     ReferenceURI = ResultResourceTemplate.BindByPosition(Prefix, ID.ToString());
     FencerURI = FencerResourceTemplate.BindByPosition(Prefix, x.FencerID.ToString());
     CompetitionURI = CompetitionResourceTemplate.BindByPosition(Prefix, x.CompetitionID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:8,代码来源:SerializedResult.cs

示例4: SerializedFencer

 public SerializedFencer(Fencer x, Uri Prefix, UriTemplate FencerTemplate, UriTemplate FencerResultTemplate)
 {
     ID = x.FencerID;
     LastName = x.LastName;
     FirstName = x.FirstName;
     Club = x.Club;
     ReferenceURI = FencerTemplate.BindByPosition(Prefix, ID.ToString());
     FencerResultsURI = FencerResultTemplate.BindByPosition(Prefix, ID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:9,代码来源:SerializedFencer.cs

示例5: SerializedResultArrayV1

    public SerializedResultArrayV1(List<Result> x, UriTemplateMatch templateMatch, Uri Prefix, UriTemplate ResultResourceTemplate, UriTemplate ResourceArrayTemplate)
    {
        Pagination = createPagination(x.Count,templateMatch, Prefix, ResourceArrayTemplate);

        List<SerializedResultArrayEntry> r = new List<SerializedResultArrayEntry>();
        foreach (Result result in x)
        {
            r.Add(new SerializedResultArrayEntry(result, Prefix, ResultResourceTemplate));
        }
        Results = filterResults(r);
        ReferenceURI = ResourceArrayTemplate.BindByPosition(Prefix,templateMatch.BoundVariables["id"]);
    }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:12,代码来源:SerializedResultArray.cs

示例6: formatUrls

    private void formatUrls(UriTemplate resourceUri, Uri prefix, int ID)
    {
        dynamic dynamicUrls = new ExpandoObject();
        //First

        if (page != 1)
        {

            Uri first = resourceUri.BindByPosition(prefix, ID.ToString(), "1");
            dynamicUrls.first = first;
            Uri previous = resourceUri.BindByPosition(prefix, ID.ToString(), (page - 1).ToString());
            dynamicUrls.previous = previous;
        }
        if (page != pages)
        {
            Uri last = resourceUri.BindByPosition(prefix, ID.ToString(), pages.ToString());
            dynamicUrls.last = last;
            Uri next = resourceUri.BindByPosition(prefix, ID.ToString(), (page + 1).ToString());
            dynamicUrls.next = next;
        }
        urls = dynamicUrls;
    }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:22,代码来源:PaginationMaker.cs

示例7: Main

        public static void Main()
        {
            Uri prefix = new Uri("http://localhost/");

            //A UriTemplate is a "URI with holes". It describes a set of URI's that
            //are structurally similar. This UriTemplate might be used for organizing
            //weather reports:
            UriTemplate template = new UriTemplate("weather/{state}/{city}");

            //You can convert a UriTemplate into a Uri by filling
            //the holes in the template with parameters.

            //BindByPosition moves left-to-right across the template
            Uri positionalUri = template.BindByPosition(prefix, "Washington", "Redmond");

            Console.WriteLine("Calling BindByPosition...");
            Console.WriteLine(positionalUri);
            Console.WriteLine();

            //BindByName takes a NameValueCollection of parameters. 
            //Each parameter gets substituted into the UriTemplate "hole"
            //that has the same name as the parameter.
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("state", "Washington");
            parameters.Add("city", "Redmond");

            Uri namedUri = template.BindByName(prefix, parameters);

            Console.WriteLine("Calling BindByName...");
            Console.WriteLine(namedUri);
            Console.WriteLine();


            //The inverse operation of Bind is Match(), which extrudes a URI
            //through the template to produce a set of name/value pairs.
            Uri fullUri = new Uri("http://localhost/weather/Washington/Redmond");
            UriTemplateMatch results = template.Match(prefix, fullUri);

            Console.WriteLine(String.Format("Matching {0} to {1}", template.ToString(), fullUri.ToString()));

            if (results != null)
            {
                foreach (string variableName in results.BoundVariables.Keys)
                {
                    Console.WriteLine(String.Format("   {0}: {1}", variableName, results.BoundVariables[variableName]));
                }
            }

            Console.WriteLine("Press any key to terminate");
            Console.ReadLine();
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:51,代码来源:Program.cs

示例8: Create

        public void Create(Movie movie)
        {
            WebOperationContext context = WebOperationContext.Current;

            UriTemplateMatch match = context.IncomingRequest.UriTemplateMatch;
            UriTemplate template = new UriTemplate("/movie/{id}");

            index++; // generate new ID
            movie.ID = index;
            movies.Add(index, movie);

            Uri uri = template.BindByPosition(match.BaseUri, movie.ID.ToString());
         
            context.OutgoingResponse.SetStatusAsCreated(uri);
            context.OutgoingResponse.StatusDescription = String.Format("Movie id '{0}' created", movie.ID);
        }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:16,代码来源:MovieService.svc.cs

示例9: AddCustomer

        public Customer AddCustomer(Customer customer)
        {
            lock (writeLock)
            {
                counter++;
                UriTemplateMatch match = WebOperationContext.Current.IncomingRequest.UriTemplateMatch;

                UriTemplate template = new UriTemplate("{id}");
                customer.Uri = template.BindByPosition(match.BaseUri, counter.ToString());

                customers[counter.ToString()] = customer;

                WebOperationContext.Current.OutgoingResponse.SetStatusAsCreated(customer.Uri);
            }

            return customer;
        }
开发者ID:ssickles,项目名称:archive,代码行数:17,代码来源:Service.cs

示例10: get_UV_Index

        public string get_UV_Index(String zipcode)
        {
            String uvIndex = "";
            try
            {

                Uri baseUri = new Uri("http://iaspub.epa.gov/enviro/efservice/getEnvirofactsUVDAILY");
                UriTemplate myTemplate = new UriTemplate("/ZIP/{zipCode}");
                Uri completeUri = myTemplate.BindByPosition(baseUri, zipcode);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(completeUri.ToString());

                uvIndex =uvIndex+ xmlDoc.GetElementsByTagName("UV_INDEX")[0].InnerText;

                int indexAsInt = Int32.Parse(uvIndex);

                if(uvIndex=="")
                {
                    uvIndex="Invalid zipcode. Please try againg";
                }
                else if(indexAsInt<=5)
                {

                    uvIndex = "Uv Index value is " + uvIndex + " \n 0-5 is moderate";
                }
                else if(indexAsInt<=8)
                {

                    //6-8 is high
                    uvIndex = "Today UV Index value in this location is " + uvIndex + "  (6-8 is high)";
                }
                else
                {
                    //above 8 better stay inside
                    uvIndex = "UV Index value in this location is " + uvIndex + " ( 8-11 is very high take necessary precautions)";
                }
                //A character indicating if there is a UV Index alert issued for this area on the forecast day.

            }
            catch(Exception e)
            {

            }
            return uvIndex;
        }
开发者ID:jvutukur,项目名称:DistributedSoftwareDevelopmentProject,代码行数:46,代码来源:Service1.svc.cs

示例11: GetValidURIs

        public IEnumerable<Uri> GetValidURIs()
        {
            var _context = SelectedAssets.FirstOrDefault().GetMediaContext();
            IEnumerable<Uri> ValidURIs;
            IAsset asset = SelectedAssets.FirstOrDefault();
            var ismFile = asset.AssetFiles.AsEnumerable().Where(f => f.Name.EndsWith(".ism")).OrderByDescending(f => f.IsPrimary).FirstOrDefault();
            if (ismFile != null)
            {
                var locators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin && l.ExpirationDateTime > DateTime.UtcNow).OrderByDescending(l => l.ExpirationDateTime);

                var template = new UriTemplate("{contentAccessComponent}/{ismFileName}/manifest");
                ValidURIs = locators.SelectMany(l =>
                    _context
                        .StreamingEndpoints
                        .AsEnumerable()
                          .Where(o => (o.State == StreamingEndpointState.Running) && (o.ScaleUnits > 0))
                          .OrderByDescending(o => o.CdnEnabled)
                        .Select(
                            o =>
                                template.BindByPosition(new Uri("http://" + o.HostName), l.ContentAccessComponent,
                                    ismFile.Name)))
                    .ToArray();

                return ValidURIs;
            }
            else
            {
                return null;
            }
        }
开发者ID:flvlef,项目名称:Azure-Media-Services-Explorer,代码行数:30,代码来源:Program.cs

示例12: SearchFromFingerprint

      public static XElement SearchFromFingerprint(int duration, string fingerprint)
      {
         var ut = new UriTemplate("v2/lookup?client=JnD0gnNt&meta=recordings&format=xml&duration={0}&fingerprint={1}");
         Uri url = ut.BindByPosition(new Uri("http://api.acoustid.org"), duration.ToString(), fingerprint);

         using (var web = new WebClient())
         {
            web.Encoding = Encoding.UTF8;
            return XElement.Parse(web.DownloadString(url));
         }
      }
开发者ID:CyberSinh,项目名称:Luminescence.Audio,代码行数:11,代码来源:Program.cs

示例13: SerializedResultArrayEntry

 public SerializedResultArrayEntry(Result x, Uri Prefix, UriTemplate ResultResourceTemplate)
 {
     ID = x.ResultID;
     ReferenceURI = ResultResourceTemplate.BindByPosition(Prefix, ID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:5,代码来源:SerializedResultArrayEntry.cs

示例14: GetTorrentFileUrlToPublish

 /// <summary>
 /// Gets the torrent file download Uri with which other peers can download 
 /// the torrent file from this server.
 /// </summary>
 /// <param name="nameSpace">The name space.</param>
 /// <param name="name">The name.</param>
 public string GetTorrentFileUrlToPublish(string nameSpace, string name)
 {
     var template = new UriTemplate("TorrentData/{namespace}/{name}/TorrentFile");
       var baseAddr = string.Format("http://{0}:{1}", _hostIP, _gsserverPort);
       Uri retVal = template.BindByPosition(new Uri(baseAddr), nameSpace, name);
       return retVal.ToString();
 }
开发者ID:xujyan,项目名称:hurricane,代码行数:13,代码来源:TorrentHelper.cs

示例15: ReturnMainStreamingURLs

       public static System.Collections.Generic.List<System.Uri> ReturnMainStreamingURLs(string aChannelName)
        {
            //Set Azure credentials
            if (_context == null)
                SetMediaServicesCredentials();

        //    _context.Assets.Where(a => a.Name == aAssetName).FirstOrDefault();

          //  var asset = _context.Assets.Where(a => a.Name == aAssetName).FirstOrDefault();
           
          var asset = _context.Channels.Where(c => c.Name == aChannelName).FirstOrDefault().Programs.FirstOrDefault().Asset;
                //context.Channels.Where(c=> c.Name == aChannelName).FirstOrDefault().Programs.FirstOrDefault().Asset;
            var locators = asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin);
            var ismFile = asset.AssetFiles.AsEnumerable().FirstOrDefault(a => a.Name.EndsWith(".ism"));
            var template = new UriTemplate("{contentAccessComponent}/{ismFileName}/manifest");
            
            return locators.SelectMany(l =>
                                      _context
                                          .StreamingEndpoints
                                          .AsEnumerable()
                                          .Where(se => se.State == StreamingEndpointState.Running)
                                          .Select(
                                              se =>
                                              template.BindByPosition(new Uri("http://" + se.HostName),
                                                                      l.ContentAccessComponent,
                                                                      ismFile.Name)))
           .ToList();

        }
开发者ID:villalongacu,项目名称:VooPpointMgr,代码行数:29,代码来源:VooAzureStreamFacade.cs


注:本文中的System.UriTemplate.BindByPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。