IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
CShell.Shell Class Reference

Hosts all general utility methods to access and modify the shell. Use this static class to manage the workspace, open documents, evaluate code and manage or dump to the sinks. More...

+ Collaboration diagram for CShell.Shell:

Static Public Member Functions

static void UpdateProgress (int progress)
 Update the progress in the staus bar. More...
 
static EvaluatorResult Evaluate (string input)
 Evaluates a piece of code. More...
 
static EvaluatorResult EvaluateFile (string filePath)
 Evaluates all the code in a file. More...
 
static bool TryEvaluateFile (string filePath)
 Evaluates all the code in a file. More...
 
static IEnumerable< IDocumentGetDocuments ()
 Gets all available documents including sinks. More...
 
static IDocument GetDocument (Uri uri)
 Gets or creates specific document and opens it. More...
 
static IDocument GetDocument (Uri uri, bool suppressOpen)
 Gets or creates specific document and opens it. More...
 
static IEnumerable< ITextDocumentGetTextDocuments ()
 Gets all available text documents. More...
 
static ITextDocument GetTextDocument (string filePath)
 Gets or creates specific text document and opens it. More...
 
static bool TryOpen (string filePath)
 Tries to open a file as a document. More...
 
static void Open (string filePath)
 Opens a file as a document. More...
 
static IEnumerable< ISinkGetSinks ()
 Gets all available sinks. More...
 
static ISink GetSink (Uri uri)
 Gets a specific sink based on the URI. If the sink URI exists or can be created the sink is opened. More...
 
static ISink GetSink (Uri uri, bool suppressOpen)
 Gets a specific sink based on the uri. More...
 
static ISink GetSink (string sinkName)
 Gets the first sink with a certain title. More...
 
static void Dump (this object o, Uri sink=null)
 Dumps an object to the specified sink. More...
 
static void Dump (this object o, string description, Uri sink=null)
 Dumps an object to the specified sink. More...
 
static void DumpGrid (this IEnumerable data, string sinkName=null)
 Dumps data to a table. More...
 
static void DumpXhtml (this object o, string description=null, int depth=3, string sinkName=null)
 Dumps the object to a XHTML sink. More...
 
static ITool GetTool (Uri uri)
 Gets a specific tool based on the URI. If the tool URI exists or can be created the tool is opened. More...
 
static ITool GetTool (Uri uri, bool suppressOpen)
 Gets a specific tool based on the uri. More...
 
static void OpenWorkspace ()
 Opens a default workspace. More...
 
static Task OpenWorkspace (string cshellFile)
 Opens a workspace based on a .cshell file. More...
 
static Task CloseWorkspace ()
 Closes the current workspace. More...
 
static void UpdateProgress (int progress)
 Update the progress in the staus bar. More...
 
static EvaluatorResult Evaluate (string input)
 Evaluates a piece of code. More...
 
static EvaluatorResult EvaluateFile (string filePath)
 Evaluates all the code in a file. More...
 
static bool TryEvaluateFile (string filePath)
 Evaluates all the code in a file. More...
 
static IEnumerable< IDocumentGetDocuments ()
 Gets all available documents including sinks. More...
 
static IDocument GetDocument (Uri uri)
 Gets or creates specific document and opens it. More...
 
static IDocument GetDocument (Uri uri, bool suppressOpen)
 Gets or creates specific document and opens it. More...
 
static IEnumerable< ITextDocumentGetTextDocuments ()
 Gets all available text documents. More...
 
static ITextDocument GetTextDocument (string filePath)
 Gets or creates specific text document and opens it. More...
 
static bool TryOpen (string filePath)
 Tries to open a file as a document. More...
 
static void Open (string filePath)
 Opens a file as a document. More...
 
static IEnumerable< ISinkGetSinks ()
 Gets all available sinks. More...
 
static ISink GetSink (Uri uri)
 Gets a specific sink based on the URI. If the sink URI exists or can be created the sink is opened. More...
 
static ISink GetSink (Uri uri, bool suppressOpen)
 Gets a specific sink based on the uri. More...
 
static ISink GetSink (string sinkName)
 Gets the first sink with a certain title. More...
 
static void Dump (this object o, Uri sink=null)
 Dumps an object to the specified sink. More...
 
static void Dump (this object o, string description, Uri sink=null)
 Dumps an object to the specified sink. More...
 
static void DumpGrid (this IEnumerable data, string sinkName=null)
 Dumps data to a table. More...
 
