LoadProfileOptions#

Options for Project.LoadProfile: a ProfileQuery that sets what the profile covers, plus the baseline the call expects. Build one with new LoadProfileOptions(query), or pass a ProfileQuery directly, since it converts implicitly.

Declaration#

public sealed class LoadProfileOptions : IDeepCloneable<LoadProfileOptions>
{
    public LoadProfileOptions(ProfileQuery query);

    public required ProfileQuery Query { get; set; }
    public string? BaselineId { get; set; }

    public static implicit operator LoadProfileOptions(ProfileQuery query);

    public LoadProfileOptions DeepClone();
}

LoadProfileOptions doesn't implement IEquatable<T>, so two instances compare by reference.

Constructors#

LoadProfileOptions(ProfileQuery)#

public LoadProfileOptions(ProfileQuery query)

Wraps query with no baseline check (BaselineId is null). The instance keeps a reference to query and doesn't copy it.

Parameters

Name Type Description
query ProfileQuery Range, resources, basis and task lists of the profile.

Properties#

Property Type Default Description
Query ProfileQuery required What the profile covers: range, resources, basis and which buckets list their tasks.
BaselineId string? null The baseline the call expects. null skips the check.

Query#

public required ProfileQuery Query { get; set; }

The range, resources, basis and task lists of the returned LoadProfile. See ProfileQuery for each field and its default.

BaselineId#

public string? BaselineId { get; set; }

A baseline token taken from the latest ScheduleResult.BaselineId. When it isn't null and doesn't name the project's current baseline, Project.LoadProfile throws a ProjectException with Code == ProjectError.StaleBaseline.

Operators#

Implicit conversion from ProfileQuery#

public static implicit operator LoadProfileOptions(ProfileQuery query)

Same as new LoadProfileOptions(query): the query with no baseline check. This lets project.LoadProfile(query) take a ProfileQuery directly.

Methods#

DeepClone#

public LoadProfileOptions DeepClone()

Returns a copy whose Query is a deep copy too, so the two instances share no list.

Example#

using Plen;

static Moment Day(int day) =>
    Moment.FromYmdHm(2026, 1, day, 0, 0) ?? throw new InvalidOperationException("invalid date");

var data = new ProjectData
{
    Tasks = [new TaskData("a") { StartDate = Day(1), Duration = 2.0 }],
    Resources = [new ResourceData { Id = "dev" }],
    Assignments = [new AssignmentData { Task = "a", Resource = "dev", Value = 1.0 }],
};

var project = new Project();
var solved = project.Solve(data, new SolveOptions());

var options = new LoadProfileOptions(new ProfileQuery(Day(1), Day(5)) { Tasks = ProfileTasks.All })
{
    BaselineId = solved.BaselineId,
};
var profile = project.LoadProfile(options);