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; }
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()); }
protected virtual AssemblyWrapper loadAssembly(string assemblyPath) { var wrapper = new AssemblyWrapper() { Path = assemblyPath }; wrapper.Assembly = Assembly.LoadFrom(assemblyPath); return wrapper; }
protected virtual object createInstanceOfType(AssemblyWrapper assemblyOfType, string namespaceDotType) { Type typeToCreate = assemblyOfType.Assembly.GetType(namespaceDotType); return Activator.CreateInstance(typeToCreate); }
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; }
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); }