static void DumpXhtml (this object o, string description=null, int depth=3, string sinkName=null)
 Dumps the object to a XHTML sink. More...
 
static ITool GetTool (Uri uri)
 Gets a specific tool based on the URI. If the tool URI exists or can be created the tool is opened. More...
 
static ITool GetTool (Uri uri, bool suppressOpen)
 Gets a specific tool based on the uri. More...
 
static void OpenWorkspace ()
 Opens a default workspace. More...
 
static Task OpenWorkspace (string cshellFile)
 Opens a workspace based on a .cshell file. More...
 
static Task CloseWorkspace ()
 Closes the current workspace. More...
 

Properties

static IRepl Repl [get]
 Gets the interface to modify the REPL window. More...
 
static IOutput Output [get]
 Gets the interface to modify the console output window. More...
 
static ITextDocument TextDocument [get]
 Gets the current text document. More...
 
static Uri DefaultSinkUri [get, set]
 Gets or sets the URI of the default sink. More...
 
static Workspace Workspace [get]
 Gets the instance of the currently open workspace, if no workspace is open returns null. More...
 

Static Private Member Functions

static ISink GetGridSink (string sinkName, bool suppressOpen=false)
 Gets a grid sink based on the sink name. More...
 
static IXhtmlSink GetXhtmlSink (string sinkName, bool suppressOpen=false)
 Gets a XHTML sink. More...
 
static ISink GetGridSink (string sinkName, bool suppressOpen=false)
 Gets a grid sink based on the sink name. More...
 
static IXhtmlSink GetXhtmlSink (string sinkName, bool suppressOpen=false)
 Gets a XHTML sink. More...
 

Static Private Attributes

static readonly Lazy< IShellshellLazy = new Lazy<IShell>(() => IoC.Get<IShell>(), true)
 
static readonly Lazy< IReplreplLazy = new Lazy<IRepl>(() => IoC.Get<IRepl>(), true)
 
static readonly Lazy< IOutputoutputLazy = new Lazy<IOutput>(()=>IoC.Get<IOutput>(), true)
 
static Uri defaultSinkUri = new Uri(Constants.SinkXhtml)
 
static Workspace workspace = null
 
static readonly object instanceLock = new object()
 

Detailed Description

Hosts all general utility methods to access and modify the shell. Use this static class to manage the workspace, open documents, evaluate code and manage or dump to the sinks.

Member Function Documentation

static void CShell.Shell.UpdateProgress ( int  progress)
inlinestatic

Update the progress in the staus bar.

Parameters
progressThe progress between 0 and 100.
static EvaluatorResult CShell.Shell.Evaluate ( string  input)
inlinestatic

Evaluates a piece of code.

Parameters
inputThe code to evaluate.
Returns
The results of the evaluation.

Referenced by IG.Lib.Ig.Eval().

static EvaluatorResult CShell.Shell.EvaluateFile ( string  filePath)
inlinestatic

Evaluates all the code in a file.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
The results of the evaluation.

References CShell.ScriptingEngine.Evaluate(), and CShell.Workspace.ScriptingEngine.

Referenced by CShell.Shell.TryEvaluateFile().

static bool CShell.Shell.TryEvaluateFile ( string  filePath)
inlinestatic

Evaluates all the code in a file.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
true if the evaluation succeeded, otherwise false.

References CShell.Shell.EvaluateFile(), and CShell.EvaluatorResult.HasErrors.

Referenced by IG.Lib.Ig.TryEvalFile().

static IEnumerable<IDocument> CShell.Shell.GetDocuments ( )
inlinestatic

Gets all available documents including sinks.

References CShell.Shell.shellLazy.

Referenced by CShell.Shell.GetDocument().

static IDocument CShell.Shell.GetDocument ( Uri  uri)
inlinestatic

Gets or creates specific document and opens it.

Parameters
uriThe URI of the document. Can be a file path URI.

Referenced by CShell.Framework.Results.OpenDocumentResult.Execute(), CShell.Shell.GetDocument(), CShell.Shell.GetTextDocument(), and CShell.Modules.Shell.ViewModels.ShellViewModel.LoadLayout().

static IDocument CShell.Shell.GetDocument ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets or creates specific document and opens it.

Parameters
uriThe URI of the document. Can be a file path URI.
suppressOpentrue if the document should not be opened.

References CShell.Shell.GetDocuments(), and CShell.Shell.shellLazy.

