CommandLinePersistence mPersistence; // TODO early prototype - abolish, implement IPersistable instead! #region IPersistable void IPersistable.LoadFrom(IPersistency persistency) { string instance = DockItem.Id.ToString(); if (mPersistence == null) { mPersistence = new CommandLinePersistence(); } mPersistence.Script = persistency.LoadSetting(instance, "Script", ""); #region support old serializer for a while, replace by better implementation if (mPersistence.Script.Length == 0) { mPersistence = (CommandLinePersistence)ComponentManager.LoadObject("CommandLine", typeof(CommandLinePersistence), DockItem); } #endregion }
public override void Loaded(DockItem item) { base.Loaded(item); mPersistence = (CommandLinePersistence)ComponentManager.LoadObject("CommandLine", typeof(CommandLinePersistence), item); Task.Factory.StartNew(() => { System.Threading.Thread.CurrentThread.Name = "CommandLine.Loaded"; if (mPersistence == null) { mPersistence = new CommandLinePersistence() { Script = "" } } ; // TODO: set a default script here try { ComponentManager.Execute(mPersistence.Script); } catch (Exception ex) { consoleview.WriteOutput("Error: " + ex.Message); consoleview.Prompt(true); } m_ScriptingInstance = new CommandScript(this, consoleview, ComponentManager); // output can be redirected to any object which implements method write and property softspace string[] phython_script_for_redirecting_stdout_and_stderr = new string[] { "import sys", "cmd=app().GetInstance(\"" + (this as ILocalizableComponent).Name + "\")", "sys.stderr=cmd", "sys.stdout=cmd" }; ComponentManager.Execute(String.Join("\r\n", phython_script_for_redirecting_stdout_and_stderr)); }); }
public override void Loaded() { // important to call base first to ensure loading of persistency base.Loaded(); Task.Factory.StartNew(() => { if (mPersistence == null) mPersistence = new CommandLinePersistence() { Script = "" }; // TODO: set a default script here try { ComponentManager.Execute(mPersistence.Script); } catch (Exception ex) { consoleview.WriteOutput("Error: " + ex.Message); consoleview.Prompt(true); } m_ScriptingInstance = new CommandScript(this, consoleview, ComponentManager); // output can be redirected to any object which implements method write and property softspace string[] phython_script_for_redirecting_stdout_and_stderr = new string[] { "import sys", "cmd=app().GetInstance(\""+(this as ILocalizableComponent).Name+"\")", "sys.stderr=cmd", "sys.stdout=cmd" }; ComponentManager.Execute(String.Join("\r\n", phython_script_for_redirecting_stdout_and_stderr)); }); }
void IPersistable.LoadFrom(IPersistency persistency) { string instance = DockItem.Id.ToString(); if (mPersistence == null) mPersistence = new CommandLinePersistence(); mPersistence.Script = persistency.LoadSetting(instance, "Script", ""); #region support old serializer for a while, replace by better implementation if (mPersistence.Script.Length == 0) mPersistence = (CommandLinePersistence)ComponentManager.LoadObject("CommandLine", typeof(CommandLinePersistence), DockItem); #endregion }