List of Files And Directories.
The GetFilesAndDirList allow to retrieve a list of files and directories provided a path of a directory in question. The default directory is the root.
The GetFileFromServer it will allow you to receive the binary of the file that you indicate in the path.
C# Execute dynamic code.
From the CSharpTools library, import a Server Action called CSharpExecute.
Note: The CSharpExecuteAsync has the same parameters.
Example 1:
In ImportNamespaces put empty string "";
In the CSharpCodeExtension add the following:
" public long fac(long n) {
if (n <= 1) return 1;
else return n*fac(n-1);
}";
In the CSharpCode add the following:
" return fac(12); ".
If you execute the result will be from recursive function fac 479001600.
Example 2:
" public float fac(float n) {
" return fac(45); ".
If you execute the result will be from recursive function fac INF.
Example 3:
In this example, let's assume you want to use a third-party library in .NET Framework 4. The code for this library is as follows:
And this DLL is available for download, in this case, on Google Drive with access for anyone.
In ImportNamespaces add the following:
"
using System;
using System.Net;
using System.Reflection;
In the CSharpCodeExtension put an empty string "";
//1JPzl4dKT_US_6wgaDZ3DGL6dLGKp61cr : This is the Id of the DLL file in the google drive
string downloadLink = "https://drive.usercontent.google.com/download?id=1JPzl4dKT_US_6wgaDZ3DGL6dLGKp61cr";
byte[] assemblyBytes = new WebClient().DownloadData(downloadLink);
Assembly loadedAssembly = Assembly.Load(assemblyBytes);
Type easyMathType = loadedAssembly.GetType("TestClassLibrary.EasyMath");
dynamic easyMathInstance = Activator.CreateInstance(easyMathType);
return easyMathInstance.fact(65); // replace fact with factfloat; factdecimal; factdouble
".
Note: In this example we are downloading a DLL from a Google Drive link and loading it as an assembly into memory, enabling the execution or dynamic manipulation of the code contained in the file.
Disclaimer:
The code is executed on the server side, using Reflection methods provided by Microsoft in the .NET Framework. For this reason, the code created is the entire responsibility of the developer who wrote it. The developer should be responsible and prevent code injection as well as the misuse of the code they have developed.
This does not replace Integration Studio; it simply allows for the interpretation and execution of code in a text. Keep in mind that interpreted code is generally slower than compiled code.