static IEnumerable<ITextDocument> CShell.Shell.GetTextDocuments ( )
inlinestatic

Gets all available text documents.

References CShell.Shell.shellLazy.

static ITextDocument CShell.Shell.GetTextDocument ( string  filePath)
inlinestatic

Gets or creates specific text document and opens it.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"

References CShell.Shell.GetDocument().

static bool CShell.Shell.TryOpen ( string  filePath)
inlinestatic

Tries to open a file as a document.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
true if the file was found, otherwise false.
static void CShell.Shell.Open ( string  filePath)
inlinestatic

Opens a file as a document.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Exceptions
ArgumentNullExceptionIf the file path is null or empty.
FileNotFoundExceptionIf the file doesn't exist.

References CShell.Framework.Results.Show.Document().

static IEnumerable<ISink> CShell.Shell.GetSinks ( )
inlinestatic

Gets all available sinks.

Returns

References CShell.Shell.shellLazy.

Referenced by CShell.Shell.GetSink().

static ISink CShell.Shell.GetSink ( Uri  uri)
inlinestatic

Gets a specific sink based on the URI. If the sink URI exists or can be created the sink is opened.

Parameters
uriThe sink URI.

Referenced by CShell.Shell.Dump(), CShell.Shell.GetGridSink(), CShell.Sinks.Plotting.GetPlotSink(), CShell.Shell.GetSink(), CShell.Shell.GetXhtmlSink(), and CShell.Modules.Shell.ViewModels.ShellViewModel.LoadLayout().

static ISink CShell.Shell.GetSink ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets a specific sink based on the uri.

Parameters
uriThe sink URI.
suppressOpenIf set to true sink will not be opened, but just created.
Returns

References CShell.Shell.GetSinks(), and CShell.Shell.shellLazy.

static ISink CShell.Shell.GetSink ( string  sinkName)
inlinestatic

Gets the first sink with a certain title.

Parameters
sinkNameName of the sink.
Returns
If the sink name cannot be found returns null.

References CShell.Shell.GetSinks().

static void CShell.Shell.Dump ( this object  o,
Uri  sink = null 
)
inlinestatic

Dumps an object to the specified sink.

Parameters
oThe object to dump.
sinkThe sink URI. If no sink URI is specified the default sink is used.

Referenced by CShell.Shell.Dump().

static void CShell.Shell.Dump ( this object  o,
string  description,
Uri  sink = null 
)
inlinestatic

Dumps an object to the specified sink.

Parameters
oThe object to dump.
descriptionA description of the object. Can be null.
sinkThe sink URI. If no sink URI is specified the default sink is used.

References CShell.Shell.DefaultSinkUri, and CShell.Shell.GetSink().

static ISink CShell.Shell.GetGridSink ( string  sinkName,
bool  suppressOpen = false 
)
inlinestaticprivate

Gets a grid sink based on the sink name.

Parameters
sinkNameName of the sink.
suppressOpenIf set to true the grid is not opened.

References CShell.Shell.GetSink(), and CShell.Constants.SinkGrid.

Referenced by CShell.Shell.DumpGrid().

static void CShell.Shell.DumpGrid ( this IEnumerable  data,
string  sinkName = null 
)
inlinestatic

Dumps data to a table.

Parameters
dataThe data.
sinkNameName of the sink.

References CShell.Shell.GetGridSink().

static IXhtmlSink CShell.Shell.GetXhtmlSink ( string  sinkName,
bool  suppressOpen = false 
)
inlinestaticprivate

Gets a XHTML sink.

Parameters
sinkNameName of the sink.
suppressOpenIf set to true the sink is not opened.
Returns

References CShell.Shell.GetSink(), and CShell.Constants.SinkXhtml.

Referenced by CShell.Shell.DumpXhtml().

static void CShell.Shell.DumpXhtml ( this object  o,
string  description = null,
int  depth = 3,
string  sinkName = null 
)
inlinestatic

Dumps the object to a XHTML sink.

Parameters
oThe object to dump.
descriptionA description of the object.
depthIf it's a nested type how many sub-types should be printed.
sinkNameName of the sink.

References CShell.Shell.GetXhtmlSink().

static ITool CShell.Shell.GetTool ( Uri  uri)
inlinestatic

Gets a specific tool based on the URI. If the tool URI exists or can be created the tool is opened.

Parameters
uriThe tool URI.

