Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Action with LinqPad Hyperlinq()

Tags:

c#

vb.net

linqpad

If I execute this VB expression:

New Hyperlinq("c:\temp\test.py").Dump()

as a result I get clickable link which opens the file with default application i.e. it runs this Python file.

I wanted to instruct LinqPad to custom Sub that will take care of click Event.
Hyperlinq Class contains Action parameter, but I can't find example how to use this method:

public Hyperlinq(string uriOrPath);
public Hyperlinq(QueryLanguage queryLanguage, string query);
public Hyperlinq(Action action, string text);
public Hyperlinq(string uriOrPath, string text);
public Hyperlinq(QueryLanguage queryLanguage, string query, string text);
public Hyperlinq(Action action, string text, bool runOnNewThread);
internal Hyperlinq(int editorRow, int editorColumn, string text);
public override bool Equals(object obj);
public override int GetHashCode();
internal int RegisterAction();

Can anyone provide an example?
For example I want to open the file with Notepad when I click on the link in the result pane.

like image 263
theta Avatar asked Jan 10 '23 20:01

theta


2 Answers

dim h = New Hyperlinq(Function() "foo".Dump, "Click me")
h.Dump
like image 117
Joe Albahari Avatar answered Jan 14 '23 22:01

Joe Albahari


Here's the C# way to do the same thing as above

var h = new Hyperlinq(()=> {"foo".Dump();}, "Click me");
h.Dump();
like image 30
BraveNewMath Avatar answered Jan 14 '23 22:01

BraveNewMath