當前位置: 首頁>>代碼示例>>C#>>正文


C# System.UriTemplateMatch類代碼示例

本文整理匯總了C#中System.UriTemplateMatch的典型用法代碼示例。如果您正苦於以下問題:C# UriTemplateMatch類的具體用法?C# UriTemplateMatch怎麽用?C# UriTemplateMatch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UriTemplateMatch類屬於System命名空間,在下文中一共展示了UriTemplateMatch類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test1Handler

 private void Test1Handler(HttpEntityManager http, UriTemplateMatch match)
 {
     if (http.User != null) 
         http.Reply("OK", 200, "OK", "text/plain");
     else 
         http.Reply("Please authenticate yourself", 401, "Unauthorized", "text/plain");
 }
開發者ID:kijanawoodard,項目名稱:EventStore,代碼行數:7,代碼來源:TestController.cs

示例2: TestEncodingHandler

        private void TestEncodingHandler(HttpEntityManager http, UriTemplateMatch match)
        {
            var a = match.BoundVariables["a"];
            var b = match.BoundVariables["b"];

            http.Reply(new { a = a, b = b, rawSegment = http.RequestedUrl.Segments[2] }.ToJson(), 200, "OK", "application/json");
        }
開發者ID:kijanawoodard,項目名稱:EventStore,代碼行數:7,代碼來源:TestController.cs

示例3: TestAnonymousHandler

 private void TestAnonymousHandler(HttpEntityManager http, UriTemplateMatch match)
 {
     if (http.User != null)
         http.Reply("ERROR", 500, "ERROR", "text/plain");
     else 
         http.Reply("OK", 200, "OK", "text/plain");
 }
開發者ID:kijanawoodard,項目名稱:EventStore,代碼行數:7,代碼來源:TestController.cs

示例4: Find

 public RouteHandler Find(HttpListenerRequest request, out UriTemplateMatch templateMatch)
 {
     var reqId = request.HttpMethod + ":" + request.Url.LocalPath;
     KeyValuePair<RouteHandler, Uri> rh;
     if (Cache.TryGetValue(reqId, out rh))
     {
         templateMatch = rh.Key.Template.Match(rh.Value, request.Url);
         return rh.Key;
     }
     templateMatch = null;
     List<RouteHandler> handlers;
     if (!MethodRoutes.TryGetValue(request.HttpMethod, out handlers))
         return null;
     var reqUrl = request.Url;
     var url = reqUrl.ToString();
     var baseAddr = new Uri(url.Substring(0, url.Length - request.RawUrl.Length));
     foreach (var h in handlers)
     {
         var match = h.Template.Match(baseAddr, reqUrl);
         if (match != null)
         {
             templateMatch = match;
             Cache.TryAdd(reqId, new KeyValuePair<RouteHandler, Uri>(h, baseAddr));
             return h;
         }
     }
     return null;
 }
開發者ID:nutrija,項目名稱:revenj,代碼行數:28,代碼來源:Routes.cs

示例5: OnPostShutdown

 private void OnPostShutdown(HttpEntity entity, UriTemplateMatch match)
 {
     Publish(new ClientMessage.RequestShutdown());
     entity.Manager.Reply(HttpStatusCode.OK,
                          "OK",
                          e => Log.ErrorException(e, "Error while closing http connection (admin controller)"));
 }
開發者ID:robashton,項目名稱:EventStore,代碼行數:7,代碼來源:AdminController.cs

示例6: OnGetFreshStats

        private void OnGetFreshStats(HttpEntityManager entity, UriTemplateMatch match)
        {
            var envelope = new SendToHttpEnvelope(_networkSendQueue,
                                                  entity,
                                                  Format.GetFreshStatsCompleted,
                                                  Configure.GetFreshStatsCompleted);

            var statPath = match.BoundVariables["statPath"];
            var statSelector = GetStatSelector(statPath);

            bool useMetadata;
            if (!bool.TryParse(match.QueryParameters["metadata"], out useMetadata))
                useMetadata = false;

            bool useGrouping;
            if (!bool.TryParse(match.QueryParameters["group"], out useGrouping))
                useGrouping = true;

            if (!useGrouping && !string.IsNullOrEmpty(statPath))
            {
                SendBadRequest(entity, "Dynamic stats selection works only with grouping enabled");
                return;
            }
             
            Publish(new MonitoringMessage.GetFreshStats(envelope, statSelector, useMetadata, useGrouping));
        }
開發者ID:Kristinn-Stefansson,項目名稱:EventStore,代碼行數:26,代碼來源:StatController.cs

示例7: AckMessages

        private void AckMessages(HttpEntityManager http, UriTemplateMatch match)
        {
            var envelope = new NoopEnvelope();
            var groupname = match.BoundVariables["subscription"];
            var stream = match.BoundVariables["stream"];
            var messageIds = match.BoundVariables["messageIds"];
            var ids = new List<Guid>();
            foreach (var messageId in messageIds.Split(new[] { ',' }))
            {
                Guid id;
                if (!Guid.TryParse(messageId, out id))
                {
                    http.ReplyStatus(HttpStatusCode.BadRequest, "messageid should be a properly formed guid", exception => { });
                    return;
                }
                ids.Add(id);
            }

            var cmd = new ClientMessage.PersistentSubscriptionAckEvents(
                                             Guid.NewGuid(),
                                             Guid.NewGuid(),
                                             envelope,
                                             BuildSubscriptionGroupKey(stream, groupname),
                                             ids.ToArray(),
                                             http.User);
            Publish(cmd);
            http.ReplyStatus(HttpStatusCode.Accepted, "", exception => { });
        }
