Exemple #1
0
        virtual protected AssemblyWrapper loadAssembly(string assemblyPath)
        {
            var wrapper = new AssemblyWrapper()
            {
                Path = assemblyPath
            };

            wrapper.Assembly = Assembly.LoadFrom(assemblyPath);
            return(wrapper);
        }
 public virtual List<Type> GetGuiTypesOnly(AssemblyWrapper assemblyWrapper)
 {
     var filteredTypes = new List<Type>();
     var allTypes = getAllTypesInsideAssembly(assemblyWrapper);
     foreach (Type anyType in allTypes)
     {
         if (   anyType == typeof(Window)
             || anyType.InheritsFrom(typeof(Window))
             || anyType == typeof(Page)
             || anyType.InheritsFrom(typeof(Page))
             || anyType == typeof(UserControl)
             || anyType.InheritsFrom(typeof(UserControl))
             )
         {
             filteredTypes.Add(anyType);
         }
     }
     return filteredTypes;
 }
Exemple #3
0
        virtual protected object createInstanceOfType(AssemblyWrapper assemblyOfType, string namespaceDotType)
        {
            Type typeToCreate = assemblyOfType.Assembly.GetType(namespaceDotType);

            return(Activator.CreateInstance(typeToCreate));
        }
 protected virtual List<Type> getAllTypesInsideAssembly(AssemblyWrapper assembly)
 {
     return new List<Type>(assembly.Assembly.GetTypes());
 }
Exemple #5
0
 protected virtual AssemblyWrapper loadAssembly(string assemblyPath)
 {
     var wrapper = new AssemblyWrapper() { Path = assemblyPath };
     wrapper.Assembly = Assembly.LoadFrom(assemblyPath);
     return wrapper;
 }
Exemple #6
0
 protected virtual object createInstanceOfType(AssemblyWrapper assemblyOfType, string namespaceDotType)
 {
     Type typeToCreate = assemblyOfType.Assembly.GetType(namespaceDotType);
     return Activator.CreateInstance(typeToCreate);
 }
Exemple #7
0
        protected virtual System.Collections.Generic.List<string> getValidAssemblyTypeNames(AssemblyWrapper assemblyWrapper)
        {
            var assemblyGuiTypes = TypesExtractor.GetGuiTypesOnly(assemblyWrapper);
            var list = new System.Collections.Generic.List<string>();

            foreach (Type type in assemblyGuiTypes)
            {
                if (!String.IsNullOrEmpty(type.FullName) && type.IsClass)
                    list.Add(type.FullName);
            }

            return list;
        }
Exemple #8
0
        public virtual void LoadAssembly(string assemblyPath)
        {
            if (string.IsNullOrEmpty(assemblyPath))
                return; // settings uninitialized

            try
            {
                m_AssemblyWrapper = loadAssembly(assemblyPath);
            }
            catch(FileNotFoundException)
            {
                m_LoadedAssemblyTypes = new List<string>();
                return; // wrong assembly path specified
            }
            catch (BadImageFormatException)
            {
                m_LoadedAssemblyTypes = new List<string>();
                return; // not a .NET dll?
            }

            m_LoadedAssemblyTypes = getValidAssemblyTypeNames(m_AssemblyWrapper);
        }