Skip to content

Commit

Permalink
Update data source context
Browse files Browse the repository at this point in the history
  • Loading branch information
dogzz9445 committed Jul 25, 2024
1 parent e863141 commit 88d3efd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Apps/Corathing.Organizer/Services/DataSourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ public void AddDataSourceContext(Guid dataSourceStateId, DataSourceContext dataS

public void AddDataSourceContext(DataSourceContext dataSourceContext)
{
DataSourceContexts.Add(dataSourceContext.DataSourceId, dataSourceContext);
if (dataSourceContext.DataSourceId == null)
{
throw new InvalidOperationException("DataSourceId is null");
}
DataSourceContexts.Add(dataSourceContext.DataSourceId.Value, dataSourceContext);
}

public void RemoveAllDataSourceContexts<T>()
Expand All @@ -124,7 +128,10 @@ public void RemoveAllDataSourceContexts<T>()

public void RemoveDataSourceContext<T>(T dataSourceContext) where T : DataSourceContext
{
DataSourceContexts.Remove(dataSourceContext.DataSourceId);
if (dataSourceContext.DataSourceId != null)
{
DataSourceContexts.Remove(dataSourceContext.DataSourceId.Value);
}
}

public IEnumerable<DataSourceContext> GetAllDataSourceContexts(Type? dataSourceContext)
Expand All @@ -139,7 +146,6 @@ public IEnumerable<DataSourceContext> GetAllDataSourceContexts(Type? dataSourceC
public IEnumerable<T> GetAllDataSourceContexts<T>()
{
return DataSourceContexts.Values.OfType<T>();
//return DataSourceContexts.Values.Select(item => item as T).Where(x => x != null);
}

public IEnumerable<T> GetDataSourceContexts<T>()
Expand Down

0 comments on commit 88d3efd

Please sign in to comment.