// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Agents.AI.Workflows;
///
/// Provides extensions methods for creating objects
///
public static class ConfigurationExtensions
{
///
/// Creates a new configuration that treats the subject as its base type, allowing configuration to be applied at
/// the parent type level.
///
/// The type of the original subject being configured. Must inherit from or implement TParent.
/// The base type or interface to which the configuration will be upcast.
/// The existing configuration for the subject type to be upcast to its parent type. Cannot be null.
/// A new instance that applies the original configuration logic to the parent type.
public static Configured Super(this Configured configured) where TSubject : TParent
=> new(async (config, runId) => await configured.FactoryAsync(config, runId).ConfigureAwait(false), configured.Id, configured.Raw);
///
/// Creates a new configuration that treats the subject as its base type, allowing configuration to be applied at
/// the parent type level.
///
/// The type of the original subject being configured. Must inherit from or implement TParent.
/// The base type or interface to which the configuration will be upcast.
/// The type of configuration options for the original subject being configured.
/// The existing configuration for the subject type to be upcast to its parent type. Cannot be null.
/// A new instance that applies the original configuration logic to the parent type.
public static Configured Super(this Configured configured) where TSubject : TParent
=> configured.Memoize().Super();
}