public static TSpec Expand(ICommandSpec src) { if ((src as TSpec)?.Expanded ?? false) { return(src as TSpec); } var args = src.Arguments; var expansion = new TSpec { CommandName = src.CommandName, Expanded = true, }; iter(args, arg => { if (ParameterIndex.ContainsKey(arg.Name)) { if ((arg.Value as string) != null) { var argExpansion = ScriptText.SpecifyEnvironmentParameters((string)arg.Value); expansion[arg.Name] = new CommandArgument(arg.Name, argExpansion); } else { expansion[arg.Name] = new CommandArgument(arg.Name, arg.Value); } } }); return(expansion); }
protected override void OnScriptText(ScriptText scriptText) { if (FlagNotSet(Flag.RemoveScriptTags)) { base.OnScriptText(scriptText); } }
private void Query() { Contract.Requires(Results != null); Contract.Ensures(Results.Any(ftr => ftr == null) == false); Results.Clear(); if (ScriptText == null || string.IsNullOrEmpty(SearchText)) { FIRE(); return; } int res = -1; int index = 0; while ((res = ScriptText.IndexOf(SearchText, res + 1, StringComparison.CurrentCultureIgnoreCase)) >= 0) { Results.Add(new FoundTextResult(index++) { StartOffset = res, EndOffset = res + SearchText.Length }); } _activeResultIndex = 0; FIRE(); }
public PlayerBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab, CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent, ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager, MeleeAttackEntity meleeAttackEntity, ProcessScrollViewPresenter processScrollViewPresenter, EventSystemWatcher eventSystemWatcher) { this.errorMsg = errorMsg; this.playerHpPresenter = playerHpPresenter; var botEntity = Object.Instantiate(botEntityPrefab); tileMapInfo.PlayerTankTransform = botEntity.transform; botEntity.gameObject.layer = LayerMask.NameToLayer("PlayerBot"); cameraFollower.SetPlayerPosition(botEntity.transform); var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>(); botEntity.transform.position = tileMapInfo.GetPlayer1StartPosition(); MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager); var gun = new Gun( soundManager, new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("PlayerBullet")), false ); botApplication = new BotApplication.BotApplication( botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun, meleeAttackApplication ); javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(botApplication); runButtonEvent.AddClickEvent(() => OnRunButtonClick(processScrollViewPresenter, scriptText)); }
internal void Parse(string unparsed) { object result; System.Runtime.InteropServices.ComTypes.EXCEPINFO exceptionInfo; ScriptText flags = ScriptText.None; if (this.isParse32) { this.parse32.ParseScriptText(unparsed, itemName: null, context: null, delimiter: null, sourceContextCookie: IntPtr.Zero, startingLineNumber: 0, flags: flags, result: out result, exceptionInfo: out exceptionInfo); } else { this.parse64.ParseScriptText(unparsed, itemName: null, context: null, delimiter: null, sourceContextCookie: IntPtr.Zero, startingLineNumber: 0, flags: flags, result: out result, exceptionInfo: out exceptionInfo); } }
public PlayGameInitData( BotEntity botEntityPrefab, BotEntity botEntityPrefab2P, CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, TileMapInfo tileMapInfo, RunButtonEvent runButtonEvent, ScriptText scriptText, BulletEntity bulletPrefab, ErrorMsg errorMsg, SoundManager soundManager, MeleeAttackEntity meleeAttackPrefab, ProcessScrollViewPresenter processScrollViewPresenter, EventSystemWatcher eventSystemWatcher) { this.botEntityPrefab = botEntityPrefab; this.botEntityPrefab2P = botEntityPrefab2P; this.cameraFollower = cameraFollower; this.playerHpPresenter = playerHpPresenter; this.tileMapInfo = tileMapInfo; this.runButtonEvent = runButtonEvent; this.scriptText = scriptText; this.bulletPrefab = bulletPrefab; this.errorMsg = errorMsg; this.soundManager = soundManager; this.meleeAttackPrefab = meleeAttackPrefab; this.processScrollViewPresenter = processScrollViewPresenter; this.eventSystemWatcher = eventSystemWatcher; }
public override void SafeAwake() { ModContext = SingleInstance <Logic> .Instance; Gas = AddSlider("Gas", "gas", 100.0f, 1.0f, MaxGas); Script = new ScriptText("script", "script"); BlockBehaviour.AddCustom(Script); // DO NOT CALL AddPIO here, because it sends invalid machine state in multiverse after simulation start machineHandler = ModContext.GetMachineHandler(BlockBehaviour); machineHandler.AddCpuBlock(this); }
protected override void OnScriptText(ScriptText scriptText) { if (scriptText == null || _scriptDepth > 0) { return; } Emit(scriptText.ToString()); base.OnScriptText(scriptText); }
internal string Text(int line) { int start = _lineStartMap[line - 1]; if (line < _lineStartMap.Length) { int length = _lineStartMap[line] - start; return(ScriptText.Substring(start, length)); } return(ScriptText.Substring(start)); }
private async void OnRunButtonClick(ProcessScrollViewPresenter processScrollViewPresenter, ScriptText scriptText) { var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; var panel = processScrollViewPresenter.AddProcessPanel(tokenSource.Cancel); var task = javaScriptEngine.ExecuteJS(scriptText.GetScriptText(), token, panel.ProcessId); await task; panel.Dispose(); }
internal HRESULT ParseScriptText( string code, string itemName, [MarshalAs(UnmanagedType.IUnknown)] object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, [MarshalAs(UnmanagedType.Struct)] out object result, out System.Runtime.InteropServices.ComTypes.EXCEPINFO exceptionInfo) { return(this.FAsp32 != null?this.FAsp32.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo) : this.FAsp64.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo)); }
/// <summary> /// Constructor /// </summary> public MainWindow() { InitializeComponent(); //new TextRange(ScriptText.Document.ContentStart, ScriptText.Document.ContentEnd).Text = ""; Data = new IntelliData(); ScriptText.KeyWordSource = Data.KeyWords; ScriptText.PredictTriggers = Data.Predict; ScriptText.KeyColour = false; KeyWordColour.IsChecked = ScriptText.KeyColour; ScriptText.Focus(); CreateParser(); DataContext = this; }
public ClientBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab, CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent, ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager, GameSignalingClient gameSignalingClient, MeleeAttackEntity meleeAttackEntity, ProcessScrollViewPresenter processScrollViewPresenter, EventSystemWatcher eventSystemWatcher) { this.errorMsg = errorMsg; this.playerHpPresenter = playerHpPresenter; var botEntity = Object.Instantiate(botEntityPrefab); tileMapInfo.PlayerTankTransform = botEntity.transform; botEntity.gameObject.layer = LayerMask.NameToLayer("PlayerBot"); cameraFollower.SetPlayerPosition(botEntity.transform); var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>(); botEntity.transform.position = tileMapInfo.GetPlayer2StartPosition(); MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager); var gun = new Gun( soundManager, new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("PlayerBullet")), false ); botApplication = new BotApplication.BotApplication( botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun, meleeAttackApplication, true ); var hookBotApplication = new ClientBotCommandsHook(botApplication, gameSignalingClient); javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(hookBotApplication); runButtonEvent.AddClickEvent(async() => { var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; var panel = processScrollViewPresenter.AddProcessPanel( () => { tokenSource.Cancel(); }); var task = javaScriptEngine.ExecuteJS(scriptText.GetScriptText(), token, panel.ProcessId); await task; panel.Dispose(); }); }
protected void OnNewButtonClick(object sender, EventArgs e) { while (ScriptTabs.Count > 1) { ScriptTabs.RemoveAt(ScriptTabs.Count - 1); } NameText.Text = ""; KeyText.Text = "C5"; BpmText.Text = "120"; VolumeText.Text = "100"; ScriptTabList.SelectedTab.ToolTipText = ScriptText.Text = ""; ScriptTabList.SelectedTab.ImageKey = VolumeText.Text = "100"; MusicList.SelectedIndex = -1; ScriptText.Select(); }
private void SetParametersInScript() { System.Text.StringBuilder sb; int first, last; first = ScriptText.IndexOf(ParameterDefinitionRegionStart); if (first < 0) { throw new ApplicationException("The script text seems to no longer contain a parameter definition start region"); } first += ParameterDefinitionRegionStart.Length; last = ScriptText.IndexOf(ParameterDefinitionRegionEnd); if (last < 0) { throw new ApplicationException("The script text seems to no longer contain a parameter definition end region"); } sb = new System.Text.StringBuilder(); sb.Append(ScriptText.Substring(0, first)); sb.Append(ParameterDefinitionRegionCore); sb.Append(DefinitionRegionIndentation); sb.Append(ScriptText.Substring(last)); ScriptText = sb.ToString(); first = ScriptText.IndexOf(ParameterAssignmentRegionStart); if (first < 0) { throw new ApplicationException("The script text seems to no longer contain a parameter assignment start region"); } first += ParameterAssignmentRegionStart.Length; last = ScriptText.IndexOf(ParameterAssignmentRegionEnd); if (last < 0) { throw new ApplicationException("The script text seems to no longer contain a parameter assignment end region"); } sb = new System.Text.StringBuilder(); sb.Append(ScriptText.Substring(0, first)); sb.Append(ParameterAssignmentRegionCore); sb.Append(AssignmentRegionIndentation); sb.Append(ScriptText.Substring(last)); ScriptText = sb.ToString(); }
protected void OnAddPartButtonClick(object sender, EventArgs e) { if (ScriptTabs.Count == 64) { ms.g("No way", "TOO MANY PARTS! THAT'D BE EAR-RAPING!"); return; } ScriptTabList.SelectedTab.ToolTipText = ScriptText.Text; ScriptTabList.SelectedTab.ImageKey = VolumeText.Text; ScriptTabs.Add($"Part {ScriptTabs.Count + 1}"); ScriptTabList.SelectedIndex = ScriptTabs.Count - 1; ScriptTabList.SelectedTab.ToolTipText = ScriptText.Text = ""; ScriptTabList.SelectedTab.ImageKey = VolumeText.Text = "100"; ScriptText.Select(); }
internal void AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, out string name, out System.Runtime.InteropServices.ComTypes.EXCEPINFO exceptionInfo) { if (this.FAsp32 != null) { this.FAsp32.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } else { this.FAsp64.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } }
public void ParseScriptText( string code, string itemName, object context, string delimiter, int sourceContextCookie, uint startingLineNumber, ScriptText flags, IntPtr result, IntPtr info) { Debug.WriteLine("ParseScriptText()"); Debug.WriteLine("code: " + code); Debug.WriteLine("itemName: " + itemName); Debug.WriteLine("delimiter: " + delimiter); Debug.WriteLine("flags: " + flags); Debug.Flush(); //result = null; // info = new System.Runtime.InteropServices.ComTypes.EXCEPINFO (); CL.Eval(CL.ReadFromString(code)); }
internal void ParseScriptText( string code, string itemName, [MarshalAs(UnmanagedType.IUnknown)] object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, [MarshalAs(UnmanagedType.Struct)] out object result, out EXCEPINFO exceptionInfo) { if (asp32 != null) { asp32.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo); } else { asp64.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo); } }
private void OnClick_LoadScript(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = ".bql"; dlg.Title = "Specify the script file"; dlg.Filter = "Building Query Language|*.bql"; dlg.FilterIndex = 0; dlg.ValidateNames = true; dlg.FileOk += delegate(object s, System.ComponentModel.CancelEventArgs eArg) { Stream file = null; string dataFormat = "Text"; try { file = dlg.OpenFile(); TextRange txtRange = new TextRange(ScriptText.Document.ContentStart, ScriptText.Document.ContentEnd); if (txtRange.CanLoad(dataFormat)) { txtRange.Load(file, dataFormat); } this.Title = "BQL Console - " + System.IO.Path.GetFileName(dlg.FileName); } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("Loading script from file failed : {0}.", ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (file != null) { file.Close(); } } }; dlg.ShowDialog(); ScriptText.RefreshKeyColour(); }
internal void AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, out string name, out EXCEPINFO exceptionInfo) { if (asp32 != null) { asp32.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } else { asp64.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } }
/// <summary> /// On Click for turning key word colour on/off /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnClick_KeyWordColour(object sender, RoutedEventArgs e) { ScriptText.KeyColour = (bool)KeyWordColour.IsChecked; ScriptText.RefreshKeyColour(); }
protected virtual void OnScriptText(ScriptText scriptText) { DefaultAction(scriptText); }
internal void ParseScriptText( string code, string itemName, [MarshalAs(UnmanagedType.IUnknown)] object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, [MarshalAs(UnmanagedType.Struct)] out object result, out EXCEPINFO exceptionInfo) { if (asp32 != null) { asp32.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo); } else { asp64.ParseScriptText(code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out exceptionInfo); } }
internal void AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptText flags, out string name, out EXCEPINFO exceptionInfo) { if (asp32 != null) { asp32.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } else { asp64.AddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out exceptionInfo); } }
public void ParseScriptText( string code, string itemName, object context, string delimiter, int sourceContextCookie, uint startingLineNumber, ScriptText flags, IntPtr result, IntPtr info) { Debug.WriteLine ("ParseScriptText()"); Debug.WriteLine ("code: " + code); Debug.WriteLine ("itemName: "+ itemName); Debug.WriteLine ("delimiter: "+delimiter); Debug.WriteLine ("flags: " + flags); Debug.Flush (); //result = null; // info = new System.Runtime.InteropServices.ComTypes.EXCEPINFO (); CL.Eval (CL.ReadFromString (code)); }
public override void Save(BinaryWriter writer, Language language) { int firstChunkOffsetsItemSize = 4 + 4 + 8; // text start + text end + string offset int secondChunkOffsetsItemSize = 8 * 4; // 4 strings // Save the file start offset as we will be writing the first chunk size once we know it long fileStartPos = writer.BaseStream.Position; writer.Write((long)0); writer.Write(Scripts.Count); writer.Write(Text.Count); long firstChunkOffsetsOffset = writer.BaseStream.Position; long firstChunkOffsetsSize = Scripts.Count * firstChunkOffsetsItemSize; writer.Write(new byte[firstChunkOffsetsSize]); for (int i = 0; i < Scripts.Count; i++) { Script script = Scripts[i]; long tempOffset = writer.BaseStream.Position; writer.BaseStream.Position = firstChunkOffsetsOffset + (i * firstChunkOffsetsItemSize); writer.Write(script.TextStartIndex); writer.Write(script.TextEndIndex); writer.WriteOffset(fileStartPos, tempOffset); writer.BaseStream.Position = tempOffset; writer.WriteNullTerminatedString(script.CodeName.GetText(language), encoding);// Is this ascii or utf-8? } // We now know the size of the first chunk. Write it to the buffer. long temp = writer.BaseStream.Position; writer.BaseStream.Position = fileStartPos; writer.Write(temp - fileStartPos); writer.BaseStream.Position = temp; long secondChunkOffsetsOffset = writer.BaseStream.Position; long secondChunkOffsetsSize = Text.Count * secondChunkOffsetsItemSize; writer.Write(new byte[secondChunkOffsetsSize]); for (int i = 0; i < Text.Count; i++) { ScriptText scriptText = Text[i]; int characterNameLen = GetStringSize(scriptText.CharacterName.GetText(language), encoding); int characterPositionLen = GetStringSize(scriptText.CharacterPosition.GetText(language), encoding); int characterExpressionLen = GetStringSize(scriptText.CharacterExpression.GetText(language), encoding); long tempOffset = writer.BaseStream.Position; writer.BaseStream.Position = secondChunkOffsetsOffset + (i * secondChunkOffsetsItemSize); writer.WriteOffset(fileStartPos, tempOffset); writer.WriteOffset(fileStartPos, tempOffset + characterNameLen); writer.WriteOffset(fileStartPos, tempOffset + characterNameLen + characterPositionLen); writer.WriteOffset(fileStartPos, tempOffset + characterNameLen + characterPositionLen + characterExpressionLen); writer.BaseStream.Position = tempOffset; writer.WriteNullTerminatedString(scriptText.CharacterName.GetText(language), encoding); writer.WriteNullTerminatedString(scriptText.CharacterPosition.GetText(language), encoding); writer.WriteNullTerminatedString(scriptText.CharacterExpression.GetText(language), encoding); writer.WriteNullTerminatedString(scriptText.Text.GetText(language), encoding); } }
public override void Load(BinaryReader reader, long length, Localized_Text.Language language) { var fileStartPos = reader.BaseStream.Position; var firstChunkSize = reader.ReadInt64(); var firstChunkItemCount = reader.ReadInt32(); var secondChunkItemCount = reader.ReadInt32(); for (var i = 0; i < firstChunkItemCount; i++) { var textStartIndex = reader.ReadInt32(); var textEndIndex = reader.ReadInt32(); var codeNameOffset = reader.ReadInt64(); var tempOffset = reader.BaseStream.Position; reader.BaseStream.Position = fileStartPos + codeNameOffset; var codeName = reader.ReadNullTerminatedString(encoding); reader.BaseStream.Position = tempOffset; Script script = null; if (Scripts.Count > i) { script = Scripts[i]; } else { Scripts.Add(script = new Script(textStartIndex, textEndIndex)); } script.CodeName.SetText(language, codeName); } reader.BaseStream.Position = fileStartPos + firstChunkSize; for (var i = 0; i < secondChunkItemCount; i++) { var characterNameOffset = reader.ReadInt64(); var characterPositionOffset = reader.ReadInt64(); var characterExpressionOffset = reader.ReadInt64(); var textOffset = reader.ReadInt64(); var tempOffset = reader.BaseStream.Position; reader.BaseStream.Position = fileStartPos + characterNameOffset; var characterName = reader.ReadNullTerminatedString(encoding); reader.BaseStream.Position = fileStartPos + characterPositionOffset; var characterPosition = reader.ReadNullTerminatedString(encoding); reader.BaseStream.Position = fileStartPos + characterExpressionOffset; var characterExpression = reader.ReadNullTerminatedString(encoding); reader.BaseStream.Position = fileStartPos + textOffset; var text = reader.ReadNullTerminatedString(encoding); reader.BaseStream.Position = tempOffset; ScriptText scriptText = null; if (Text.Count > i) { scriptText = Text[i]; } else { Text.Add(scriptText = new ScriptText()); } scriptText.CharacterName.SetText(language, characterName); scriptText.CharacterPosition.SetText(language, characterPosition); scriptText.CharacterExpression.SetText(language, characterExpression); scriptText.Text.SetText(language, text); } }
protected override void OnScriptText(ScriptText scriptText) { }
/// <inheritdoc /> protected override async Task <Result <StringStream, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { //var isAdmin = IsCurrentProcessAdmin(); //var isLinux = IsLinux; //if(isAdmin &&!isLinux) // return new SingleError("You cannot run arbitrary Nuix Scripts as Administrator", ErrorCode.ExternalProcessError, new StepErrorLocation(this)); var functionName = await FunctionName.Run(stateMonad, cancellationToken) .Map(x => x.GetStringAsync()) ; if (functionName.IsFailure) { return(functionName.ConvertFailure <StringStream>()); } var scriptText = await ScriptText.Run(stateMonad, cancellationToken) .Map(x => x.GetStringAsync()); if (scriptText.IsFailure) { return(scriptText.ConvertFailure <StringStream>()); } var parameters = await Parameters.Run(stateMonad, cancellationToken); if (parameters.IsFailure) { return(parameters.ConvertFailure <StringStream>()); } var nuixConnection = await stateMonad.GetOrCreateNuixConnection(this, false); if (nuixConnection.IsFailure) { return(nuixConnection.ConvertFailure <StringStream>() .MapError(x => x.WithLocation(this))); } var rubyFunctionParameters = parameters.Value .Select(x => new RubyFunctionParameter(ConvertString(x.Name), x.Name, true)) .ToList(); var parameterDict = parameters.Value .ToDictionary( x => new RubyFunctionParameter(ConvertString(x.Name), x.Name, true), x => x.BestValue.ObjectValue ) .Where(x => x.Value != null) .ToDictionary(x => x.Key, x => x.Value !); if (EntityStreamParameter != null) { var streamResult = await EntityStreamParameter.Run(stateMonad, cancellationToken); if (streamResult.IsFailure) { return(streamResult.ConvertFailure <StringStream>()); } const string streamParameter = "datastream"; var parameter = new RubyFunctionParameter( ConvertString(streamParameter), streamParameter, true ); rubyFunctionParameters.Add(parameter); parameterDict.Add(parameter, streamResult.Value); } var function = new RubyFunction <string>( ConvertString(functionName.Value), scriptText.Value, rubyFunctionParameters, new Version(5, 0), ArraySegment <NuixFeature> .Empty ); var runResult = await nuixConnection.Value.RunFunctionAsync( stateMonad, this, function, parameterDict, CasePathParameter.IgnoresOpenCase.Instance, cancellationToken ) .Map(x => new StringStream(x)); if (runResult.IsFailure) { return(runResult.MapError(x => x.WithLocation(this)).ConvertFailure <StringStream>()); } return(runResult.Value); }
public override int GetHashCode() { return(ScriptText.GetHashCode()); }
private object Parse(string text, bool expression) { const string varName = "x___"; object result; _engine.SetScriptState(ScriptState.Connected); ScriptText flags = ScriptText.None; if (expression) { flags |= ScriptText.IsExpression; } try { // immediate expression computation seems to work only for 64-bit // so hack something for 32-bit... System.Runtime.InteropServices.ComTypes.EXCEPINFO exceptionInfo; if (_parse32 != null) { if (expression) { // should work for jscript & vbscript at least... text = varName + "=" + text; } _parse32.ParseScriptText(text, null, IntPtr.Zero, null, 0, 0, flags, out result, out exceptionInfo); } else { _parse64.ParseScriptText(text, null, IntPtr.Zero, null, 0, 0, flags, out result, out exceptionInfo); } } catch { if (Site.LastException != null) { throw Site.LastException; } throw; } IntPtr dispatch; if (expression) { // continue our 32-bit hack... if (_parse32 != null) { _engine.GetScriptDispatch(null, out dispatch); object dp = Marshal.GetObjectForIUnknown(dispatch); try { return(dp.GetType().InvokeMember(varName, BindingFlags.GetProperty, null, dp, null)); } catch { if (Site.LastException != null) { throw Site.LastException; } throw; } } return(result); } _engine.GetScriptDispatch(null, out dispatch); ParsedScript parsed = new ParsedScript(this, dispatch); return(parsed); }
public void Parse() { SimpleHtmlParser parser = new SimpleHtmlParser(_html); OnDocumentBegin(); while (true) { Element currentElement = parser.Next(); BeginTag beginTag = currentElement as BeginTag; if (beginTag != null) { OnBeginTag(beginTag); continue; } EndTag endTag = currentElement as EndTag; if (endTag != null) { OnEndTag(endTag); continue; } ScriptLiteral literal = currentElement as ScriptLiteral; if (literal != null) { OnScriptLiteral(literal); continue; } Comment comment = currentElement as Comment; if (comment != null) { OnComment(comment); continue; } MarkupDirective markupDirective = currentElement as MarkupDirective; if (markupDirective != null) { OnMarkupDirective(markupDirective); continue; } ScriptText scriptText = currentElement as ScriptText; if (scriptText != null) { OnScriptText(scriptText); continue; } ScriptComment scriptComment = currentElement as ScriptComment; if (scriptComment != null) { OnScriptComment(scriptComment); continue; } StyleText styleText = currentElement as StyleText; if (styleText != null) { OnStyleText(styleText); continue; } StyleUrl styleUrl = currentElement as StyleUrl; if (styleUrl != null) { OnStyleUrl(styleUrl); continue; } StyleImport styleImport = currentElement as StyleImport; if (styleImport != null) { OnStyleImport(styleImport); continue; } StyleComment styleComment = currentElement as StyleComment; if (styleComment != null) { OnStyleComment(styleComment); continue; } StyleLiteral styleLiteral = currentElement as StyleLiteral; if (styleLiteral != null) { OnStyleLiteral(styleLiteral); continue; } Text text = currentElement as Text; if (text != null) { OnText(text); continue; } if (currentElement == null) { OnDocumentEnd(); return; } Debug.Fail("Unrecognized element in LightWeightHTMLDocumentIterator"); } }