BuildingCoder.CmdCollectorPerformance.GetFirstNamedElementOfTypeUsingAnonymousButNamedMethod C# (CSharp) Method

GetFirstNamedElementOfTypeUsingAnonymousButNamedMethod() private method

Return the first element of the given type and name using an anonymous method to define a named method.
private GetFirstNamedElementOfTypeUsingAnonymousButNamedMethod ( Type type, string name ) : Element
type Type
name string
return Element
        Element GetFirstNamedElementOfTypeUsingAnonymousButNamedMethod(
            Type type,
            string name)
        {
            FilteredElementCollector a
            = GetElementsOfType( type );

              // using an anonymous method to define a named method:

              Func<Element, bool> nameEquals = e => e.Name.Equals( name );
              return a.First<Element>( nameEquals );
        }