mirror of https://github.com/abpframework/abp.git
Browse Source
Added new classes: WorkspaceConfiguration, WorkspaceConfigurationDictionary, and TypedKernelAccessor. These classes facilitate workspace-specific configurations and provide a typed access mechanism for the kernel service. Removed the previous implementation of WorkspaceConfiguration and its dictionary to streamline the configuration process.pull/23533/head
4 changed files with 52 additions and 45 deletions
@ -0,0 +1,28 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.AI; |
|||
|
|||
public class WorkspaceConfiguration |
|||
{ |
|||
public string Name { get; } |
|||
public ChatClientConfiguration ChatClient { get; } = new(); |
|||
public KernelConfiguration Kernel { get; } = new(); |
|||
|
|||
public WorkspaceConfiguration(string name) |
|||
{ |
|||
Name = name; |
|||
} |
|||
|
|||
public WorkspaceConfiguration ConfigureChatClient(Action<ChatClientConfiguration> configureAction) |
|||
{ |
|||
configureAction(ChatClient); |
|||
return this; |
|||
} |
|||
|
|||
|
|||
public WorkspaceConfiguration ConfigureKernel(Action<KernelConfiguration> configureAction) |
|||
{ |
|||
configureAction(Kernel); |
|||
return this; |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AI; |
|||
|
|||
public class WorkspaceConfigurationDictionary : Dictionary<string, WorkspaceConfiguration> |
|||
{ |
|||
public void Configure<TWorkSpace>(Action<WorkspaceConfiguration> configureAction) |
|||
where TWorkSpace : class |
|||
{ |
|||
Configure(WorkspaceNameAttribute.GetWorkspaceName<TWorkSpace>(), configureAction); |
|||
} |
|||
|
|||
public void Configure(string name, Action<WorkspaceConfiguration> configureAction) |
|||
{ |
|||
if (!TryGetValue(name, out var configuration)) |
|||
{ |
|||
configuration = new WorkspaceConfiguration(name); |
|||
this[name] = configuration; |
|||
} |
|||
|
|||
configureAction(configuration); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue