/// <summary> /// /// </summary> /// <returns></returns> public Type GetExpertType(ref string operationResultMessage) { if (IsExternal) { return(ContainingAssemblyExpertType); } // We need to compile runtime. Dictionary <string, int> messages; Assembly assembly = CompilationHelper.CompileSourceToAssembly(_sourceCode, out messages); if (assembly == null) { operationResultMessage = "Failed to compile expert source code."; return(null); } List <Type> expertTypes = new List <Type>(); foreach (Type type in assembly.GetExportedTypes()) { if (type.IsSubclassOf(typeof(PlatformManagedExpert))) { expertTypes.Add(type); } } if (expertTypes.Count == 0) { operationResultMessage = "Failed to find expert type in expert source code."; return(null); } if (expertTypes.Count > 1) { operationResultMessage = "More than one expert type found in source code, creating instance of the first one found."; } return(expertTypes[0]); }
private Assembly CompileSource(String source) { Dictionary <string, int> messages; Assembly assembly = CompilationHelper.CompileSourceToAssembly(source, out messages); this.listViewMessages.Items.Clear(); if (assembly == null) { foreach (string message in messages.Keys) { ListViewItem item = new ListViewItem(message, "error"); item.Tag = messages[message]; this.listViewMessages.Items.Add(item); } } else { ListViewItem item = new ListViewItem("Compiled succesfully", "ok"); this.listViewMessages.Items.Add(item); } return(assembly); }