private static void UnmarshallResult(XmlUnmarshallerContext context, CreateHealthCheckResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 1;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("HealthCheck", targetDepth))
                    {
                        var unmarshaller = HealthCheckUnmarshaller.Instance;
                        response.HealthCheck = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }

            return;
        }
Пример #2
0
        public static CreateHealthCheckResponse Unmarshall(UnmarshallerContext context)
        {
            CreateHealthCheckResponse createHealthCheckResponse = new CreateHealthCheckResponse();

            createHealthCheckResponse.HttpResponse       = context.HttpResponse;
            createHealthCheckResponse.RequestId          = context.StringValue("CreateHealthCheck.RequestId");
            createHealthCheckResponse.CreateTime         = context.LongValue("CreateHealthCheck.CreateTime");
            createHealthCheckResponse.InstanceId         = context.StringValue("CreateHealthCheck.InstanceId");
            createHealthCheckResponse.SmartAGId          = context.StringValue("CreateHealthCheck.SmartAGId");
            createHealthCheckResponse.Name               = context.StringValue("CreateHealthCheck.Name");
            createHealthCheckResponse.RegionId           = context.StringValue("CreateHealthCheck.RegionId");
            createHealthCheckResponse.Description        = context.StringValue("CreateHealthCheck.Description");
            createHealthCheckResponse.Type               = context.StringValue("CreateHealthCheck.Type");
            createHealthCheckResponse.DstIpAddr          = context.StringValue("CreateHealthCheck.DstIpAddr");
            createHealthCheckResponse.DstPort            = context.IntegerValue("CreateHealthCheck.DstPort");
            createHealthCheckResponse.SrcIpAddr          = context.StringValue("CreateHealthCheck.SrcIpAddr");
            createHealthCheckResponse.SrcPort            = context.IntegerValue("CreateHealthCheck.SrcPort");
            createHealthCheckResponse.ProbeInterval      = context.IntegerValue("CreateHealthCheck.ProbeInterval");
            createHealthCheckResponse.ProbeCount         = context.IntegerValue("CreateHealthCheck.ProbeCount");
            createHealthCheckResponse.ProbeTimeout       = context.IntegerValue("CreateHealthCheck.ProbeTimeout");
            createHealthCheckResponse.RttThreshold       = context.IntegerValue("CreateHealthCheck.RttThreshold");
            createHealthCheckResponse.RttFailThreshold   = context.IntegerValue("CreateHealthCheck.RttFailThreshold");
            createHealthCheckResponse.FailCountThreshold = context.IntegerValue("CreateHealthCheck.FailCountThreshold");

            return(createHealthCheckResponse);
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHealthChecks("/health/liveness", new HealthCheckOptions()
            {
                Predicate = (check) => check.Tags.Contains("liveness"),

                ResponseWriter = async(context, report) =>
                {
                    context.Response.ContentType = "application/json";

                    await context.Response.WriteAsync(
                        JsonConvert.SerializeObject(
                            CreateHealthCheckResponse.Create(report)));
                }
            });

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseOcelot().Wait();
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            CreateHealthCheckResponse response = new CreateHealthCheckResponse();

            UnmarshallResult(context, response);
            if (context.ResponseData.IsHeaderPresent("Location"))
            {
                response.Location = context.ResponseData.GetHeaderValue("Location");
            }

            return(response);
        }
Пример #5
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            CreateHealthCheckResponse response = new CreateHealthCheckResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    response.CreateHealthCheckResult = CreateHealthCheckResultUnmarshaller.GetInstance().Unmarshall(context);
                    break;
                }
            }

            return(response);
        }
Пример #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "eMobile.Phones.API v1"));
            }

            app.UseHealthChecks("/health/readiness", new HealthCheckOptions()
            {
                Predicate = (check) => check.Tags.Contains("readiness"),

                ResponseWriter = async(context, report) =>
                {
                    context.Response.ContentType = "application/json";

                    await context.Response.WriteAsync(
                        JsonConvert.SerializeObject(
                            CreateHealthCheckResponse.Create(report)));
                }
            });

            app.UseHealthChecks("/health/liveness", new HealthCheckOptions()
            {
                Predicate = (check) => check.Tags.Contains("liveness"),

                ResponseWriter = async(context, report) =>
                {
                    context.Response.ContentType = "application/json";

                    await context.Response.WriteAsync(
                        JsonConvert.SerializeObject(
                            CreateHealthCheckResponse.Create(report)));
                }
            });

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, CreateHealthCheckResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("HealthCheck", targetDepth))
                    {
                        response.HealthCheck = HealthCheckUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }


            IWebResponseData responseData = context.ResponseData;

            if (responseData.IsHeaderPresent("Location"))
            {
                response.Location = responseData.GetHeaderValue("Location");
            }


            return;
        }