public static Assembly GetAssemblyOfProjectItem(this ProjectItem pi) { var path = pi.GetAssemblyPath(); if (!string.IsNullOrEmpty(path)) { return(Assembly.LoadFrom(path)); } else { return(null); } }
/// <summary> /// Returns a type from an assembly reference by ProjectItem.Project. Cached. /// </summary> /// <param name="pi"></param> /// <param name="typeName"></param> /// <returns></returns> /// <remarks></remarks> public static Type GetTypeFromProject(this ProjectItem pi, string typeName) { //INSTANT C# NOTE: VB local static variable moved to class level: // Static cache As new Dictionary(Of String, Assembly) var path = pi.GetAssemblyPath(); if (!(GetTypeFromProject_cache.ContainsKey(path))) { GetTypeFromProject_cache.Add(path, Assembly.LoadFrom(path)); } var asm = GetTypeFromProject_cache[path]; return(asm.GetType(typeName)); }