public static GetCreatableObjectImplementsInterface ( |
||
interfaceType | ||
assembly | ||
리턴 | System.Type[] |
/// <summary> /// Gets a list of all installed generators /// </summary> /// <returns></returns> public static IEnumerable <AddInGeneratorInstalled> GetInstalledGenerators() { var retval = new List <AddInGeneratorInstalled>(); //Get installed generators var installedGeneratorTypeList = ReflectionHelper.GetCreatableObjectImplementsInterface(typeof(IProjectGenerator), nHydrate.Generator.Common.GeneratorFramework.AddinAppData.Instance.ExtensionDirectory); foreach (var igen in installedGeneratorTypeList) { var gen = ReflectionHelper.CreateInstance(igen); if (gen != null) { var att = (GeneratorProjectAttribute)ReflectionHelper.GetSingleAttribute(typeof(GeneratorProjectAttribute), gen); if (att != null) { var newGenMeta = new AddInGeneratorInstalled(); newGenMeta.GeneratorGuid = att.GeneratorGuid; newGenMeta.Name = att.Name; newGenMeta.Version = igen.Assembly.GetName().Version.ToString(); var fi = new FileInfo(igen.Assembly.Location); newGenMeta.InstallDate = fi.LastWriteTime; retval.Add(newGenMeta); } } } return(retval); }
/// <summary> /// Creates an instance of the Generator Store control /// </summary> /// <returns></returns> public static nHydrate.Generator.Common.GeneratorFramework.IGeneratorStore CreateGeneratorStore() { try { var fileName = Path.Combine(nHydrate.Generator.Common.GeneratorFramework.AddinAppData.Instance.ExtensionDirectory, STORE_ASSEMBLY); if (!File.Exists(fileName)) { return(null); } var asm = Assembly.LoadFrom(fileName); var list = ReflectionHelper.GetCreatableObjectImplementsInterface(typeof(nHydrate.Generator.Common.GeneratorFramework.IGeneratorStore), asm); var t = list.FirstOrDefault(); if (t == null) { return(null); } else { return(ReflectionHelper.CreateInstance(t) as nHydrate.Generator.Common.GeneratorFramework.IGeneratorStore); } } catch (Exception ex) { } return(null); }