コード例 #1
0
        /// <summary>
        /// Determines whether the specified <paramref name="type"/> is enabled for the given <paramref name="assembly"/>.
        /// </summary>
        /// <param name="assembly"><see cref="Assembly"/> to check if the <paramref name="type"/> is enabled for.</param>
        /// <param name="type"><see cref="TypeIdentity"/> to check if is enabled.</param>
        /// <param name="modules"><see cref="ModuleContainer"/> that provides a collection of Durian modules to pick the <see cref="TypeIdentity"/>s from.</param>
        /// <exception cref="ArgumentNullException"><paramref name="assembly"/> is <see langword="null"/>. -or- <paramref name="type"/> is <see langword="null"/>. -or- <paramref name="modules"/> is <see langword="null"/>.</exception>
        public static bool IsEnabled(this Assembly assembly, TypeIdentity type, ModuleContainer modules)
        {
            if (assembly is null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            if (type is null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (modules is null)
            {
                throw new ArgumentNullException(nameof(modules));
            }

            if (modules.IsEmpty)
            {
                return(false);
            }

            DurianModule[] array = modules.AsEnums();

            return(IsEnabled_Internal(assembly, type, array));
        }
コード例 #2
0
        /// <summary>
        /// Returns a collection of all Durian modules that are enabled for the specified <paramref name="assembly"/>.
        /// </summary>
        /// <param name="assembly"><see cref="Assembly"/> to get all the enabled Durian modules of.</param>
        /// <returns>A new instance of <see cref="ModuleContainer"/> that contains the enabled Durian modules.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="assembly"/> is <see langword="null"/>.</exception>
        public static ModuleContainer GetEnabledModules(this Assembly assembly)
        {
            if (assembly is null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            ModuleContainer all = ModuleIdentity.GetAllModules();

            return(assembly.GetEnabledModules(all.AsEnums()));
        }
コード例 #3
0
        /// <summary>
        /// Returns a collection of all Durian modules present in the provided collection of <paramref name="modules"/> that are disabled for the specified <paramref name="assembly"/>.
        /// </summary>
        /// <param name="assembly"><see cref="Assembly"/> to get the disabled Durian modules from.</param>
        /// <param name="modules"><see cref="ModuleContainer"/> that provides a collection of Durian modules to pick from.</param>
        /// <returns>A new instance of <see cref="ModuleContainer"/> that contains the disabled Durian modules.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="assembly"/> is <see langword="null"/>. -or- <paramref name="modules"/> is <see langword="null"/>.</exception>
        public static ModuleContainer GetDisabledModules(this Assembly assembly, ModuleContainer modules)
        {
            if (assembly is null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            if (modules is null)
            {
                throw new ArgumentNullException(nameof(modules));
            }

            if (modules.Count == 0)
            {
                return(new ModuleContainer());
            }

            return(assembly.GetDisabledModules(modules.AsEnums()));
        }