Referenced by CShell.Shell.GetTool(), and CShell.Modules.Shell.ViewModels.ShellViewModel.LoadLayout().

static ITool CShell.Shell.GetTool ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets a specific tool based on the uri.

Parameters
uriThe tool URI.
suppressOpenIf set to true tool will not be opened, but just created.
Returns

References CShell.Shell.shellLazy.

static void CShell.Shell.OpenWorkspace ( )
inlinestatic
static Task CShell.Shell.OpenWorkspace ( string  cshellFile)
inlinestatic

Opens a workspace based on a .cshell file.

Parameters
cshellFileThe file path to the .cshell file.
Returns
A task that completes once the workspace is opened.

References CShell.Shell.Workspace.

static Task CShell.Shell.CloseWorkspace ( )
inlinestatic

Closes the current workspace.

Returns
A task that completes once the workspace is closed.

Referenced by CShell.Framework.Results.CloseWorkspaceResult.Execute().

static void CShell.Shell.UpdateProgress ( int  progress)
inlinestatic

Update the progress in the staus bar.

Parameters
progressThe progress between 0 and 100.
static EvaluatorResult CShell.Shell.Evaluate ( string  input)
inlinestatic

Evaluates a piece of code.

Parameters
inputThe code to evaluate.
Returns
The results of the evaluation.
static EvaluatorResult CShell.Shell.EvaluateFile ( string  filePath)
inlinestatic

Evaluates all the code in a file.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
The results of the evaluation.

References CShell.ScriptingEngine.Evaluate(), and CShell.Workspace.ScriptingEngine.

static bool CShell.Shell.TryEvaluateFile ( string  filePath)
inlinestatic

Evaluates all the code in a file.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
true if the evaluation succeeded, otherwise false.

References CShell.Shell.EvaluateFile(), and CShell.EvaluatorResult.HasErrors.

static IEnumerable<IDocument> CShell.Shell.GetDocuments ( )
inlinestatic

Gets all available documents including sinks.

References CShell.Shell.shellLazy.

static IDocument CShell.Shell.GetDocument ( Uri  uri)
inlinestatic

Gets or creates specific document and opens it.

Parameters
uriThe URI of the document. Can be a file path URI.

References CShell.Shell.GetDocument().

static IDocument CShell.Shell.GetDocument ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets or creates specific document and opens it.

Parameters
uriThe URI of the document. Can be a file path URI.
suppressOpentrue if the document should not be opened.

References CShell.Shell.GetDocuments(), and CShell.Shell.shellLazy.

static IEnumerable<ITextDocument> CShell.Shell.GetTextDocuments ( )
inlinestatic

Gets all available text documents.

References CShell.Shell.shellLazy.

static ITextDocument CShell.Shell.GetTextDocument ( string  filePath)
inlinestatic

Gets or creates specific text document and opens it.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"

References CShell.Shell.GetDocument().

static bool CShell.Shell.TryOpen ( string  filePath)
inlinestatic

Tries to open a file as a document.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Returns
true if the file was found, otherwise false.
static void CShell.Shell.Open ( string  filePath)
inlinestatic

Opens a file as a document.

Parameters
filePathThe path to the file. Can be relative to the root path of the workspace, e.g. "subfolder/file.csx"
Exceptions
ArgumentNullExceptionIf the file path is null or empty.
FileNotFoundExceptionIf the file doesn't exist.

References CShell.Framework.Results.Show.Document().

static IEnumerable<ISink> CShell.Shell.GetSinks ( )
inlinestatic

Gets all available sinks.

Returns

References CShell.Shell.shellLazy.

static ISink CShell.Shell.GetSink ( Uri  uri)
inlinestatic

Gets a specific sink based on the URI. If the sink URI exists or can be created the sink is opened.

Parameters
uriThe sink URI.

References CShell.Shell.GetSink().

static ISink CShell.Shell.GetSink ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets a specific sink based on the uri.

Parameters
uriThe sink URI.
suppressOpenIf set to true sink will not be opened, but just created.
Returns

References CShell.Shell.GetSinks(), and CShell.Shell.shellLazy.

static ISink CShell.Shell.GetSink ( string  sinkName)
inlinestatic

Gets the first sink with a certain title.

Parameters
sinkNameName of the sink.
Returns
If the sink name cannot be found returns null.

References CShell.Shell.GetSinks().

static void CShell.Shell.Dump ( this object  o,
Uri  sink = null 
)
inlinestatic

