public static IEnumerable<Family> GetFilteredNestedFamilyDefinitions(
string familyFileNameFilter,
Document familyDocument,
bool caseSensitiveFiltering)
{
// Following good SOA practices, verify the
// incoming data can be worked with.
ValidateFamilyDocument( familyDocument ); // Throws an exception if not a family doc
// The filter can be null, the filter matching function checks for that.
#if _2010
List<Family> oResult = new List<Family>();
ElementIterator it = familyDocument.Elements;
while( it.MoveNext() )
{
Element oElement = it.Current as Element;
if( ( oElement is Family )
&& FilterMatches( oElement.Name,
familyFileNameFilter, caseSensitiveFiltering ) )
{
oResult.Add( oElement as Family );
}
}
#endif // _2010
FilteredElementCollector collector
= new FilteredElementCollector( familyDocument );
collector.OfClass( typeof( Family ) );
IEnumerable<Element> familiesMatching =
from f in collector
where FilterMatches( f.Name, familyFileNameFilter, caseSensitiveFiltering )
select f;
return familiesMatching.Cast<Family>();
}