開發者ID:EventStore,項目名稱:EventStore,代碼行數:28,代碼來源:PersistentSubscriptionController.cs

示例8: TryUriTemplateMatch

 private bool TryUriTemplateMatch(string uri, out UriTemplateMatch uriTemplateMatch)
 {
     var uriTemplate = new UriTemplate(uri);
     var serverPath = Request.Url.GetServerBaseUri();
     uriTemplateMatch = uriTemplate.Match(new Uri(serverPath), Request.Url);
     return uriTemplateMatch != null;
 }
開發者ID:JamesTryand,項目名稱:minimods,代碼行數:7,代碼來源:HttpContext.cs

示例9: OnPostShutdown

 private void OnPostShutdown(HttpEntity entity, UriTemplateMatch match)
 {
     Log.Info("Request shut down of node because shutdown command has been received.");
     Publish(new ClientMessage.RequestShutdown(exitProcessOnShutdown: true));
     entity.Manager.ReplyStatus(HttpStatusCode.OK,
                          "OK",
                          e => Log.ErrorException(e, "Error while closing http connection (admin controller)"));
 }
開發者ID:base31,項目名稱:geteventstore_EventStore,代碼行數:8,代碼來源:AdminController.cs

示例10: OnGetTcpConnectionStats

 private void OnGetTcpConnectionStats(HttpEntityManager entity, UriTemplateMatch match)
 {
     var envelope = new SendToHttpEnvelope(_networkSendQueue,
                                           entity,
                                           Format.GetFreshTcpConnectionStatsCompleted,
                                           Configure.GetFreshTcpConnectionStatsCompleted);
     Publish(new MonitoringMessage.GetFreshTcpConnectionStats(envelope));
 }
開發者ID:SzymonPobiega,項目名稱:EventStore,代碼行數:8,代碼來源:StatController.cs

示例11: UriToActionMatch

 public UriToActionMatch(UriTemplateMatch templateMatch, 
                         ControllerAction controllerAction, 
                         Func<HttpEntityManager, UriTemplateMatch, RequestParams> requestHandler)
 {
     TemplateMatch = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler = requestHandler;
 }
開發者ID:Kristinn-Stefansson,項目名稱:EventStore,代碼行數:8,代碼來源:UriToActionMatch.cs

示例12: UriToActionMatch

 public UriToActionMatch(UriTemplateMatch templateMatch, 
                         ControllerAction controllerAction, 
                         Action<HttpEntity, UriTemplateMatch> requestHandler)
 {
     TemplateMatch = templateMatch;
     ControllerAction = controllerAction;
     RequestHandler = requestHandler;
 }
開發者ID:base31,項目名稱:geteventstore_EventStore,代碼行數:8,代碼來源:UriToActionMatch.cs

示例13: OnGetOptions

 private void OnGetOptions(HttpEntityManager entity, UriTemplateMatch match)
 {
     entity.ReplyTextContent(Codec.Json.To(GetOptionsInfo(options)),
                             HttpStatusCode.OK,
                             "OK",
                             entity.ResponseCodec.ContentType,
                             null,
                             e => Log.ErrorException(e, "error while writing http response (options)"));
 }
開發者ID:BrunoMVPCosta,項目名稱:EventStore,代碼行數:9,代碼來源:InfoController.cs

示例14: SerializedResultArrayBeta

 public SerializedResultArrayBeta(List<Result> x, UriTemplateMatch templateMatch, Uri Prefix, UriTemplate ResultResourceTemplate, UriTemplate ResourceArrayTemplate)
 {
     List<SerializedResultArrayEntry> r = new List<SerializedResultArrayEntry>();
     foreach (Result result in x)
     {
         r.Add(new SerializedResultArrayEntry(result, Prefix, ResultResourceTemplate));
     }
     Results = r;
 }
開發者ID:TheHandsomeCoder,項目名稱:SOFT512RestAPI,代碼行數:9,代碼來源:SerializedResultArray.cs

示例15: GetPrincipal

        /// <summary>
        /// Virtual method to be able to extend principal.
        /// Returns "Guest" identity with no roles.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="match"></param>
        /// <returns></returns>
        public virtual IPrincipal GetPrincipal(HttpContext context, UriTemplateMatch match)
        {
            // using System.Security.Permissions;
            // using System.Security.Principal;

            GenericIdentity gi = new GenericIdentity("Guest");
            GenericPrincipal genPrincipal = new GenericPrincipal(gi, new string[]{});

            return genPrincipal;
        }
開發者ID:swizkon,項目名稱:gigagoga,代碼行數:17,代碼來源:RESTRouter.cs


注:本文中的System.UriTemplateMatch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。