Resource.Set

Set<T>(Key<T, RscKey>, T)

Maps the specified property to the specified value in this container.

public void Set<T>(Key<T, RscKey> key, T val)
ParameterDescription
Tthe type of the mapped value.
keythe specified property key. Rsc for getting the property key.
valthe value.

Examples

Shows how to read/write common resource properties.

var project = new Project(DataDir + "UpdateResourceData.mpp");

// Add resource and set some properties
var resource = project.Resources.Add("Rsc");
resource.Set(Rsc.Start, new DateTime(2020, 4, 1, 8, 0, 0));
resource.Set(Rsc.StandardRate, 30);
resource.Set(Rsc.OvertimeRate, 45);
resource.Set(Rsc.Group, "Workgroup1");

Console.WriteLine("Resource Start: " + resource.Get(Rsc.Start));
Console.WriteLine("Resource Standard Rate: " + resource.Get(Rsc.StandardRate));
Console.WriteLine("Resource Overtime Rate: " + resource.Get(Rsc.OvertimeRate));
Console.WriteLine("Resource Group: " + resource.Get(Rsc.Group));

project.Save(OutDir + "UpdateResourceData_out.mpp", SaveFileFormat.Mpp);

See Also


Set(Key<DateTime, RscKey>, DateTime)

Maps the specified property to the specified value in this container.

public void Set(Key<DateTime, RscKey> key, DateTime val)
ParameterTypeDescription
keyKey`2the specified property key. Rsc for getting the property key.
valDateTimethe value.

Examples

Shows how to read/write common resource properties.

var project = new Project(DataDir + "UpdateResourceData.mpp");

// Add resource and set some properties
var resource = project.Resources.Add("Rsc");
resource.Set(Rsc.Start, new DateTime(2020, 4, 1, 8, 0, 0));
resource.Set(Rsc.StandardRate, 30);
resource.Set(Rsc.OvertimeRate, 45);
resource.Set(Rsc.Group, "Workgroup1");

Console.WriteLine("Resource Start: " + resource.Get(Rsc.Start));
Console.WriteLine("Resource Standard Rate: " + resource.Get(Rsc.StandardRate));
Console.WriteLine("Resource Overtime Rate: " + resource.Get(Rsc.OvertimeRate));
Console.WriteLine("Resource Group: " + resource.Get(Rsc.Group));

project.Save(OutDir + "UpdateResourceData_out.mpp", SaveFileFormat.Mpp);

See Also