/// <summary> /// Creates an element filter. /// </summary> /// <param name="filterBy">The filter by.</param> /// <returns>An element filter.</returns> private static IElementFilter CreateElementFilter(FilterBy filterBy) { IElementFilter filter = null; if (filterBy != null) { filter = new ElementFilter(filterBy.Condition); } return(filter); }
/// <summary> /// Determines whether or not the specified element can be arranged by /// this arranger. /// </summary> /// <param name="parentElement">The parent element.</param> /// <param name="codeElement">The code element.</param> /// <returns> /// <c>true</c> if this instance can arrange the specified parent element; otherwise, <c>false</c>. /// </returns> public virtual bool CanArrange(ICodeElement parentElement, ICodeElement codeElement) { // Clone the instance and assign the parent ICodeElement testCodeElement = codeElement; if (_filter == null && _elementConfiguration.FilterBy != null) { _filter = CreateElementFilter(_elementConfiguration.FilterBy); } if (parentElement != null && _filter != null && _filter.RequiredScope == ElementAttributeScope.Parent) { testCodeElement = codeElement.Clone() as ICodeElement; testCodeElement.Parent = parentElement.Clone() as ICodeElement; } return((_elementConfiguration.ElementType == ElementType.NotSpecified || codeElement.ElementType == _elementConfiguration.ElementType) && (_filter == null || _filter.IsMatch(testCodeElement))); }
/// <summary> /// Determines whether or not the specified element can be arranged by /// this arranger. /// </summary> /// <param name="parentElement">The parent element.</param> /// <param name="codeElement">The code element.</param> /// <returns> /// <c>true</c> if this instance can arrange the specified parent element; otherwise, <c>false</c>. /// </returns> public virtual bool CanArrange(ICodeElement parentElement, ICodeElement codeElement) { // Clone the instance and assign the parent ICodeElement testCodeElement = codeElement; if (_filter == null && _elementConfiguration.FilterBy != null) { _filter = CreateElementFilter(_elementConfiguration.FilterBy); } if (parentElement != null && _filter != null && _filter.RequiredScope == ElementAttributeScope.Parent) { testCodeElement = codeElement.Clone() as ICodeElement; testCodeElement.Parent = parentElement.Clone() as ICodeElement; } return (_elementConfiguration.ElementType == ElementType.NotSpecified || codeElement.ElementType == _elementConfiguration.ElementType) && (_filter == null || _filter.IsMatch(testCodeElement)); }