Esempio n. 1
0
 public async Task <WrappedResponse <ImmutableList <ProjectDefinition> > > GetAllAsync()
 {
     using (CallProxy)
     {
         return(await CallProxy.CallAsync(async() => await projectDefinitionsReader.GetAllProjectDefinitionsAsync()));
     }
 }
        public async Task <ProjectDefinition> InsertAsync(ProjectDefinition projectDefinition)
        {
            try
            {
                var allProjectDefinitions = await projectDefinitionsReader.GetAllProjectDefinitionsAsync();

                await Semaphore.WaitAsync();

                var collision = allProjectDefinitions.Any(a => a.ProjectPath.Equals(projectDefinition.ProjectPath));
                if (collision)
                {
                    throw new Exception($"Project at path '{projectDefinition.ProjectPath}' has already been added");
                }
                projectDefinition.ProjectId = Guid.NewGuid();
                allProjectDefinitions       = allProjectDefinitions.Add(projectDefinition);
                await fileSystemAccessor.WriteAllText(ProjectsDefinitionStoreFile, JsonSerializer.Serialize(allProjectDefinitions));

                return(projectDefinition);
            }
            finally
            {
                Semaphore.Release();
            }
        }