SharpJSScriptControl 1.0.0

dotnet add package SharpJSScriptControl --version 1.0.0
                    
NuGet\Install-Package SharpJSScriptControl -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpJSScriptControl" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpJSScriptControl" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpJSScriptControl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpJSScriptControl --version 1.0.0
                    
#r "nuget: SharpJSScriptControl, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SharpJSScriptControl@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpJSScriptControl&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SharpJSScriptControl&version=1.0.0
                    
Install as a Cake Tool

SharpJSScriptControl

SharpJSScriptControl是一个WPF控件,用来编辑JavaScript脚本代码,同时支持

  • 在线格式化代码
  • 编译代码
  • 运行代码
  • 设置脚本中的变量、方法
  • 获取脚本中的方法、变量
  • 将你的C#方法无缝集成到JavaScript脚本中

SharpJSScriptControl is a WPF control that can be used to edit JavaScript code, and supports:

  • Code formatting in real-time
  • Compiling code
  • Running code
  • Setting variables and methods in the script
  • Retrieving methods and variables in the script
  • Integrating your C# methods seamlessly into JavaScript scripts

安装方式

install-package SharpJSScriptControl

使用方式

命名空间

xmlns:jsControl="clr-namespace:SharpJSScriptControl;assembly=SharpJSScriptControl"

声明控件

<Grid>
    <jsControl:SharpJSScriptControl x:Name="jsControl1" />
</Grid>

编译和运行 使用控件中的字段JSScriptEngine来进行编译和运行等,详情见接口IScript

namespace ScriptBase;

public interface IScript
{
    void Init(params object[] args);
    T? GetVariable<T>(string name);
    void SetVariable<T>(string name, T value);

    /// <summary>
    /// 获取所有变量,Key是变量名,Value是变量类型
    /// </summary>
    /// <returns></returns>
    Dictionary<string, string> GetVariables();
    void SetAdditionalMethods(params SMethod[] methods);
    void Run();

    void ChangeCode(string code);

    string Format(string code);
    T? Invoke<T>(string methodName, params object[] args);
    void SetScriptEnvVariable(string name, string value);
}

public class SMethod(string name, Delegate method)
{
    public string Name { get; set; } = name;
    public Delegate Method { get; set; } = method;
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 160 3/20/2025

First Update