public static string GetHrefFromData(Core.Context context, object data) { if (data is Core.ElementReference el) { return(el.Eval(context, ".href")?.ToString()); } return(data?.ToString()); }
protected override object OnExecute(Core.Context context, int index, object data) { var dataString = ((data is Core.ElementReference el) ? el.Eval(context, "outerHTML") : data)?.ToString(); dataString = ProcessText(dataString); context.Field(RecordName, Name, dataString, IsUnique); return(dataString); }
protected override object OnExecute(Core.Context context, int index, object data) { switch (Mode) { case BreakMode.Stop: context.Stop(); return(null); case BreakMode.Action: return(new Core.BreakValue(Core.BreakValue.BreakMode.Break, ActionID)); } return(data); }
protected override object OnExecute(Core.Context context, int index, object data) { var key = FormatGroupName(data); switch (Action) { case ValueAction.Add: lock (context.Manager.Values) context.Manager.Values.Add(key); break; case ValueAction.Remove: lock (context.Manager.Values) context.Manager.Values.Remove(key); break; } return(data); }
protected override void Dispose(bool disposing) { if (disposing) { if (_context != null) { OwnerWindow.ContextManager.RemoveContext(_context); Context = null; } } base.Dispose(disposing); }
protected override object OnExecute(Core.Context context, int index, object data) { var href = GetHrefFromData(context, data); context.LoadUrl(href); if (Once) { lock (context.Manager.Values) context.Manager.Values.Add("Navigate$" + href); } context.WaitPage(Timeout); return(href); }
protected override object OnExecute(Core.Context context, int index, object data) { switch (Mode) { case WaitMode.Sleep: context.Sleep(Miliseconds); break; case WaitMode.Frame: context.WaitFrame(Miliseconds); break; case WaitMode.Page: context.WaitPage(Miliseconds); break; } return(data); }
public override int GetItemCount(Core.Context context, object data = null) { if (Once) { var href = GetHrefFromData(context, data); if (!string.IsNullOrEmpty(href)) { lock (context.Manager.Values) return(context.Manager.Values.Contains("Navigate$" + href) ? 0 : 1); } } return(base.GetItemCount(context, data)); }
internal Engine(Form1 Mainform) { this.Mainform = Mainform; this.Os = new Core.Context(); this.Os.Gi.Gui.Windows.Tabs.MainTabControl = this.Mainform.tabControl_WebTabs; var OsForPlugin = new TransOS.Core.Implement.Context(this.Os); this.WebBrowser = new Plugin.WebBrowser.Context(OsForPlugin); OsForPlugin = new TransOS.Core.Implement.Context(this.Os); this.Ridge = new Plugin.Ridge.Context(OsForPlugin); }
public override int GetItemCount(Core.Context context, object data = null) { var key = FormatGroupName(data); switch (Action) { case ValueAction.Exist: case ValueAction.Remove: lock (context.Manager.Values) return(context.Manager.Values.Contains(key) ? 1 : 0); case ValueAction.NotExist: case ValueAction.Add: lock (context.Manager.Values) return(context.Manager.Values.Contains(key) ? 0 : 1); } return(base.GetItemCount(context, data)); }
protected override object ExecuteElement(Core.Context context, Core.ElementReference element, object data) { string format = null; switch (PropertyType) { case PropertyType.Property: format = "{0}"; break; case PropertyType.Attribute: format = "attributes['{0}']"; break; case PropertyType.Style: format = "style['{0}']"; break; } return(element.Eval(context, string.Format(format, PropertyName))); }
protected override object OnExecute(Core.Context context, int index, object data) { var href = Navigate.GetHrefFromData(context, data); var newContext = context.PushContext(ContextTimeout); if (Clone) { var srcFrame = context.Browser.GetBrowser().MainFrame; var src = srcFrame.GetSourceAsync().Result; newContext.Browser.GetBrowser().MainFrame.LoadStringForUrl(src, context.Browser.Address); newContext.WaitPage(); //100 } newContext.Play(this, data, true, context.State == Core.ContextState.Pause); return(null); }
public void BindCustomCommand_MissingCommand() { var formatter = new TextOutputFormatter(); var ctx = new Core.Context(); ctx.CommandHandler = new Core.CommandHandler(ctx, formatter); var cmd = new Mod.BindCommand(); cmd.Initialise(ctx, formatter); cmd.CommandName = "c"; var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure)); }
public void BindCustomCommand() { var formatter = new TextOutputFormatter(); var ctx = new Core.Context(); ctx.CommandHandler = new Core.CommandHandler(ctx, formatter); var cmd = new Mod.BindCommand(); cmd.Initialise(ctx, formatter); cmd.Command = "Revolver.Test.BindCommand+CustomCommand, Revolver.Test"; cmd.CommandName = "c"; var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Success)); Assert.That(ctx.CommandHandler.CustomCommands, Contains.Item(new KeyValuePair<string, Type>("c", typeof(CustomCommand)))); }
public object Execute(Core.Context context, int index, object data) { if (Break) { context.Break(); } if (Beep) { System.Media.SystemSounds.Beep.Play(); } var ret = OnExecute(context, index, data); if (Log) { context.Log(ret?.ToString() ?? "[null]", ID); } return(ret); }
/// <summary> /// /// </summary> /// <param name="Os">Original TransOS context</param> public Context(Core.Context Os) { this.Os = Os; this.Network = new Network.This(Os.Network); /*this.ObjectFactory = new ObjectFactory.This(Os.ObjectFactory);*/ this.Settings = new Settings.This(this); this.Ridge = new Ridge.This(Os.Ridge); /*this.Log = new Log.This(Os.Log); * this.MainMenu = new MainMenu.This(Os.MainMenu); * this.Plugins = new Plugins.This(Os.Plugins); * this.Autorun = new Autorun.This(Os.Autorun); * this.HotKeys = new HotKeys.This(this);*/ this.Gi = new Gi.This(Os.Gi); this.Helper = new Helper.This(Os.Helper); this.Application = new Application.This(Os.Application); /*this.ParentOs = new ParentOs.This(Os.ParentOs); * this.FileSystem = new FileSystem.This(Os.FileSystem); * this.Converter = new Converter.This(Os.Converter);*/ }
public void RemoveCustomCommand() { var formatter = new TextOutputFormatter(); var ctx = new Core.Context(); ctx.CommandHandler = new Core.CommandHandler(ctx, formatter); ctx.CommandHandler.AddCustomCommand("c", typeof (CustomCommand)); var cmd = new Mod.BindCommand(); cmd.Initialise(ctx, formatter); cmd.CommandName = "c"; cmd.Remove = true; var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Success)); Assert.That(ctx.CommandHandler.CustomCommands, Is.Not.Contains(new KeyValuePair<string, Type>("c", typeof(CustomCommand)))); }
private void initParametersFast(Expression[] arguments, Core.Context initiator, Context internalContext) { JSValue a0 = null, a1 = null, a2 = null, a3 = null, a4 = null, a5 = null, a6 = null, a7 = null; // Вместо кучи, выделяем память на стеке var argumentsCount = arguments.Length; if (_functionDefinition.parameters.Length != argumentsCount) { throw new ArgumentException("Invalid arguments count"); } if (argumentsCount > 8) { throw new ArgumentException("To many arguments"); } if (argumentsCount == 0) { return; } /* * Да, от этого кода можно вздрогнуть, но по ряду причин лучше сделать не получится. * Такая она цена оптимизации */ /* * Эти два блока нельзя смешивать. Текущие значения параметров могут быть использованы для расчёта новых. * Поэтому заменять значения можно только после полного расчёта новых значений */ a0 = Tools.EvalExpressionSafe(initiator, arguments[0]); if (argumentsCount > 1) { a1 = Tools.EvalExpressionSafe(initiator, arguments[1]); if (argumentsCount > 2) { a2 = Tools.EvalExpressionSafe(initiator, arguments[2]); if (argumentsCount > 3) { a3 = Tools.EvalExpressionSafe(initiator, arguments[3]); if (argumentsCount > 4) { a4 = Tools.EvalExpressionSafe(initiator, arguments[4]); if (argumentsCount > 5) { a5 = Tools.EvalExpressionSafe(initiator, arguments[5]); if (argumentsCount > 6) { a6 = Tools.EvalExpressionSafe(initiator, arguments[6]); if (argumentsCount > 7) { a7 = Tools.EvalExpressionSafe(initiator, arguments[7]); } } } } } } } setParamValue(0, a0, internalContext); if (argumentsCount > 1) { setParamValue(1, a1, internalContext); if (argumentsCount > 2) { setParamValue(2, a2, internalContext); if (argumentsCount > 3) { setParamValue(3, a3, internalContext); if (argumentsCount > 4) { setParamValue(4, a4, internalContext); if (argumentsCount > 5) { setParamValue(5, a5, internalContext); if (argumentsCount > 6) { setParamValue(6, a6, internalContext); if (argumentsCount > 7) { setParamValue(7, a7, internalContext); } } } } } } } }
public override int GetItemCount(Core.Context context, object data = null) { return(new Core.ElementReference(Selector, IsGlobal ? null : data as Core.ElementReference).GetCount(context)); }
protected override object OnExecute(Core.Context context, int index, object data) { var elementReference = new Core.ElementReference(Selector, IsGlobal ? null : data as Core.ElementReference, index); return(ExecuteElement(context, elementReference, data)); }
protected override object ExecuteElement(Core.Context context, Core.ElementReference element, object data) { return(element); }
public void ListBindings() { var formatter = new TextOutputFormatter(); var ctx = new Core.Context(); ctx.CommandHandler = new Core.CommandHandler(ctx, formatter); var cmd = new Mod.BindCommand(); cmd.Initialise(ctx, formatter); var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message); Assert.That(result.Message, Contains.Substring("cd")); Assert.That(result.Message, Contains.Substring("ls")); }
protected override object OnExecute(Core.Context context, int index, object data) { return(data); }
protected override object OnExecute(Core.Context context, int index, object data) { return(context.Eval(Source)); }
protected override object OnExecute(Core.Context context, int index, object data) { context.Record(Name); return(data); }
/* * [XmlAttribute, DefaultValue(false)] * public bool Desc { get; set; } */ protected virtual object ExecuteElement(Core.Context context, Core.ElementReference element, object data) { return(data); }
protected internal override Core.JSValue EvaluateForWrite(Core.Context context) { ExceptionHelper.ThrowReferenceError(Strings.InvalidLefthandSideInAssignment); return(null); }
protected abstract object OnExecute(Core.Context context, int index, object data);
public void RemoveAlias() { var formatter = new TextOutputFormatter(); var ctx = new Core.Context(); ctx.CommandHandler = new Core.CommandHandler(ctx, formatter); ctx.CommandHandler.AddCustomCommand("c", typeof(CustomCommand)); ctx.CommandHandler.AddCommandAlias("cc", "c"); var cmd = new Mod.BindCommand(); cmd.Initialise(ctx, formatter); cmd.Remove = true; cmd.CommandName = "cc"; cmd.ProcessAsAlias = true; var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message); Assert.That(ctx.CommandHandler.CustomCommands, Contains.Item(new KeyValuePair<string, Type>("c", typeof(CustomCommand)))); var cmdArgs = ctx.CommandHandler.FindCommandAlias("cc"); Assert.That(cmdArgs, Is.Null); }
protected override object OnExecute(Core.Context context, int index, object data) { return(new Core.BreakValue(Core.BreakValue.BreakMode.Goto, ActionID)); }
protected override object ExecuteElement(Core.Context context, Core.ElementReference element, object data) { return(element.Eval(context, MethodName)); }
public override JSValue Evaluate(Core.Context context) { int itemp; long ltemp; double dtemp; var op = _left.Evaluate(context); if (op._valueType == Core.JSValueType.Integer) { itemp = op._iValue; op = _right.Evaluate(context); if (op._valueType == Core.JSValueType.Integer) { ltemp = (long)itemp + op._iValue; if ((int)ltemp == ltemp) { _tempContainer._valueType = JSValueType.Integer; _tempContainer._iValue = (int)ltemp; } else { _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = (double)ltemp; } } else if (op._valueType == Core.JSValueType.Double) { _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = itemp + op._dValue; } else { _tempContainer._valueType = JSValueType.Integer; _tempContainer._iValue = itemp; Addition.Impl(_tempContainer, _tempContainer, op); } } else if (op._valueType == Core.JSValueType.Double) { dtemp = op._dValue; op = _right.Evaluate(context); if (op._valueType == Core.JSValueType.Integer) { _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = dtemp + op._iValue; } else if (op._valueType == Core.JSValueType.Double) { _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = dtemp + op._dValue; } else { _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = dtemp; Addition.Impl(_tempContainer, _tempContainer, op); } } else { Addition.Impl(_tempContainer, op.CloneImpl(false), _right.Evaluate(context)); } return(_tempContainer); }
public virtual int GetItemCount(Core.Context context, object data = null) { return(1); }
public override JSValue Evaluate(Core.Context context) { int itemp; double dtemp; var op = _left.Evaluate(context); if (op._valueType == Core.JSValueType.Integer || op._valueType == Core.JSValueType.Boolean) { itemp = op._iValue; op = _right.Evaluate(context); if (op._valueType == Core.JSValueType.Integer || op._valueType == Core.JSValueType.Boolean) { return(itemp <= op._iValue); } else if (op._valueType == Core.JSValueType.Double) { return(itemp <= op._dValue); } else { if (_tempContainer == null) { _tempContainer = new JSValue() { _attributes = JSValueAttributesInternal.Temporary } } ; _tempContainer._valueType = JSValueType.Integer; _tempContainer._iValue = itemp; return(!More.Check(_tempContainer, op, true)); } } else if (op._valueType == Core.JSValueType.Double) { dtemp = op._dValue; op = _right.Evaluate(context); if (op._valueType == Core.JSValueType.Integer || op._valueType == Core.JSValueType.Boolean) { return(dtemp <= op._iValue); } else if (op._valueType == Core.JSValueType.Double) { return(dtemp <= op._dValue); } else { if (_tempContainer == null) { _tempContainer = new JSValue() { _attributes = JSValueAttributesInternal.Temporary } } ; _tempContainer._valueType = JSValueType.Double; _tempContainer._dValue = dtemp; return(!More.Check(_tempContainer, op, true)); } } else { if (_tempContainer == null) { _tempContainer = new JSValue() { _attributes = JSValueAttributesInternal.Temporary } } ; var temp = _tempContainer; temp.Assign(op); _tempContainer = null; var res = !More.Check(temp, _right.Evaluate(context), true); _tempContainer = temp; return(res); } }
public BrowserDocument(AppWindow owner, bool show = true, bool contextAcquired = false) : base(owner) { MainMenuStrip = new MenuStrip() { Dock = DockStyle.Top, AllowMerge = true, Visible = false, Items = { new MenuButton("&View") { MergeAction = MergeAction.MatchOnly, DropDownItems = { new MenuButton("&DevTools", null, (s, a) => { if ((s as ToolStripMenuItem).Checked) { Browser.ShowDevTools(); } else { Browser.CloseDevTools(); } }, Keys.F12) { CheckOnClick = true, MergeIndex = 0,MergeAction = MergeAction.Insert }, new ToolStripSeparator() { MergeIndex = 1, MergeAction = MergeAction.Insert }, } }, new MenuButton("&Navigate") { MergeIndex = 3, MergeAction = MergeAction.Insert, DropDownItems = { new MenuButton("&Forward", Icons.Icon_Forward, (s, a) => Browser.Forward()), new MenuButton("&Back", Icons.Icon_Back, (s, a) => Browser.Back()), new MenuButton("&Stop", Icons.Icon_Stop, (s, a) => Browser.Stop()), new ToolStripSeparator(), new MenuButton("&Refresh", Icons.Icon_Refresh, (s, a) => Browser.Reload()), } }, new MenuButton("&Execute") { MergeAction = MergeAction.MatchOnly, DropDownItems = { new MenuButton("&Play", Icons.Icon_Play, (s, a) => Context.Play(), Keys.F5) { MergeAction = MergeAction.Insert, MergeIndex = 0 }, new ToolStripSeparator() { MergeAction = MergeAction.Insert, MergeIndex = 1 }, new MenuButton("&Break", Icons.Icon_Break, (s, a) => Context.Break(), Keys.Control | Keys.Pause) { MergeAction = MergeAction.Insert, MergeIndex = 2 }, new MenuButton("&Step", Icons.Icon_Step, (s, a) => Context.Step(), Keys.F8) { MergeAction = MergeAction.Insert, MergeIndex = 3 }, new MenuButton("Sto&p", Icons.Icon_Stop, (s, a) => Context.Stop(), Keys.Shift | Keys.F5) { MergeAction = MergeAction.Insert, MergeIndex = 4 }, new ToolStripSeparator() { MergeAction = MergeAction.Insert, MergeIndex = 5 }, new ToolStripSeparator(), new MenuButton("Register &JS Fetcher", null, (s, a) => RegisterJsObject(), Keys.F9), } } }, }; AddressBar = new MenuStrip() { Dock = DockStyle.Top, AllowMerge = false, Stretch = true, LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow, ImageList = Icons.ImageList, Items = { new ToolbarButton("Back", Icons.Icon_Back, (s, a) => Browser.Back(), "navigate-backward"), new ToolbarButton("Forward", Icons.Icon_Forward, (s, a) => Browser.Forward(), "navigate-forward"), new ToolbarButton("Refresh", Icons.Icon_Refresh, (s, a) => Browser.Reload(), "navigate-refresh"), new ToolStripLabel("&Address") { TextAlign = System.Drawing.ContentAlignment.TopLeft }, (AddressBox = new ToolStripTextBox("AddressBox") { AutoSize = false }), new ToolStripButton("Go", null, (s, a) => Context.LoadUrl(AddressBox.Text)) { Alignment = ToolStripItemAlignment.Right }, } }; Browser = new ChromiumWebBrowser(new CefSharp.Web.HtmlString("<center><h1>Enter URL</h1></center>")) { Dock = DockStyle.Fill, BrowserSettings = new BrowserSettings() { FileAccessFromFileUrls = CefState.Enabled, UniversalAccessFromFileUrls = CefState.Enabled, } }; Controls.AddRange(new Control[] { Browser, MainMenuStrip, AddressBar }); AddressBox.KeyUp += (s, a) => { if (a.KeyCode != Keys.Enter) { return; } Context.LoadUrl(AddressBox.Text); }; AddressBar.Layout += (s, a) => { var width = AddressBar.Width; foreach (ToolStripItem item in AddressBar.Items) { if (item != AddressBox) { width -= item.Width - item.Margin.Horizontal; } } AddressBox.Width = Math.Max(0, width - AddressBox.Margin.Horizontal - 18); }; Browser.TitleChanged += (s, a) => this.InvokeOnUiThreadIfRequired(() => { _browserTitle = a.Title; Context_StateChanged(Context, EventArgs.Empty); }); Browser.AddressChanged += (s, a) => this.InvokeOnUiThreadIfRequired(() => AddressBox.Text = a.Address); Browser.StatusMessage += (s, a) => this.InvokeOnUiThreadIfRequired(() => OwnerWindow.Status = a.Value); Browser.LoadingStateChanged += (s, a) => { this.InvokeOnUiThreadIfRequired(() => { AddressBar.Items["navigate-refresh"].Enabled = a.CanReload; AddressBar.Items["navigate-forward"].Enabled = a.CanGoForward; AddressBar.Items["navigate-backward"].Enabled = a.CanGoBack; }); }; Context = new Core.Context(Browser, OwnerWindow.ContextManager); owner.ContextManager.AddContext(Context, contextAcquired); if (show) { Show(); } }