Exemplo n.º 1
0
        private static List <Type> GetConnectionTypes(ref List <Type> types, IsSpecificType isSpecificType)
        {
            if (types == null)
            {
                // Load internal types
                types = GetConnectionTypes(AssemblyInfo.Assembly, isSpecificType);

                // Load external types
                string pluginPath = Path.Combine(AssemblyInfo.Directory, "Plugins");

                Log.Debug("Plugins path: " + pluginPath);

                // Check if the plugin folder exists
                if (Directory.Exists(pluginPath))
                {
                    // Get all dlls in the plugin folder and under it.
                    var assemblies = from assembly in new DirectoryInfo(pluginPath).GetFiles("*.dll", SearchOption.AllDirectories) where !assembly.FullName.ToUpperInvariant().StartsWith(AssemblyInfo.UpgradeDirectory.ToUpperInvariant()) select assembly.FullName;

                    // Now load the external types and add them to the list.
                    foreach (string assemblyFile in assemblies)
                    {
                        try
                        {
                            types.AddRange(GetConnectionTypes(Assembly.LoadFile(assemblyFile), isSpecificType));
                        }
                        catch (Exception ex)
                        {
                            Log.Debug("Ignoring native assembly " + assemblyFile, ex);
                        }
                    }
                }
            }

            return(types);
        }
Exemplo n.º 2
0
        private static List <Type> GetConnectionTypes(Assembly assembly, IsSpecificType isSpecificType)
        {
            if (Limit == null)
            {
                Limit = new string[0];
            }

            IEnumerable <Type> a = null;

            try
            {
                a =
                    from t in assembly.GetTypes()
                    where t != null && t.IsClass && t.IsPublic
                    select t;
            }
            catch (ReflectionTypeLoadException ex)
            {
                a =
                    from t in ex.Types
                    where t != null && t.IsClass && t.IsPublic
                    select t;
            }


            List <Type> types = new List <Type>();

            foreach (Type type in a)
            {
                if (type != null)
                {
                    if (isSpecificType(type))    //(IsConnectionType(type))
                    {
                        // If the user is not allowed to
                        // use all available connections e.g.
                        // if the user has a freeware version.
                        if (!Limit.Contains(GetProtocolName(type)))
                        {
                            types.Add(type);
                        }
                    }
                }
            }

            return(types);
        }
Exemplo n.º 3
0
        private static List<Type> GetConnectionTypes(Assembly assembly, IsSpecificType isSpecificType)
        {
        	if (Limit == null)
        		Limit = new string[0];
        	
            IEnumerable<Type> a = null;
            try
            {
                a =
                    from t in assembly.GetTypes()
                    where t != null && t.IsClass && t.IsPublic
                    select t;
            }
            catch (ReflectionTypeLoadException ex)
            {
                a =
                    from t in ex.Types
                    where t != null && t.IsClass && t.IsPublic
                    select t;
            }


            List<Type> types = new List<Type>();
            
            foreach (Type type in a)
            {
            	if (type != null)
	                if (isSpecificType(type))//(IsConnectionType(type))
	                {
	                    // If the user is not allowed to
	                    // use all available connections e.g. 
	                    // if the user has a freeware version.
	                    if (!Limit.Contains(GetProtocolName(type)))
	                    {
	                    	types.Add(type);
	                    }
	                }
            }

            return types;
        }
Exemplo n.º 4
0
        private static List<Type> GetConnectionTypes(ref List<Type> types, IsSpecificType isSpecificType)
        {
            if (types == null)
            {
                // Load internal types
                types = GetConnectionTypes(AssemblyInfo.Assembly, isSpecificType);

                // Load external types
                string pluginPath = Path.Combine(AssemblyInfo.Directory, "Plugins");

                // Check if the plugin folder exists
                if (Directory.Exists(pluginPath))
                {
                    // Get all dlls in the plugin folder and under it.
                    var assemblies = from assembly in new DirectoryInfo(pluginPath).GetFiles("*.dll", SearchOption.AllDirectories) select assembly.FullName;

                    // Now load the external types and add them to the list.
                    foreach (string assemblyFile in assemblies)
                    {
                        try
                        {
                            types.AddRange(GetConnectionTypes(Assembly.LoadFile(assemblyFile), isSpecificType));
                        }
                        catch (Exception ex)
                        {
                            Log.Debug("Ignoring native assembly " + assemblyFile, ex);
                        }
                    }
                }
            }

            return types;
        }