Exemplo n.º 1
0
 protected override JSONValue HandlePost(Request request, JSONValue payload)
 {
     string str = payload.Get("action").AsString();
     switch (str)
     {
         case "move":
         {
             string from = request.Url.Substring("/unity/".Length);
             string to = payload.Get("newpath").AsString();
             this.MoveAsset(from, to);
             break;
         }
         case "create":
         {
             string assetPath = request.Url.Substring("/unity/".Length);
             byte[] bytes = Convert.FromBase64String(payload.Get("contents").AsString());
             string contents = Encoding.UTF8.GetString(bytes);
             this.CreateAsset(assetPath, contents);
             break;
         }
         default:
         {
             RestRequestException exception = new RestRequestException {
                 HttpStatusCode = HttpStatusCode.BadRequest,
                 RestErrorString = "Uknown action: " + str
             };
             throw exception;
         }
     }
     return new JSONValue();
 }
        protected override JSONValue HandlePost(Request request, JSONValue payload)
        {
            string str = payload.Get("action").AsString();
            string str2 = this.CurrentState();
            switch (str)
            {
                case "play":
                    EditorApplication.isPlaying = true;
                    EditorApplication.isPaused = false;
                    break;

                case "pause":
                    EditorApplication.isPaused = true;
                    break;

                case "stop":
                    EditorApplication.isPlaying = false;
                    break;

                default:
                {
                    RestRequestException exception = new RestRequestException {
                        HttpStatusCode = HttpStatusCode.BadRequest,
                        RestErrorString = "Invalid action: " + str
                    };
                    throw exception;
                }
            }
            JSONValue value3 = new JSONValue();
            value3["oldstate"] = str2;
            value3["newstate"] = this.CurrentState();
            return value3;
        }
    protected override JSONValue HandlePost(Request request, JSONValue payload)
    {
      string str1 = payload.Get("action").AsString();
      string str2 = this.CurrentState();
      string key = str1;
      if (key != null)
      {
        // ISSUE: reference to a compiler-generated field
        if (PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA == null)
        {
          // ISSUE: reference to a compiler-generated field
          PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA = new Dictionary<string, int>(3)
          {
            {
              "play",
              0
            },
            {
              "pause",
              1
            },
            {
              "stop",
              2
            }
          };
        }
        int num;
        // ISSUE: reference to a compiler-generated field
        if (PlayModeRestHandler.\u003C\u003Ef__switch\u0024mapA.TryGetValue(key, out num))
        {
          switch (num)
          {
            case 0:
              EditorApplication.isPlaying = true;
              EditorApplication.isPaused = false;
              break;
            case 1:
              EditorApplication.isPaused = true;
              break;
            case 2:
              EditorApplication.isPlaying = false;
              break;
            default:
              goto label_8;
          }
          JSONValue jsonValue = new JSONValue();
          jsonValue["oldstate"] = (JSONValue) str2;
          jsonValue["newstate"] = (JSONValue) this.CurrentState();
          return jsonValue;
        }
      }
label_8:
      throw new RestRequestException() { HttpStatusCode = HttpStatusCode.BadRequest, RestErrorString = "Invalid action: " + str1 };
    }
      protected override JSONValue HandlePost(Request request, JSONValue payload)
      {
        string str = payload.Get("action").AsString();
        string key = str;
        if (key != null)
        {
          // ISSUE: reference to a compiler-generated field
          if (AssetRestHandler.AssetHandler.\u003C\u003Ef__switch\u0024map9 == null)
          {
            // ISSUE: reference to a compiler-generated field
            AssetRestHandler.AssetHandler.\u003C\u003Ef__switch\u0024map9 = new Dictionary<string, int>(2)
            {
              {
                "move",
                0
              },
              {
                "create",
                1
              }
            };
          }
          int num;
          // ISSUE: reference to a compiler-generated field
          if (AssetRestHandler.AssetHandler.\u003C\u003Ef__switch\u0024map9.TryGetValue(key, out num))
          {
            if (num != 0)
            {
              if (num == 1)
                this.CreateAsset(request.Url.Substring("/unity/".Length), Encoding.UTF8.GetString(Convert.FromBase64String(payload.Get("contents").AsString())));
              else
                goto label_8;
            }
            else
              this.MoveAsset(request.Url.Substring("/unity/".Length), payload.Get("newpath").AsString());
            return new JSONValue();
          }
        }
label_8:
        throw new RestRequestException() { HttpStatusCode = HttpStatusCode.BadRequest, RestErrorString = "Uknown action: " + str };
      }