Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterBuilderCollection"/> class
 /// with the specified array of <see cref="FilterBuilder"/> instances.
 /// </summary>
 public FilterBuilderCollection(FilterBuilder[] value)
 {
     AddRange(value);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Scans a given <see cref="Type" /> for filters.
        /// </summary>
        /// <param name="extensionAssembly">The <see cref="ExtensionAssembly" /> containing the <see cref="Type" /> to scan.</param>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// <see cref="Filter" />; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForFilters(ExtensionAssembly extensionAssembly, Type type, Task task)
        {
            try {
                ElementNameAttribute elementNameAttribute = (ElementNameAttribute)
                    Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute));

                if (type.IsSubclassOf(typeof(Filter)) && !type.IsAbstract && elementNameAttribute != null) {
                    task.Log(Level.Debug, "Creating FilterBuilder for \"{0}\".",
                        type.Name);
                    FilterBuilder builder = new FilterBuilder(extensionAssembly, type.FullName);
                    if (FilterBuilders[builder.FilterName] == null) {
                        FilterBuilders.Add(builder);

                        task.Log(Level.Debug, "Adding filter \"{0}\" from {1}:{2}.",
                            builder.FilterName, GetAssemblyLocation(builder.Assembly),
                            builder.ClassName);
                    }

                    // specified type represents a filter
                    return true;
                }

                // specified type does not represent a valid filter
                return false;
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for filters.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Inserts a <see cref="FilterBuilder"/> into the collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="FilterBuilder"/> to insert.</param>
 public void Insert(int index, FilterBuilder item)
 {
     base.List.Insert(index, item);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Removes a member from the collection.
 /// </summary>
 /// <param name="item">The <see cref="FilterBuilder"/> to remove from the collection.</param>
 public void Remove(FilterBuilder item)
 {
     base.List.Remove(item);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Retrieves the index of a specified <see cref="FilterBuilder"/> object in the collection.
 /// </summary>
 /// <param name="item">The <see cref="FilterBuilder"/> object for which the index is returned.</param> 
 /// <returns>
 /// The index of the specified <see cref="FilterBuilder"/>. If the <see cref="FilterBuilder"/> is not currently a member of the collection, it returns -1.
 /// </returns>
 public int IndexOf(FilterBuilder item)
 {
     return base.List.IndexOf(item);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.        
 /// </summary>
 /// <param name="array">The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.</param> 
 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
 public void CopyTo(FilterBuilder[] array, int index)
 {
     base.List.CopyTo(array, index);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Determines whether a <see cref="FilterBuilder"/> is in the collection.
 /// </summary>
 /// <param name="item">The <see cref="FilterBuilder"/> to locate in the collection.</param> 
 /// <returns>
 /// <see langword="true" /> if <paramref name="item"/> is found in the 
 /// collection; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(FilterBuilder item)
 {
     return base.List.Contains(item);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds the elements of a <see cref="FilterBuilder"/> array to the end of the collection.
 /// </summary>
 /// <param name="items">The array of <see cref="FilterBuilder"/> elements to be added to the end of the collection.</param> 
 public void AddRange(FilterBuilder[] items)
 {
     for (int i = 0; (i < items.Length); i = (i + 1)) {
         Add(items[i]);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds a <see cref="FilterBuilder"/> to the end of the collection.
 /// </summary>
 /// <param name="item">The <see cref="FilterBuilder"/> to be added to the end of the collection.</param> 
 /// <returns>The position into which the new element was inserted.</returns>
 public int Add(FilterBuilder item)
 {
     return base.List.Add(item);
 }