private void CreateTypeFiles() { foreach (var solution in StepInput.SDProject.Solutions.Values) { var sdRepository = solution.Repositories.SingleOrDefault(r => r.TargetFx.Identifier == StepInput.CurrentTargetFx.Identifier); if (sdRepository != null) { foreach (var sdNamespace in sdRepository.GetAllNamespaces()) { foreach (var sdType in sdNamespace.Types) { ExecuteOnStepMessage(string.Format("{0}: {1}", StepInput.ChmStrings.CreateType, sdType.Name)); var typeHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + ".html"); var template = new TypeTemplate { SDType = sdType, SDRepository = sdRepository }; if (!sdType.IsClassDiagramEmpty()) { sdType.GetClassDiagram().ToPng(Path.Combine(StepInput.TmpPath, "diagrams", sdType.Guid + ".png")); } File.WriteAllText(typeHtmlFile, template.TransformText()); } } } } }
public void MakeClasses() { var curDir = Directory.GetCurrentDirectory(); var aidboxClasses = Directory.GetParent(curDir); aidboxClasses = Directory.GetParent(aidboxClasses.FullName); aidboxClasses = Directory.GetParent(aidboxClasses.FullName); var request = new HttpRequestMessage(HttpMethod.Post, aidboxApiUrl + "auth/token"); var content = Newtonsoft.Json.JsonConvert.SerializeObject(new { grant_type = "password", client_id = _client_id, client_secret = _client_secret, username = _username, password = _userpassword }); request.Content = new StringContent(content, Encoding.Default, "application/json"); var result = httpClient.SendAsync(request).Result; if (result.StatusCode != HttpStatusCode.OK) { throw new ApplicationException("Aidbox server authentication error"); } var text = result.Content.ReadAsStringAsync().Result; var responseJson = (JObject)JsonConvert.DeserializeObject(text); var token = ((JValue)responseJson["access_token"]).Value; httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}"); var primitivesList = GetTypesList(httpClient, "primitive"); var typesList = GetTypesList(httpClient, "type"); var resourceList = GetTypesList(httpClient, "resource"); resourceList.Add("Resource"); resourceList.Remove("App"); resourceList.Remove("AidboxQuery"); resourceList.Remove("SearchQuery"); resourceList.Clear(); resourceList.Add("Resource"); resourceList.Add("Patient"); typesList.Clear(); typesList.Add("CodeableConcept"); typesList.Add("Narrative"); typesList.Add("HumanName"); typesList.Add("ContactPoint"); typesList.Add("Identifier"); typesList.Add("Attachment"); typesList.Add("Meta"); typesList.Add("Address"); typesList.Add("Reference"); typesList.Add("Period"); typesList.Add("Coding"); var typesCollection = typesList.Select(t => GetType(httpClient, t)).ToList(); var resourceCollection = resourceList.Select(t => GetType(httpClient, t)).ToList(); foreach (var t in typesCollection) { var template = new TypeTemplate(t); string classText = template.TransformText(); System.IO.File.WriteAllText(@$ "{aidboxClasses}\GeneratedTypes\{t.EntityName}.cs", classText);