|
|
|
@ -26,9 +26,7 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -26,9 +26,7 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
public class TypeResolutionService : ITypeResolutionService |
|
|
|
|
{ |
|
|
|
|
readonly static List<Assembly> designerAssemblies = new List<Assembly>(); |
|
|
|
|
/// <summary>
|
|
|
|
|
/// string "filename:size" -> Assembly
|
|
|
|
|
/// </summary>
|
|
|
|
|
// hash of file content -> Assembly
|
|
|
|
|
readonly static Dictionary<string, Assembly> assemblyDict = new Dictionary<string, Assembly>(); |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -139,8 +137,7 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -139,8 +137,7 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
if (!File.Exists(fileName)) |
|
|
|
|
return null; |
|
|
|
|
byte[] data = File.ReadAllBytes(fileName); |
|
|
|
|
|
|
|
|
|
string hash = fileName + ":" + File.GetLastWriteTimeUtc(fileName); |
|
|
|
|
string hash; |
|
|
|
|
using (HashFunction hashFunction = new HashFunction()) { |
|
|
|
|
hash = Convert.ToBase64String(hashFunction.ComputeHash(data)); |
|
|
|
|
} |
|
|
|
@ -265,11 +262,18 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -265,11 +262,18 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
lock (designerAssemblies) { |
|
|
|
|
foreach (Assembly asm in DesignerAssemblies) { |
|
|
|
|
Type t = asm.GetType(name, false); |
|
|
|
|
if (t != null) { |
|
|
|
|
return t; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Type type = null; |
|
|
|
|
int idx = name.IndexOf(","); |
|
|
|
|
Type type = Type.GetType(name, false, ignoreCase); |
|
|
|
|
|
|
|
|
|
if (idx < 0) { |
|
|
|
|
if (type == null) { |
|
|
|
|
IProjectContent pc = this.CallingProject; |
|
|
|
|
if (pc != null) { |
|
|
|
|
IClass foundClass = pc.GetClass(name); |
|
|
|
@ -283,34 +287,26 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -283,34 +287,26 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// type lookup for typename, assembly, xyz style lookups
|
|
|
|
|
if (type == null && idx > 0) { |
|
|
|
|
string[] splitName = name.Split(','); |
|
|
|
|
string typeName = splitName[0]; |
|
|
|
|
string assemblyName = splitName[1].Substring(1); |
|
|
|
|
Assembly assembly = null; |
|
|
|
|
try { |
|
|
|
|
assembly = Assembly.Load(assemblyName); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LoggingService.Error(e); |
|
|
|
|
} |
|
|
|
|
if (assembly != null) { |
|
|
|
|
lock (designerAssemblies) { |
|
|
|
|
if (!designerAssemblies.Contains(assembly)) |
|
|
|
|
designerAssemblies.Add(assembly); |
|
|
|
|
} |
|
|
|
|
type = assembly.GetType(typeName, false, ignoreCase); |
|
|
|
|
} else { |
|
|
|
|
type = Type.GetType(typeName, false, ignoreCase); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (type == null) { |
|
|
|
|
lock (designerAssemblies) { |
|
|
|
|
foreach (Assembly asm in DesignerAssemblies) { |
|
|
|
|
Type t = asm.GetType(name, false); |
|
|
|
|
if (t != null) { |
|
|
|
|
return t; |
|
|
|
|
int idx = name.IndexOf(","); |
|
|
|
|
if (idx > 0) { |
|
|
|
|
string[] splitName = name.Split(','); |
|
|
|
|
string typeName = splitName[0]; |
|
|
|
|
string assemblyName = splitName[1].Substring(1); |
|
|
|
|
Assembly assembly = null; |
|
|
|
|
try { |
|
|
|
|
assembly = Assembly.Load(assemblyName); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LoggingService.Error(e); |
|
|
|
|
} |
|
|
|
|
if (assembly != null) { |
|
|
|
|
lock (designerAssemblies) { |
|
|
|
|
if (!designerAssemblies.Contains(assembly)) |
|
|
|
|
designerAssemblies.Add(assembly); |
|
|
|
|
} |
|
|
|
|
type = assembly.GetType(typeName, false, ignoreCase); |
|
|
|
|
} else { |
|
|
|
|
type = Type.GetType(typeName, false, ignoreCase); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|