Dumps an object to the specified sink.

Parameters
oThe object to dump.
sinkThe sink URI. If no sink URI is specified the default sink is used.

References CShell.Shell.Dump().

static void CShell.Shell.Dump ( this object  o,
string  description,
Uri  sink = null 
)
inlinestatic

Dumps an object to the specified sink.

Parameters
oThe object to dump.
descriptionA description of the object. Can be null.
sinkThe sink URI. If no sink URI is specified the default sink is used.

References CShell.Shell.DefaultSinkUri, and CShell.Shell.GetSink().

static ISink CShell.Shell.GetGridSink ( string  sinkName,
bool  suppressOpen = false 
)
inlinestaticprivate

Gets a grid sink based on the sink name.

Parameters
sinkNameName of the sink.
suppressOpenIf set to true the grid is not opened.

References CShell.Shell.GetSink(), and CShell.Constants.SinkGrid.

static void CShell.Shell.DumpGrid ( this IEnumerable  data,
string  sinkName = null 
)
inlinestatic

Dumps data to a table.

Parameters
dataThe data.
sinkNameName of the sink.

References CShell.Shell.GetGridSink().

static IXhtmlSink CShell.Shell.GetXhtmlSink ( string  sinkName,
bool  suppressOpen = false 
)
inlinestaticprivate

Gets a XHTML sink.

Parameters
sinkNameName of the sink.
suppressOpenIf set to true the sink is not opened.
Returns

References CShell.Shell.GetSink(), and CShell.Constants.SinkXhtml.

static void CShell.Shell.DumpXhtml ( this object  o,
string  description = null,
int  depth = 3,
string  sinkName = null 
)
inlinestatic

Dumps the object to a XHTML sink.

Parameters
oThe object to dump.
descriptionA description of the object.
depthIf it's a nested type how many sub-types should be printed.
sinkNameName of the sink.

References CShell.Shell.GetXhtmlSink().

static ITool CShell.Shell.GetTool ( Uri  uri)
inlinestatic

Gets a specific tool based on the URI. If the tool URI exists or can be created the tool is opened.

Parameters
uriThe tool URI.

References CShell.Shell.GetTool().

static ITool CShell.Shell.GetTool ( Uri  uri,
bool  suppressOpen 
)
inlinestatic

Gets a specific tool based on the uri.

Parameters
uriThe tool URI.
suppressOpenIf set to true tool will not be opened, but just created.
Returns

References CShell.Shell.shellLazy.

static void CShell.Shell.OpenWorkspace ( )
inlinestatic

Opens a default workspace.

References CShell.Constants.CShellDefaultFilePath, and CShell.Shell.OpenWorkspace().

static Task CShell.Shell.OpenWorkspace ( string  cshellFile)
inlinestatic

Opens a workspace based on a .cshell file.

Parameters
cshellFileThe file path to the .cshell file.
Returns
A task that completes once the workspace is opened.

References CShell.Shell.Workspace.

static Task CShell.Shell.CloseWorkspace ( )
inlinestatic

Closes the current workspace.

Returns
A task that completes once the workspace is closed.

Member Data Documentation

static readonly Lazy< IShell > CShell.Shell.shellLazy = new Lazy<IShell>(() => IoC.Get<IShell>(), true)
staticprivate
static readonly Lazy< IRepl > CShell.Shell.replLazy = new Lazy<IRepl>(() => IoC.Get<IRepl>(), true)
staticprivate
static readonly Lazy< IOutput > CShell.Shell.outputLazy = new Lazy<IOutput>(()=>IoC.Get<IOutput>(), true)
staticprivate
static Uri CShell.Shell.defaultSinkUri = new Uri(Constants.SinkXhtml)
staticprivate
static Workspace CShell.Shell.workspace = null
staticprivate
static readonly object CShell.Shell.instanceLock = new object()
staticprivate

Property Documentation

static IRepl CShell.Shell.Repl
staticget

Gets the interface to modify the REPL window.

Referenced by IG.Lib.Ig.Clear().

static IOutput CShell.Shell.Output
staticget

Gets the interface to modify the console output window.

static ITextDocument CShell.Shell.TextDocument
staticget

Gets the current text document.

static Uri CShell.Shell.DefaultSinkUri
staticgetset

Gets or sets the URI of the default sink.

Referenced by CShell.Shell.Dump().


The documentation for this class was generated from the following files: