public void Execute(int timeout, ILog log) { log.Write("Executing Template Instance '{0}'", this.SavedObjectName); string path = FileTools.ResolvePath(this.TemplatePath); ZeusTemplate template = new ZeusTemplate(path); ZeusInput zin = new ZeusInput(); zin.AddItems(this.InputItems); this.ApplyOverrideData(zin); ZeusContext context = new ZeusContext(zin, /*new GuiController(),*/ new Hashtable()); context.Log = log; template.Execute(context, timeout, true); foreach (string file in context.Output.SavedFiles) { if (!SavedFiles.Contains(file)) { SavedFiles.Add(file); } } }
private static void LoadEngines() { ZeusConfig config = ZeusConfig.Current; IZeusScriptingEngine engine; _engines = new Hashtable(); engine = new DotNetScript.DotNetScriptEngine(); _engines.Add(engine.EngineName, engine); engine = new MicrosoftScript.MicrosoftScriptEngine(); _engines.Add(engine.EngineName, engine); string path; Assembly assembly; foreach (string unparsedpath in config.ScriptingEngines) { if (unparsedpath.EndsWith("MicrosoftScriptingEngine.dll", StringComparison.CurrentCultureIgnoreCase) || unparsedpath.EndsWith("DotNetScriptingEngine.dll", StringComparison.CurrentCultureIgnoreCase)) { continue; } else { path = FileTools.ResolvePath(unparsedpath, true); assembly = DynamicAssemblyTools.LoadDynamicAssembly(path); if (assembly != null) { object[] tmp = DynamicAssemblyTools.InstantiateClassesByType(assembly, typeof(IZeusScriptingEngine)); for (int i = 0; i < tmp.Length; i++) { engine = tmp[i] as IZeusScriptingEngine; if (engine != null) { _engines.Add(engine.EngineName, engine); } } } else { throw new ZeusDynamicException(ZeusDynamicExceptionType.ScriptingEnginePluginInvalid, path); } assembly = null; } } }
protected static void PopulateContextObjects(IZeusContext icontext) { ZeusContext context = icontext as ZeusContext; if (icontext != null) { ZeusConfig config = ZeusConfig.Current; context.SetIntrinsicObjects(ZeusFactory.IntrinsicObjectsArray); foreach (ZeusIntrinsicObject obj in config.IntrinsicObjects) { Type intrinsicObjectType = null; Assembly newassembly = null; object[] objs = null; if (!context.Objects.Contains(obj.VariableName) && !obj.Disabled) { newassembly = obj.Assembly; // First thing, try to create the type without knowing the assembly. /*try * { * intrinsicObjectType = Type.GetType(obj.ClassPath); * } * catch * { * intrinsicObjectType = null; * }*/ if (intrinsicObjectType == null) { try { if (obj.AssemblyPath != string.Empty) { string assemblyPath = obj.AssemblyPath; if (newassembly == null) { assemblyPath = FileTools.ResolvePath(assemblyPath, true); FileInfo finf = new FileInfo(assemblyPath); FileInfo callingfinf = new FileInfo(Assembly.GetCallingAssembly().Location); if (callingfinf.FullName == finf.FullName) { newassembly = Assembly.GetCallingAssembly(); } } if (newassembly == null) { throw new ZeusDynamicException(ZeusDynamicExceptionType.IntrinsicObjectPluginInvalid, "Invalid Assembly: " + assemblyPath); } else { intrinsicObjectType = newassembly.GetType(obj.ClassPath); } } else { intrinsicObjectType = Type.GetType(obj.ClassPath); } } catch (ZeusDynamicException zex) { context.Objects[obj.VariableName] = zex.Message; } } if (intrinsicObjectType != null) { try { if (intrinsicObjectType != null) { if (newassembly != null) { objs = DynamicAssemblyTools.InstantiateClassesByType(newassembly, newassembly.GetType(obj.ClassPath)); } else { objs = new object[1]; objs[0] = DynamicAssemblyTools.InstantiateClassByType(intrinsicObjectType); } } else { throw new ZeusDynamicException(ZeusDynamicExceptionType.IntrinsicObjectPluginInvalid, "Invalid Type: " + obj.ClassPath); } if (objs != null) { if (objs.Length > 0) { context.Objects[obj.VariableName] = objs[0]; } } } catch (ZeusDynamicException zex) { context.Objects[obj.VariableName] = zex.Message; } } } } } }