Xsemmel/XPath/ScriptEngine.cs
/// <summary>
/// Searches for T (or a type sub-classing T) in the specified assembly
/// and calls it's default constructor.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="assembly"></param>
/// <returns>Object initializes by the default-constructor</returns>
Searches for T (or a type sub-classing T) in the specified assembly
and calls it's default constructor.
Searches for T ( or a type sub - classing T ) in the specified assembly and calls it ' s default constructor .
public T As<T>(Assembly assembly)
        {
            foreach (Type type in assembly.GetTypes()
                .Where(type => type.IsClass)
                .Where(type =>
                       type.Equals(typeof(T))
                    || type.IsSubclassOf(typeof(T))
                    || ((IList<Type>)type.GetInterfaces()).Contains(typeof(T))))
            {
                return (T)Activator.CreateInstance(type);
            }
            throw new Exception("Assembly does not contain type T");
        }
public T As < T > ( Assembly assembly ) { foreach ( Type type in assembly . GetTypes ( ) . Where ( type => type . IsClass ) . Where ( type => type . Equals ( typeof ( T ) ) || type . IsSubclassOf ( typeof ( T ) ) || ( ( IList < Type > ) type . GetInterfaces ( ) ) . Contains ( typeof ( T ) ) ) ) { return ( T ) Activator . CreateInstance ( type ) ; } throw new Exception ( " " ) ; }
Searches for T (or a type sub-classing T) in the specified assembly
and calls it's default constructor.
Searches for T ( or a type sub - classing T ) in the specified assembly and calls it ' s default constructor .
Object initializes by the default-constructor
Object initializes by the default - constructor
assembly
Assembly
None
typeparam
None