Skip to content

Commit

Permalink
implements #7 - Add more constructors to SharedParameterFile class en…
Browse files Browse the repository at this point in the history
…hancement
  • Loading branch information
salaros committed Jun 8, 2018
1 parent 775fbcf commit 1c84586
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/Parameters/Shared/SharedParameterFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ public sealed partial class SharedParameterFile : ICloneable, IEquatable<SharedP
{
#region Constructors

private List<Group> _groups;
private IReadOnlyList<Group> _groups;

internal SharedParameterFile()
{
Metadata = new MetaData(2, 1);
Parameters = new ParameterCollection(this, null);
_groups = new List<Group>();
}

/// <summary>
/// Initializes a new instance of the <see cref="SharedParameterFile"/> class.
Expand All @@ -37,6 +44,38 @@ public SharedParameterFile(IEnumerable<Group> groups = null, IEnumerable<Paramet
_groups = groups != null ? new List<Group>(groups) : new List<Group>();
}

/// <summary>
/// Initializes a new instance of the <see cref="T:CodeCave.Revit.Toolkit.Parameters.Shared.SharedParameterFile" /> class.
/// </summary>
/// <param name="groups">The list of groups.</param>
/// <param name="parameters">The list of parameters.</param>
/// <param name="metadata">The metadata section.</param>
/// <inheritdoc />
public SharedParameterFile(IEnumerable<string> groups = null, IEnumerable<Parameter> parameters = null, MetaData metadata = null)
: this(
groups?.Select((g, i) => new Group(g, i +1)),
parameters,
metadata
)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="SharedParameterFile"/> class.
/// </summary>
/// <param name="groups">The list of groups.</param>
/// <param name="parameters">The list of parameters.</param>
/// <param name="metadata">The metadata section.</param>
/// <inheritdoc />
public SharedParameterFile(IDictionary<string, int> groups = null, IEnumerable<Parameter> parameters = null, MetaData metadata = null)
: this(
groups?.Select((g, i) => new Group(g.Key, (g.Value > 0) ? g.Value : i)),
parameters,
metadata
)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="T:CodeCave.Revit.Toolkit.Parameters.Shared.SharedParameterFile" /> class.
/// </summary>
Expand Down

0 comments on commit 1c84586

Please sign in to comment.