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


C# EntityManagement.HttpEntity类代码示例

本文整理汇总了C#中EventStore.Transport.Http.EntityManagement.HttpEntity的典型用法代码示例。如果您正苦于以下问题:C# HttpEntity类的具体用法?C# HttpEntity怎么用?C# HttpEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpEntity类属于EventStore.Transport.Http.EntityManagement命名空间,在下文中一共展示了HttpEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadEventCompleted

        public static ResponseConfiguration ReadEventCompleted(HttpEntity entity, Message message)
        {
            Debug.Assert(message.GetType() == typeof(ClientMessage.ReadEventCompleted));

            var completed = message as ClientMessage.ReadEventCompleted;
            if (completed == null)
                return InternalServerEror(entity, message);

            switch (completed.Result)
            {
                case SingleReadResult.Success:
                    return new ResponseConfiguration(HttpStatusCode.OK, 
                                                     "OK",
                                                     entity.ResponseCodec.ContentType,
                                                     new KeyValuePair<string, string>(
                                                         "Cache-Control",
                                                         string.Format("max-age={0}", MaxPossibleAge)));
                case SingleReadResult.NotFound:
                case SingleReadResult.NoStream:
                    return NotFound(entity, completed);
                case SingleReadResult.StreamDeleted:
                    return Gone(entity, completed);
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:26,代码来源:Configure.cs

示例2: ReadEventsBackwardsCompletedFeed

            public static string ReadEventsBackwardsCompletedFeed(HttpEntity entity, Message message, int start, int count)
            {
                Debug.Assert(message.GetType() == typeof(ClientMessage.ReadEventsBackwardsCompleted));

                var completed = message as ClientMessage.ReadEventsBackwardsCompleted;
                if (completed != null)
                {
                    switch (completed.Result)
                    {
                        case RangeReadResult.Success:
                            var updateTime = completed.Events.Length != 0
                                                 ? completed.Events[0].TimeStamp
                                                 : DateTime.MinValue.ToUniversalTime();
                            return entity.ResponseCodec.To(Convert.ToFeed(completed.EventStreamId,
                                                                          start,
                                                                          count,
                                                                          updateTime,
                                                                          completed.Events,
                                                                          Convert.ToEntry,
                                                                          entity.ServerHttpEndPoint));
                        case RangeReadResult.NoStream:
                        case RangeReadResult.StreamDeleted:
                            return string.Empty;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                return string.Empty;
            }
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:29,代码来源:Format.cs

示例3: TextMessage

        public static string TextMessage(HttpEntity entity, Message message)
        {
            Debug.Assert(message.GetType() == typeof(HttpMessage.TextMessage));

            var textMessage = message as HttpMessage.TextMessage;
            return textMessage != null ? entity.ResponseCodec.To(textMessage) : string.Empty;
        }
开发者ID:alistair,项目名称:EventStore,代码行数:7,代码来源:Format.cs

示例4: 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

示例5: CreateStreamCompleted

        public static ResponseConfiguration CreateStreamCompleted(HttpEntity entity, Message message)
        {
            Debug.Assert(message.GetType() == typeof(ClientMessage.CreateStreamCompleted));

            var completed = message as ClientMessage.CreateStreamCompleted;
            if (completed == null)
                return InternalServerEror(entity, message);

            switch (completed.ErrorCode)
            {
                case OperationErrorCode.Success:
                    return new ResponseConfiguration(HttpStatusCode.Created,
                                                     "Stream created",
                                                     null,
                                                     new KeyValuePair<string, string>("Location",
                                                                                      HostName.Combine(entity.UserHostName,
                                                                                                  "/streams/{0}",
                                                                                                  completed.EventStreamId)));
                case OperationErrorCode.PrepareTimeout:
                case OperationErrorCode.CommitTimeout:
                case OperationErrorCode.ForwardTimeout:
                    return new ResponseConfiguration(HttpStatusCode.InternalServerError, "Create timeout", null);
                case OperationErrorCode.WrongExpectedVersion:
                case OperationErrorCode.StreamDeleted:
                case OperationErrorCode.InvalidTransaction:
                    return new ResponseConfiguration(HttpStatusCode.BadRequest,
                                                     string.Format("Error code : {0}. Reason : {1}", completed.ErrorCode, completed.Error),
                                                     null);
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:slavah,项目名称:EventStore,代码行数:32,代码来源:Configure.cs

示例6: OnGetFreshStats

        private void OnGetFreshStats(HttpEntity 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:base31,项目名称:geteventstore_EventStore,代码行数:26,代码来源:StatController.cs

示例7: HttpEntity

        private HttpEntity(HttpEntity httpEntity, IPrincipal user)
        {
            RequestedUrl = httpEntity.RequestedUrl;

            Request = httpEntity.Request;
            Response = httpEntity.Response;
            User = user;
        }
开发者ID:adbrowne,项目名称:EventStore,代码行数:8,代码来源:HttpEntity.cs

示例8: 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

示例9: ManagerOperationState

        public ManagerOperationState(HttpEntity entity, Action<HttpEntityManager, string> onSuccess, Action<Exception> onError)
        {
            Ensure.NotNull(entity, "entity");
            Ensure.NotNull(onSuccess, "onSuccess");
            Ensure.NotNull(onError, "onError");

            Entity = entity;
            OnSuccess = onSuccess;
            OnError = onError;
        }
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:10,代码来源:ManagerOperationState.cs

示例10: OnGetPing

 private void OnGetPing(HttpEntity entity, UriTemplateMatch match)
 {
     var response = new HttpMessage.TextMessage("Ping request successfully handled");
     entity.Manager.Reply(Format.TextMessage(entity, response),
                          HttpStatusCode.OK,
                          "OK",
                          entity.ResponseCodec.ContentType,
                          null,
                          e => Log.ErrorException(e, "Error while writing http response (ping)"));
 }
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:10,代码来源:PingController.cs

示例11: GetFreshStatsCompleted

        public static string GetFreshStatsCompleted(HttpEntity entity, Message message)
        {
            Debug.Assert(message.GetType() == typeof(MonitoringMessage.GetFreshStatsCompleted));

            var completed = message as MonitoringMessage.GetFreshStatsCompleted;
            if (completed == null || !completed.Success)
                return string.Empty;

            return entity.ResponseCodec.To(completed.Stats);
        }
开发者ID:alistair,项目名称:EventStore,代码行数:10,代码来源:Format.cs

示例12: HttpEntityManager

        internal HttpEntityManager(HttpEntity httpEntity, string[] allowedMethods, Action<HttpEntity> onRequestSatisfied)
        {
            Ensure.NotNull(httpEntity, "httpEntity");
            Ensure.NotNull(allowedMethods, "allowedMethods");
            Ensure.NotNull(onRequestSatisfied, "onRequestSatisfied");

            HttpEntity = httpEntity;

            _allowedMethods = allowedMethods;
            _onRequestSatisfied = onRequestSatisfied;
        }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:11,代码来源:HttpEntityManager.cs

示例13: ListStreamsCompletedServiceDoc

            public static string ListStreamsCompletedServiceDoc(HttpEntity entity, Message message)
            {
                Debug.Assert(message.GetType() == typeof(ClientMessage.ListStreamsCompleted));

                var streams = message as ClientMessage.ListStreamsCompleted;
                return streams != null
                           ? entity.ResponseCodec.To(Convert.ToServiceDocument(streams.Streams,
                                                                               new string[0],
                                                                               entity.ServerHttpEndPoint))
                           : string.Empty;
            }
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:11,代码来源:Format.cs

示例14: GetAllBefore

 public void GetAllBefore(HttpEntity entity, TFPos position, int count)
 {
     var envelope = new SendToHttpEnvelope(entity,
                                           Format.Atom.ReadAllEventsBackwardCompleted,
                                           Configure.ReadAllEventsBackwardCompleted);
     Publish(new ClientMessage.ReadAllEventsBackward(Guid.NewGuid(),
                                                     envelope,
                                                     position.CommitPosition,
                                                     position.PreparePosition,
                                                     count,
                                                     true));
 }
开发者ID:robashton,项目名称:EventStore,代码行数:12,代码来源:AtomControllerDefinitions.cs

示例15: OnGetFreshStats

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

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

            Publish(new MonitoringMessage.GetFreshStats(envelope, statSelector));
        }
开发者ID:jpierson,项目名称:EventStore,代码行数:12,代码来源:StatController.cs


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