Skip to content

Context window

tomdam edited this page Jun 17, 2020 · 1 revision

Context window is a feature of SPCoder which serves as a link between objects in Explorer view and Roslyn C# engine. By adding a .net object to the Context window, you also add it to Roslyn C# engine and you can use it in your code.

Context window

By default the window is located at the bottom of the main screen.

Context 1

Usage

Every SPCoder connector adds one or more objects to the context after successful connection to the data source is established. For example, after you connect to SharePoint online site, 3 objects will be added to SPCoder Context:

  • context - ClientContext object, which can be used from the code to make additional calls to SharePoint API
  • web - Web object, that represents the root web site
  • site - Site object, that represent the site collection

You can add new objects to context by dragging them from the Explorer window's tree view and dropping to the Context window.

After adding the object to Context, you can use it in code:

Context 2

Important note: You can regularly declare variables and use them in your code without the need to add them to Context window.

String s = "Roslyn";

//you can now use the variable s but it won't show up in Context window.
String x = s.ToLower();
...

Settings

There are 4 options available for every context item:

  • Describe - Opens the Describer window and displays the properties of the selected object
  • Properties - Opens the Properties window and displays the properties of the selected object
  • Delete - Deletes the selected object from context
  • Rename - Renames the selected object's variable name.

Context 3