C# Class clojure.lang.Hosting.Clojure

Convenience class for interfacing with Clojure from other .NET languages. Provides an extremely simple way to retreive Clojure vars and invoke Clojure functions.
Mostra file Open project: aaronc/clojure-clr

Public Methods

Method Description
AddNamespaceLoadMapping ( string namespaceBase, string directory ) : void

Allows a namespace to be loaded from a directory whose path corresponds to only part of the namespace name. This can be used to load .clj files properly from the repl that are being stored as embedded resources in mixed language .NET DLL's (for example existing C# and Visual Basic projects).

Adding a load mapping from "MyCompany.MyProject" to "MyProject" allows the namespace "A.B.C" to be stored in "MyProject/C.clj" on the file system. Assuming the default namespace (configurable in a Visual Studio project's properties) is "MyCompany.MyProject", "C.clj" can be stored as an embedded resource in "MyProject.dll" and still loaded properly by the Clojure namespace loader. This is because embedded resources receive a virtual filename in a DLL based on both the DLL's default namespace and the file's actual path relative to the project. In order for the namespace to be loaded from the repl, a load mapping must be created. AddNamespaceLoadMapping("MyCompany.MyProject", "MySolutionDir/MyProject");

AddToLoadPath ( string path ) : void

Adds a path to the CLOJURE_LOAD_PATH environment variable used to load Clojure files from the disk.

GetVar ( string nsname, string varName ) : Var

Returns the Var object refered to in the namespace called nsname with the name varName.

Require ( string nsname ) : void

Calls (require nsname) on the namespace name provided by nsname.

Method Details

AddNamespaceLoadMapping() public static method

Allows a namespace to be loaded from a directory whose path corresponds to only part of the namespace name. This can be used to load .clj files properly from the repl that are being stored as embedded resources in mixed language .NET DLL's (for example existing C# and Visual Basic projects).
Adding a load mapping from "MyCompany.MyProject" to "MyProject" allows the namespace "A.B.C" to be stored in "MyProject/C.clj" on the file system. Assuming the default namespace (configurable in a Visual Studio project's properties) is "MyCompany.MyProject", "C.clj" can be stored as an embedded resource in "MyProject.dll" and still loaded properly by the Clojure namespace loader. This is because embedded resources receive a virtual filename in a DLL based on both the DLL's default namespace and the file's actual path relative to the project. In order for the namespace to be loaded from the repl, a load mapping must be created. AddNamespaceLoadMapping("MyCompany.MyProject", "MySolutionDir/MyProject");
public static AddNamespaceLoadMapping ( string namespaceBase, string directory ) : void
namespaceBase string
directory string
return void

AddToLoadPath() public static method

Adds a path to the CLOJURE_LOAD_PATH environment variable used to load Clojure files from the disk.
public static AddToLoadPath ( string path ) : void
path string The path to add to CLOJURE_LOAD_PATH. Use ; to separate multiple paths.
return void

GetVar() public static method

Returns the Var object refered to in the namespace called nsname with the name varName.
public static GetVar ( string nsname, string varName ) : Var
nsname string The namespace name
varName string The name of the Var
return Var

Require() public static method

Calls (require nsname) on the namespace name provided by nsname.
public static Require ( string nsname ) : void
nsname string The name of the namespace to require, ex.: /// clojure.string
return void