Exemplo n.º 1
0
        /// <summary>
        /// Populate the list box with files and directories according to the
        /// directoryName property
        /// </summary>
        private void PopulatingItems()
        {
            // Ignore when in desing mode
            if (DesignMode)
            {
                return;
            }

            Items.Clear();
            // Shows the back directory item (
            if (_showBackIcon && _selectedPath.Length > 3 && _selectedPath != _mainDirectory)
            {
                Items.Add("..");
            }
            try
            {
                // Fills all directory items
                if (_showDirectories)
                {
                    string[] dirNames = Directory.GetDirectories(_selectedPath);
                    foreach (string dir in dirNames)
                    {
                        string realDir = Path.GetFileName(dir);
                        if (IgnoredNames.Contains(realDir) && SelectedPath == MainDir)
                        {
                            continue;
                        }
                        Items.Add(realDir);
                    }
                }
                // Fills all list items
                string[] fileNames = Directory.GetFiles(_selectedPath);
                foreach (string file in fileNames)
                {
                    string fileName = Path.GetFileName(file);
                    if (IgnoredNames.Contains(fileName) && SelectedPath == MainDir)
                    {
                        continue;
                    }
                    Items.Add(fileName);
                }
                // eat this - back is still optional even when no other items exists
            }
            catch
            {
            }
            Invalidate();
        }
        /// <summary>
        /// Determines if the specified property should be included in the list of a given type's properties.
        /// <para>
        /// The default behavior is to check the property name against the <see cref="IgnoredNames"/> list
        /// and check the property type against the <see cref="IgnoredTypes"/> list. The type is
        /// checked for equality and via <see cref="Type.IsAssignableFrom(Type)"/>. If both the property
        /// type and the currently tested type are generic (<see cref="Type.IsGenericType"/>), the equality and assignable tests are repeated
        /// with the generic definitions obtained by calling <see cref="Type.GetGenericTypeDefinition"/>. Additionally,
        /// read-only properties are ignored.
        /// </para>
        /// </summary>
        /// <param name="property">The property</param>
        /// <returns>True if the property should be included, or false.</returns>
        protected virtual bool IncludeProperty(PropertyInfo property)
        {
            if (IgnoredNames.Contains(property.Name, StringComparer.OrdinalIgnoreCase))
            {
                return(false);
            }

            var type = property.PropertyType;

            if (IgnoredTypes.Any(a => {
                if (a.Equals(type))
                {
                    return(true);
                }
                if (a.IsAssignableFrom(type))
                {
                    return(true);
                }

                if (type.IsGenericType && a.IsGenericType)
                {
                    var genericA = a.GetGenericTypeDefinition();
                    var genericType = type.GetGenericTypeDefinition();
                    if (genericA.Equals(genericType))
                    {
                        return(true);
                    }
                    if (genericA.IsAssignableFrom(genericType))
                    {
                        return(true);
                    }
                }

                return(false);
            }))
            {
                return(false);
            }

            // If we have a read-only property, we don't want to map
            // it to anything.
            if (!property.CanWrite)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool IsMatch(Project project)
        {
            if (Language != null &&
                Language != project.Language)
            {
                return(false);
            }

            if (Names?.Count > 0)
            {
                return(Names.Contains(project.Name));
            }

            if (IgnoredNames?.Count > 0)
            {
                return(!IgnoredNames.Contains(project.Name));
            }

            return(true);
        }