Esempio n. 1
0
        /// <summary>
        /// Try to gets an instance of a named pseudoclass filter.
        /// </summary>
        ///
        /// <param name="name">
        /// The name of the pseudoselector.
        /// </param>
        /// <param name="instance">
        /// [out] The new instance.
        /// </param>
        ///
        /// <returns>
        /// true if succesful, false if a pseudoselector of that name doesn't exist.
        /// </returns>

        public bool TryGetInstance(string name, out IPseudoSelector instance)
        {
            Type type;

            if (InnerSelectors.TryGetValue(name, out type))
            {
                instance = (IPseudoSelector)FastActivator.CreateInstance(type);
                return(true);
            }
            instance = null;
            return(false);
        }
Esempio n. 2
0
        private int PopulateFromAssembly(Assembly assy, params string[] nameSpaces)
        {
            int loaded = 0;

            foreach (var t in assy.GetTypes())
            {
                if (t.IsClass && t.Namespace != null &&
                    !t.IsAbstract &&
                    nameSpaces.Contains(t.Namespace))
                {
                    if (t.GetInterface("IPseudoSelector") != null)
                    {
                        IPseudoSelector instance = (IPseudoSelector)FastActivator.CreateInstance(t);
                        InnerSelectors[instance.Name] = t;
                        loaded++;
                    }
                }
            }
            return(loaded);
        }
Esempio n. 3
0
        /// <summary>
        /// Try to gets an instance of a named pseudoclass filter.
        /// </summary>
        ///
        /// <param name="name">
        /// The name of the pseudoselector.
        /// </param>
        /// <param name="instance">
        /// [out] The new instance.
        /// </param>
        ///
        /// <returns>
        /// true if succesful, false if a pseudoselector of that name doesn't exist.
        /// </returns>

        public bool TryGetInstance(string name, out IPseudoSelector instance) {
            Type type;
            if (InnerSelectors.TryGetValue(name, out type))
            {
                instance = (IPseudoSelector)FastActivator.CreateInstance(type);
                return true;
            }
            instance = null;
            return false;
        }