Add DefinitionBindingMap.AsEnumerable extension#80
Open
AleksandrFomenko wants to merge 6 commits into
Open
Conversation
AleksandrFomenko
marked this pull request as draft
June 19, 2026 09:15
Author
|
😺 |
Owner
|
Owner
|
Better to add a custom enumeration and thats it. extension(DefinitionBindingMap map)
{
[Pure]
public IEnumerable<(Definition Definition, ElementBinding Binding)> AsEnumerable()
{
var iterator = map.ForwardIterator();
while (iterator.MoveNext())
{
if (iterator is { Key: { } definition, Current: ElementBinding binding })
{
yield return (definition, binding);
}
}
}
}Usage: foreach (var (definition, binding) in document.ParameterBindings.AsEnumerable())
{
} |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new DefinitionBindingMap extension to make iterating Revit project-parameter bindings easier (as (Definition, ElementBinding) pairs), and documents it in the README and CHANGELOG.
Changes:
- Add
DefinitionBindingMapExtensions.AsEnumerable()to iterate bindings as tuple pairs for LINQ-friendly querying. - Document the new enumeration pattern in
README.md. - Add a CHANGELOG entry for the new extension.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| source/Nice3point.Revit.Extensions/DefinitionBindingMapExtensions.cs | Adds AsEnumerable() for iterating DefinitionBindingMap bindings as (Definition, ElementBinding) tuples. |
| README.md | Adds a “Project parameters” section showing how to query document.ParameterBindings.AsEnumerable() with LINQ. |
| CHANGELOG.md | Records the new map.AsEnumerable() extension under 2027.0.3. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2
to
+13
| namespace Nice3point.Revit.Extensions; | ||
|
|
||
| /// <summary> | ||
| /// Specifies which parameter bindings to include when querying project parameters. | ||
| /// </summary> | ||
| /// <summary> | ||
| /// Revit DefinitionBindingMap Extensions | ||
| /// </summary> | ||
| [PublicAPI] | ||
| public static class DefinitionBindingMapExtensions | ||
| { | ||
| extension(DefinitionBindingMap map) |
Comment on lines
+699
to
+703
| ### Project parameters | ||
|
|
||
| **AsEnumerable** enumerates the project parameter bindings of the document as `(Definition, Binding)` pairs, making them easy to query with LINQ. | ||
| ```csharp | ||
| var bindings = document.ParameterBindings.AsEnumerable(); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
AleksandrFomenko
force-pushed
the
feature/parameter-extensions
branch
from
July 15, 2026 16:55
fc8806b to
891f7ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
What is this about:
Adds an extension to enumerate project parameter bindings with LINQ.
Description:
DefinitionBindingMap.AsEnumerable()iterates the map and yields(Definition, ElementBinding)pairs, so callers can query bindings with standard LINQ instead of working withForwardIterator()directly.Readme and Changelog updated accordingly.
Quality Checklist