示例#1
0
        /// <summary>
        /// Returns the set of assemblies containing the specified type and all of its base types.
        /// </summary>
        private static Assembly[] GetAssembliesForType(Type type, bool walkInheritanceChain)
        {
            List <Assembly> assemblies = new List <Assembly>();

            while (type != typeof(object))
            {
                assemblies.Add(type.Assembly);
                if (!walkInheritanceChain)
                {
                    break;
                }
                type = type.BaseType;
            }
            return(CollectionUtils.Unique(assemblies).ToArray());
        }
示例#2
0
        /// <summary>
        /// Returns the set of resources whose name matches the specified regular expression.
        /// </summary>
        /// <param name="regex">A regular expression to be used to select matching resources.</param>
        /// <returns>An array of fully qualified resource names that match the specified regular expression.</returns>
        public string[] FindResources(Regex regex)
        {
            Platform.CheckForNullReference(regex, @"regex");

            var matches = new List <string>();

            foreach (var asm in _assemblies)
            {
                matches.AddRange(CollectionUtils.Select(asm.GetManifestResourceNames(), result => regex.Match(result).Success));
            }

            // include the fallback
            if (_fallbackResolver != null)
            {
                matches.AddRange(_fallbackResolver.FindResources(regex));
            }

            return(CollectionUtils.Unique(matches).ToArray());
        }
示例#3
0
        /// <summary>
        /// Returns the set of resources whose name matches the specified regular expression.
        /// </summary>
        /// <param name="regex"></param>
        /// <returns></returns>
        public string[] FindResources(Regex regex)
        {
            List <string> matches = new List <string>();

            foreach (Assembly asm in _assemblies)
            {
                matches.AddRange(
                    CollectionUtils.Select(asm.GetManifestResourceNames(),
                                           delegate(string res) { return(regex.Match(res).Success); }));
            }

            // include the fallback
            if (_fallbackResovler != null)
            {
                matches.AddRange(_fallbackResovler.FindResources(regex));
            }

            return(CollectionUtils.Unique(matches).ToArray());
        }