public static string ToJson(this ResponseApi self) { JsonSerializerSettings settings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }; var json = JsonConvert.SerializeObject(self, settings); return(json); }
public override void LoadProjectStructure(int projectId, Action <ProjectStructure> onFinish) { string structureRequestString = string.Format(ApiRoutes.ProjectStructureRequest, projectId); var structureRequest = new RequestApi(structureRequestString); Logger.Info("API request: " + structureRequestString); structureRequest.OnFinish += response => { ResponseApi structureResponseApi = (ResponseApi)response; if (!Helper.IsResponseGood(structureResponseApi)) { Logger.Fatal("Can not get " + structureRequestString); onFinish.Invoke(null); return; } string projectStructureJson = structureResponseApi.Data.ToString(); ProjectStructure currentProjectStructure = projectStructureJson.JsonDeserialize <ProjectStructure>(); foreach (var scene in currentProjectStructure.Scenes) { var logicRequest = new RequestUri(scene.LogicResource); logicRequest.OnFinish += response1 => { ResponseUri logicResponse = (ResponseUri)response1; scene.AssemblyBytes = logicResponse.ByteData; }; } onFinish.Invoke(currentProjectStructure); }; }