コード例 #1
0
        public override void HandleRequest(HttpContextBase context)
        {
            if (CanHandle(context))
            {
                try
                {
                    var installedPackage = _installationRecorder.GetLatestPackage();

                    if (installedPackage is InstalledPackageNotFound)
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                    }
                    else
                    {
                        var json = new JavaScriptSerializer().Serialize(new { installedPackage });

                        JsonResponse(json, HttpStatusCode.OK, context);
                    }
                }
                catch (NotFoundException)
                {
                    context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                }
            }
            else if (Successor != null)
            {
                Successor.HandleRequest(context);
            }
        }
コード例 #2
0
        public override void HandleRequest(HttpContextBase context)
        {
            if (CanHandle(context))
            {
                var packageName = context.Request["name"];
                if (!string.IsNullOrWhiteSpace(packageName))
                {
                    var versionText = UpdatePackageVersionRetriver.GetUpdatePackageVersion(packageName);
                    TextResponse(versionText, HttpStatusCode.OK, context);
                    return;
                }

                try
                {
                    var installedPackage = _installationRecorder.GetLatestPackage();

                    if (installedPackage is InstalledPackageNotFound)
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                    }
                    else
                    {
                        var json = Json.Encode(new { installedPackage });

                        JsonResponse(json, HttpStatusCode.OK, context);
                    }
                }
                catch (NotFoundException)
                {
                    context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                }
            }
            else if (Successor != null)
            {
                Successor.HandleRequest(context);
            }
        }
コード例 #3
0
        private dynamic LatestVersion(dynamic o)
        {
            try
            {
                var installedPackage = _installationRecorder.GetLatestPackage();

                if (installedPackage is InstalledPackageNotFound)
                {
                    return(new Response
                    {
                        StatusCode = HttpStatusCode.NoContent
                    });
                }

                return(Response.AsJson(installedPackage));
            }
            catch (NotFoundException)
            {
                return(new Response
                {
                    StatusCode = HttpStatusCode.NotFound
                });
            }
        }