public void ReloadScriptables() { foreach (Scriptable s in scriptables) { Object.Destroy(s); } scriptables.Clear(); WorldGenerator worldGenerator = GameObject.Find("WorldGenerator").GetComponent <WorldGenerator>(); scriptables = new List <Scriptable>(); GameObject scriptable; if (scriptablesInfo.ContainsKey(worldGenerator.world_id)) { foreach (ScriptableInfo s in scriptablesInfo[worldGenerator.world_id]) { //all scriptables must implement "Scriptable" string pathname = "Scriptables/" + s.prefabName; scriptable = (GameObject)Instantiate((GameObject)Resources.Load(pathname)); Scriptable script = scriptable.GetComponent <Scriptable>(); script.Load(this, s); scriptables.Add(scriptable.GetComponent <Scriptable>()); } } }
internal void Initialize(XMLLibImpl lib, Scriptable scope, XMLObject prototype) { SetParentScope(scope); SetPrototype(prototype); prototypeFlag = (prototype == null); this.lib = lib; }
public override Scriptable Construct(Context cx, Scriptable scope, object[] args) { NativeRegExp re = new NativeRegExp(); re.Compile(cx, scope, args); ScriptRuntime.SetBuiltinProtoAndParent(re, scope, TopLevel.Builtins.RegExp); return re; }
public virtual object Action(Context cx, Scriptable scope, Scriptable thisObj, object[] args, int actionType) { GlobData data = new GlobData(); data.mode = actionType; switch (actionType) { case RegExpProxyConstants.RA_MATCH: { object rval; data.optarg = 1; rval = MatchOrReplace(cx, scope, thisObj, args, this, data, false); return data.arrayobj == null ? rval : data.arrayobj; } case RegExpProxyConstants.RA_SEARCH: { data.optarg = 1; return MatchOrReplace(cx, scope, thisObj, args, this, data, false); } case RegExpProxyConstants.RA_REPLACE: { object arg1 = args.Length < 2 ? Undefined.instance : args[1]; string repstr = null; Function lambda = null; if (arg1 is Function) { lambda = (Function)arg1; } else { repstr = ScriptRuntime.ToString(arg1); } data.optarg = 2; data.lambda = lambda; data.repstr = repstr; data.dollar = repstr == null ? -1 : repstr.IndexOf('$'); data.charBuf = null; data.leftIndex = 0; object val = MatchOrReplace(cx, scope, thisObj, args, this, data, true); if (data.charBuf == null) { if (data.global || val == null || !val.Equals(true)) { return data.str; } SubString lc = this.leftContext; Replace_glob(data, cx, scope, this, lc.index, lc.length); } SubString rc = this.rightContext; data.charBuf.AppendRange(rc.str, rc.index, rc.index + rc.length); return data.charBuf.ToString(); } default: { throw Kit.CodeBug(); } } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { IShapeContainer container = CurrentPage.SelectionContainer(); if (container == null) { MessageBox.Show(Strings.Item("Container_Mismatch")); return; } transaction.Edit((Datum)container); List <Shape> created = new List <Shape>(); int nextID = (from p in Globals.Root.CurrentDocument.Pages select p.FindHighestUsedID()).Max() + 1; foreach (Shape s in CurrentPage.SelectedShapes) { transaction.Edit(s); Scriptable scriptable = new Scriptable(s); transaction.Create(scriptable); scriptable.Parent = container; scriptable.SAWID = nextID++; container.Contents.Remove(s); container.Contents.Add(scriptable); // note this makes no attempt to maintain Z order. Edited items will be brought to the front (but are likely to maintain relative order) created.Add(scriptable); } container.FinishedModifyingContents(transaction); // it should still be the contained elements which are listed as selected I think CurrentPage.SelectOnly(created); }
/// <summary>Create function compiled from Function(...) constructor.</summary> /// <remarks>Create function compiled from Function(...) constructor.</remarks> internal static Rhino.InterpretedFunction CreateFunction(Context cx, Scriptable scope, InterpreterData idata, object staticSecurityDomain) { Rhino.InterpretedFunction f; f = new Rhino.InterpretedFunction(idata, staticSecurityDomain); f.InitScriptFunction(cx, scope); return f; }
internal static void Init(Scriptable scope, bool @sealed) { Rhino.NativeDate obj = new Rhino.NativeDate(); // Set the value of the prototype Date to NaN ('invalid date'); obj.date = ScriptRuntime.NaN; obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed); }
private void runBtn_Click(object sender, EventArgs e) { rhino = Context.enter(); rhino.setOptimizationLevel(-1); rhino.setLanguageVersion(Context.VERSION_ES6); //버전을 ES6으로 지정 Script script; try { scope = new ImporterTopLevel(rhino); ScriptableObject.putProperty(scope, "ctx", this); ScriptableObject.defineClass(scope, new customMethod.Api().getClass()); //Api라는 클래스 추가 /*컴파일 * * script = rhino.compileReader(reader, "JavaScript", 1, null); * resultBox.Text = script.exec(rhino, scope); */ resultBox.Text = rhino.evaluateString(scope, codeBox.Text, "JavaScript", 1, null).ToString(); //실행 } catch (Exception error) { resultBox.Text = error.ToString(); } finally { Context.exit(); } }
public ModuleScope(Scriptable prototype, Uri uri, Uri @base) { this.uri = uri; this.@base = @base; SetPrototype(prototype); CacheBuiltins(); }
/// <exception cref="System.IO.IOException"></exception> private ModuleSource LoadFromPathArray(string moduleId, Scriptable paths, object validator) { long llength = ScriptRuntime.ToUint32(ScriptableObject.GetProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > int.MaxValue ? int.MaxValue : (int)llength; for (int i = 0; i < ilength; ++i) { string path = EnsureTrailingSlash(ScriptableObject.GetTypedProperty<string>(paths, i)); try { Uri uri = new Uri(path); if (!uri.IsAbsoluteUri) { uri = new FilePath(path).ToURI().Resolve(string.Empty); } ModuleSource moduleSource = LoadFromUri(uri.Resolve(moduleId), uri, validator); if (moduleSource != null) { return moduleSource; } } catch (URISyntaxException e) { throw new UriFormatException(e.Message); } } return null; }
void Switcher(Scriptable scriptable, List <System.Object> objects, int i, bool toSet) { switch (scriptable) { case Scriptable.weapons: if (!toSet) { objects.Add(Weapons[i].GetSerializers()); } else { Weapons[i].SetSerializers(objects, i); } break; case Scriptable.levels: if (!toSet) { objects.Add(Levels[i].GetSerializers()); } else { Levels[i].SetSerializers(objects, i); } break; default: break; } }
private static void RunFileIfExists(Context cx, Scriptable global, FilePath f) { if (f.IsFile()) { Main.ProcessFileNoThrow(cx, global, f.GetPath()); } }
/// <summary>Used by the Paste verb to do the paste in this case</summary> public static void Paste(Transaction transaction) { DataObject data = (DataObject)Clipboard.GetDataObject(); byte[] buffer = (byte[])data.GetData("Splash scripts", false); if (buffer == null) { Debug.Fail("Deserialisation failed"); return; } using (MemoryStream stream = new MemoryStream(buffer, false)) using (DataReader reader = new DataReader(stream, (FileMarkers)Shape.Shapes.Scriptable)) { Scriptable copied = (Scriptable)reader.ReadData((FileMarkers)Shape.Shapes.Scriptable); foreach (Scriptable target in CurrentPage.SelectedShapes.OfType <Scriptable>()) { transaction.Edit(target); target.RepeatTimeout = copied.RepeatTimeout; foreach (Scriptable.ScriptTypes type in Enum.GetValues(typeof(Scriptable.ScriptTypes))) { target.SetScript(type, copied.GetScript(type)); } } } }
/// <summary>Used by the Paste verb to do the paste in this case</summary> public static void Paste(Transaction transaction, EditableView pnlView) { DataObject data = (DataObject)Clipboard.GetDataObject(); byte[] buffer = (byte[])data.GetData("Splash presentation", false); if (buffer == null) { Debug.Fail("Deserialisation failed"); return; } using (MemoryStream stream = new MemoryStream(buffer, false)) using (DataReader reader = new DataReader(stream, (FileMarkers)Shape.Shapes.SAWItem)) { Item copied = (Item)reader.ReadData((FileMarkers)Shape.Shapes.SAWItem); copied.UpdateReferencesObjectsCreated(CurrentDocument, reader); //copied.UpdateReferencesIDsChanged(hashIDChanges, Globals.Root.CurrentDocument); foreach (Shape target in CurrentPage.SelectedShapes) { Item itemTarget = (Item)((target as Scriptable)?.Element ?? target); // unwraps the Scriptable if that was selected transaction.Edit(itemTarget); if (string.IsNullOrEmpty(itemTarget.LabelText)) { itemTarget.LabelText = copied.LabelText; } itemTarget.FillStyle?.CopyFrom(copied.FillStyle); itemTarget.LineStyle?.CopyFrom(copied.LineStyle); itemTarget.TextStyle?.CopyFrom(copied.TextStyle); itemTarget.CopyPresentationFrom(copied, true); Scriptable scriptableTarget = target as Scriptable ?? (Scriptable)(target as Item).Parent; scriptableTarget.CopyPresentationFrom((Scriptable)copied.Parent, true); } } pnlView.InvalidateData(CurrentPage.SelectedRefreshBoundary(), StaticView.InvalidationBuffer.All); }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { Scriptable scriptable = pnlView.CurrentPage.SelectedShapes.First() as Scriptable; if (scriptable == null) { return; } // write the list of shapes into a byte buffer; this way we control the serialisation DataObject data = new DataObject(); using (MemoryStream buffer = new MemoryStream(1000)) using (DataWriter writer = new DataWriter(buffer, (FileMarkers)Shape.Shapes.Scriptable)) { writer.Write(scriptable); data.SetData("Splash scripts", false, buffer.GetBuffer()); } IndentStringBuilder output = new IndentStringBuilder(); // store as text as well foreach (Scriptable.ScriptTypes type in Enum.GetValues(typeof(Scriptable.ScriptTypes))) { Script script = scriptable.GetScript(type); script?.WriteExportText(output, Strings.Item("SAW_ScriptType_" + type)); } if (output.Length > 0) { data.SetText(output.ToString()); } // store result on clipboard Clipboard.SetDataObject(data); }
internal static void Init(Scriptable scope, bool @sealed) { Rhino.BaseFunction obj = new Rhino.BaseFunction(); // Function.prototype attributes: see ECMA 15.3.3.1 obj.prototypePropertyAttributes = DONTENUM | READONLY | PERMANENT; obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed); }
/// <seealso cref="Function.Call(Context, Scriptable, Scriptable, object[])">Function.Call(Context, Scriptable, Scriptable, object[])</seealso> public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args) { object sync = syncObject != null ? syncObject : thisObj; lock (sync is Wrapper ? ((Wrapper)sync).Unwrap() : sync) { return ((Function)obj).Call(cx, scope, thisObj, args); } }
public void ShowUnimplementedScriptPanel(Scriptable scriptable) { VisibleImplementedScriptPanel(false); currentScriptable = scriptable; unimplementedScriptText.text = scriptable.script; unimplementedScriptName.text = scriptable.name; VisibleUnimplementedScriptPanel(true); }
public virtual object Get(int index, Scriptable start) { if (start == this) { start = prototype; } return prototype.Get(index, start); }
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args) { if (args.Length > 0 && args[0] is NativeRegExp && (args.Length == 1 || args[1] == Undefined.instance)) { return args[0]; } return Construct(cx, scope, args); }
public override bool HasInstance(Scriptable instance) { if (targetFunction is Function) { return ((Function)targetFunction).HasInstance(instance); } throw ScriptRuntime.TypeError0("msg.not.ctor"); }
public override Scriptable Construct(Context cx, Scriptable scope, object[] extraArgs) { if (targetFunction is Function) { return ((Function)targetFunction).Construct(cx, scope, Concat(boundArgs, extraArgs)); } throw ScriptRuntime.TypeError0("msg.not.ctor"); }
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args) { if (script != null) { return script.Exec(cx, scope); } return Undefined.instance; }
public override bool Has(string name, Scriptable start) { if (this == thePrototypeInstance) { return base.Has(name, start); } return (Runtime.GetProperty(name) != null); }
public virtual object Get(string id, Scriptable start) { if (start == this) { start = prototype; } return prototype.Get(id, start); }
/// <summary>ScriptableOutputStream constructor.</summary> /// <remarks> /// ScriptableOutputStream constructor. /// Creates a ScriptableOutputStream for use in serializing /// JavaScript objects. Calls excludeStandardObjectNames. /// </remarks> /// <param name="out">the OutputStream to write to.</param> /// <param name="scope">the scope containing the object.</param> /// <exception cref="System.IO.IOException"></exception> public ScriptableOutputStream(Stream @out, Scriptable scope) : base(@out) { // API class this.scope = scope; table = new Dictionary<object, string>(); table.Put(scope, string.Empty); EnableReplaceObject(true); ExcludeStandardObjectNames(); }
/// <summary>Search for ClassCache object in the given scope.</summary> /// <remarks> /// Search for ClassCache object in the given scope. /// The method first calls /// <see cref="ScriptableObject.GetTopLevelScope(Scriptable)">ScriptableObject.GetTopLevelScope(Scriptable)</see> /// to get the top most scope and then tries to locate associated /// ClassCache object in the prototype chain of the top scope. /// </remarks> /// <param name="scope">scope to search for ClassCache object.</param> /// <returns> /// previously associated ClassCache object or a new instance of /// ClassCache if no ClassCache object was found. /// </returns> /// <seealso cref="Associate(ScriptableObject)">Associate(ScriptableObject)</seealso> public static ClassCache Get(Scriptable scope) { ClassCache cache = (ClassCache)ScriptableObject.GetTopScopeValue(scope, AKEY); if (cache == null) { throw new Exception("Can't find top level scope for " + "ClassCache.get"); } return cache; }
/// <summary>Implements the instanceof operator for JavaScript Function objects.</summary> /// <remarks> /// Implements the instanceof operator for JavaScript Function objects. /// <p> /// <code> /// foo = new Foo();<br /> /// foo instanceof Foo; // true<br /> /// </code> /// </remarks> /// <param name="instance"> /// The value that appeared on the LHS of the instanceof /// operator /// </param> /// <returns> /// true if the "prototype" property of "this" appears in /// value's prototype chain /// </returns> public override bool HasInstance(Scriptable instance) { object protoProp = ScriptableObject.GetProperty(this, "prototype"); if (protoProp is Scriptable) { return ScriptRuntime.JsDelegatesTo(instance, (Scriptable)protoProp); } throw ScriptRuntime.TypeError1("msg.instanceof.bad.prototype", GetFunctionName()); }
public void AddScript(Scriptable script) { if (scripts.Count(x => x.IsNotNull()) == 1) { return; } script.AddHost(this); scripts.Add(script); }
internal static void Init(Scriptable scope, bool @sealed) { NativeError obj = new NativeError(); ScriptableObject.PutProperty(obj, "name", "Error"); ScriptableObject.PutProperty(obj, "message", string.Empty); ScriptableObject.PutProperty(obj, "fileName", string.Empty); ScriptableObject.PutProperty(obj, "lineNumber", Sharpen.Extensions.ValueOf(0)); obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed); }
void Loop(Scriptable scriptable, List <System.Object> objects, int i, UnityAction call) { int length = GetLength(scriptable); for (i = 0; i < length; i++) { call(); } }
public static void Init(Context cx, Scriptable scope, bool @sealed) { Rhino.Xmlimpl.XMLLibImpl lib = new Rhino.Xmlimpl.XMLLibImpl(scope); XMLLib bound = lib.BindToScope(scope); if (bound == lib) { lib.ExportToScope(@sealed); } }
private void View_MouseLeave(object sender, EventArgs e) { if (m_Current == null) { return; } m_Current = null; OnCurrentChanged(); }
private void View_MouseLeave(object sender, EventArgs e) { m_MouseOver = null; if (m_Clicked != null) { OnStateChange(false); } m_Clicked = null; }
internal static Rhino.Xmlimpl.Namespace Create(Scriptable scope, Rhino.Xmlimpl.Namespace prototype, Rhino.Xmlimpl.XmlNode.Namespace @namespace) { Rhino.Xmlimpl.Namespace rv = new Rhino.Xmlimpl.Namespace(); rv.SetParentScope(scope); rv.prototype = prototype; rv.SetPrototype(prototype); rv.ns = @namespace; return rv; }
public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr) { IDictionary <string, object> testParams = new Dictionary <string, object>(); IMachine machine = null; string testKey = DEFAULT_TESTKEY; // Initialize test arguments with plan arguments. foreach (var arg in planArguments) { testParams[arg.Key] = arg.Value; } // Override above with user arguments if (objarr.Length > 0) { IdScriptableObject sObj = objarr[0] as IdScriptableObject; if (sObj != null) { foreach (object id in sObj.getIds()) { object value = sObj.get(id); testParams[id.ToString()] = value; } } } // Find magic arguments foreach (var parm in testParams) { object value = parm.Value; switch (parm.Key) { case ARG_TESTKEY: testKey = value.ToString(); break; case ARG_MACHINE: machine = new MachineResolver(provider).Resolve(value); break; } } if (machine == null) { throw new Exception("Test requires '" + ARG_MACHINE + "' argument"); } var stringParams = testParams.ToDictionary(e => e.Key, e => e.Value.ToString()); return(Context.javaToJS(InvokeTest(machine, testKey, stringParams), s1)); }
/// <summary> /// More complicated example: this form of call allows variable /// argument lists, and allows access to the 'this' object. /// </summary> /// <remarks> /// More complicated example: this form of call allows variable /// argument lists, and allows access to the 'this' object. For /// a global function, the 'this' object is the global object. /// In this case we look up a value that we associated with the global /// object using /// <see cref="Rhino.ScriptableObject.GetAssociatedValue(object)">Rhino.ScriptableObject.GetAssociatedValue(object)</see> /// . /// </remarks> public static object G(Context cx, Scriptable thisObj, object[] args, Function funObj) { object arg = args.Length > 0 ? args[0] : Undefined.instance; object privateValue = Undefined.instance; if (thisObj is ScriptableObject) { privateValue = ((ScriptableObject)thisObj).GetAssociatedValue(key); } return arg.ToString() + privateValue; }
private void View_MouseMove(object sender, MouseEventArgs e) { m_MouseOver = PointerSwitch.View.HitTest(e.Location); if (m_Clicked != null && m_Clicked != m_MouseOver) { OnStateChange(false); m_Clicked = null; m_Selected = null; // because UI will probably deselect? } }
protected internal XMLLib BindToScope(Scriptable scope) { ScriptableObject so = ScriptRuntime.GetLibraryScopeOrNull(scope); if (so == null) { // standard library should be initialized at this point throw new InvalidOperationException(); } return (XMLLib)so.AssociateValue(XML_LIB_KEY, this); }
public static XMLLib ExtractFromScope(Scriptable scope) { XMLLib lib = ExtractFromScopeOrNull(scope); if (lib != null) { return lib; } string msg = ScriptRuntime.GetMessage0("msg.XML.not.available"); throw Context.ReportRuntimeError(msg); }
public override object Get(int index, Scriptable start) { if (0 <= index && index < length) { Context cx = Context.GetContext(); object obj = Sharpen.Runtime.GetArrayValue(array, index); return cx.GetWrapFactory().Wrap(cx, this, obj, cls); } return Undefined.instance; }
private void WriteSetting(Scriptable target) { for (int i = 1; i <= MAX_INSTANCE_ID; ++i) { int id = base.GetMaxInstanceId() + i; string name = GetInstanceIdName(id); object value = GetInstanceIdValue(id); ScriptableObject.PutProperty(target, name, value); } }
internal static Rhino.Xmlimpl.QName Create(XMLLibImpl lib, Scriptable scope, Rhino.Xmlimpl.QName prototype, Rhino.Xmlimpl.XmlNode.QName delegate_) { Rhino.Xmlimpl.QName rv = new Rhino.Xmlimpl.QName(); rv.lib = lib; rv.SetParentScope(scope); rv.prototype = prototype; rv.SetPrototype(prototype); rv.delegate_ = delegate_; return rv; }
public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr) { IDictionary<string, object> testParams = new Dictionary<string, object>(); IMachine machine = null; string testKey = DEFAULT_TESTKEY; // Initialize test arguments with plan arguments. foreach(var arg in planArguments) { testParams[arg.Key] = arg.Value; } // Override above with user arguments if(objarr.Length > 0) { IdScriptableObject sObj = objarr[0] as IdScriptableObject; if(sObj != null) { foreach(object id in sObj.getIds()) { object value = sObj.get (id); testParams[id.ToString()] = value; } } } // Find magic arguments foreach(var parm in testParams) { object value = parm.Value; switch(parm.Key) { case ARG_TESTKEY: testKey = value.ToString(); break; case ARG_MACHINE: machine = new MachineResolver(provider).Resolve(value); break; } } if(machine == null) { throw new Exception("Test requires '" + ARG_MACHINE + "' argument"); } var stringParams = testParams.ToDictionary(e => e.Key, e => e.Value.ToString()); return Context.javaToJS(InvokeTest (machine, testKey, stringParams), s1); }
public override void Execute(ExecutionContext context) { int id = GetParamAsInt(0); Scriptable item = context.Page.FindScriptableByID(id); if (item == null) { throw new UserException(Strings.Item("Script_Error_CannotFindItem").Replace("%0", GetParamAsString(0))); } context.View.InvokeScript(item, Scriptable.ScriptTypes.Select, false, context.TargetItem); }
public override void Execute(ExecutionContext context) { int ID = GetParamAsInt(0); Scriptable item = context.Page.FindScriptableByID(ID); if (item == null) { context.View.OnFail("Item " + ID + " not found for " + GetCommandName()); return; } context.View.InvokeScript(item, Scriptable.ScriptTypes.Select, true, item); // note item is set as the context - unlike exec item }
private Scriptable CreateButton(string text, Element topLeft, Element size, Page page) { Item item = new Item(); item.SetBounds(GetRect(topLeft, size, page)); item.LabelText = text; Scriptable script = new Scriptable(item); script.SAWID = m_NextID++; script.HighlightStyle.LineColour = Color.White; script.HighlightStyle.FillColour = Color.Red; return(script); }
public void ShowImplementedScriptPanel(ScriptableHost host) { VisibleUnimplementedScriptPanel(false); currentScriptable = host.scripts.First(); if (currentScriptable.IsNull()) { VisibleImplementedScriptPanel(false); return; } implementedScriptText.text = currentScriptable.script; implementedScriptName.text = currentScriptable.name; implementedHostName.text = host.name; VisibleImplementedScriptPanel(true); }
protected Scriptable ResolveTarget(ExecutionContext context) { if (AffectsThis) { return(context.TargetItem); } Scriptable result = context.Page.FindScriptableByID(ItemID); if (result == null) { throw new UserException(Strings.Item("Script_Error_CannotFindItem").Replace("%0", ItemID.ToString())); } return(result); }
private void View_MouseMove(object sender, MouseEventArgs e) { if (View == null) // can happen if this event was queued from before window closed { return; } Scriptable hit = View.HitTest(e.Location); if (hit != m_Current) { m_Current = hit; OnCurrentChanged(); } }
int GetLength(Scriptable scriptable) { switch (scriptable) { case Scriptable.weapons: return(Weapons.Length); case Scriptable.levels: return(Levels.Length); default: break; } return(0); }
public override void Execute(ExecutionContext context) { Script.VisitTarget temp = new Script.VisitTarget() { VisitType = m_Target }; if (m_Target == Script.VisitTarget.VisitTypes.Item) { temp.ItemID = GetParamAsInt(0); } Scriptable item = context.View.ResolveVisitTarget(temp, context.TargetItem); if (item != null) // i think a null here is not any sort of error. Eg Down in an item with no contents is just ignored { context.View.SelectItem(item, false); // must be false or View will enter infinite loop as the leave script calls back to this } }
/// <summary> /// Loads the script assembly /// </summary> /// <param name="name">Name of the assembly to be loaded, namespace must be Script and main class must be named Script</param> /// <returns></returns> public Scriptable loadScript(string name) { assembly = null; try { assembly = Assembly.Load(loadFile(name)); } catch (System.IO.FileNotFoundException e) { Console.WriteLine(e.ToString()); return(null); } if (assembly == null) { Console.WriteLine("Couldn't load assembly"); return(null); } Type script = assembly.GetType("Script.Script"); if (script == null) { Console.WriteLine("Script Type is null"); return(null); } Scriptable scriptInstance = null; try { scriptInstance = (Scriptable)Activator.CreateInstance(script); } catch (Exception e) { Console.WriteLine("Load Error" + e.ToString()); } this.script = scriptInstance; return(scriptInstance); }
public object SaveLoad(Scriptable scriptable, Cmd cmd, List <System.Object> objects) { int i = 0; switch (cmd) { case Cmd.Get: List <System.Object> _objects = new List <System.Object>(); Loop(scriptable, _objects, i, () => Switcher(scriptable, _objects, i, false)); return(_objects); case Cmd.Set: Loop(scriptable, objects, i, () => Switcher(scriptable, objects, i, true)); break; default: break; } return(null); }
/// <summary>Start editing the given command. The scriptable can be given for context, or can be null (it is never essential)</summary> public void EditCommand(Command value, Scriptable scriptable) { if (value == m_Command) // no nothing if the value isn't actually changed { return; } m_Command = value; ContainerScriptable = scriptable; if (m_Control != null) { m_Control.UserChanged -= Control_UserChanged; (m_Control as Control).Dispose(); Controls.Remove(m_Control as Control); } m_Control = m_Command?.GetEditor(); if (m_Control != null) { Control control = m_Control as Control; control.Dock = DockStyle.Fill; Controls.Add(control); m_Control.EditCommand = m_Command; m_Control.UserChanged += Control_UserChanged; } }
public object call(Context c, Scriptable scope, Scriptable thisObj, object[] objarr) { if (objarr.Length < 1) { throw new Exception("Snapshot function requires machine argument"); } IMachine machine = new MachineResolver(provider).Resolve(objarr[0]); initFunc(machine); var snapshotId = machine.MakeSnapshot(); // We need to clean up the snapshots at some point. Action oldAction = CleanupSnapshots; CleanupSnapshots = () => { machine.DeleteSnapshot(snapshotId); oldAction(); }; return(new SnapshotObject(machine, snapshotId)); }
public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr) { act(); return(Undefined.instance); }
public object call(Context c, Scriptable s1, Scriptable thisObj, object[] objarr) { return(val); }
public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr) { Console.WriteLine(objarr[0].ToString()); return(Undefined.instance); }
public Model(Scriptable scriptable) { this.scriptable = scriptable; }