SettingsFile

References
public sealed class SettingsFile
A class for caching settings which are stored in a file.

Constructors

SettingsFile

#
Create a new settings file which mirrors a file on the disk.
public SettingsFile(
file
)

Fields

Extension

#
Gets the file extension under which grasshopper settings files are stored.
public const string Extension = ".ghs"

Properties

File

#
Gets the file path this settings file points to. The file may or may not exist.
public string File { get; }

Node

#
Gets the underlying node which stores the values. Careful when using this object directly, you may for example not overwrite existing values, you must delete them first. Also, changes made directly to the node will not cause a settings file update.
public Node Node { get; }

Methods

Clear

#
Clear all settings.
public void Clear()

Get

#
Retrieve a bool from the cached settings.
public bool Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a boolean.
)
Boolean value of setting or the default if the setting isn't known.

Get

#
Retrieve a colour from the cached settings.
public Color Get(
name,
Name of setting to retrieve.
Color
default
Default value in case name isn't available, or doesn't represent a colour.
)
Id value of setting or the default if the setting isn't known.

Get

#
Retrieve a date from the cached settings.
public DateTime Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a date.
)
Id value of setting or the default if the setting isn't known.

Get

#
Retrieve a number from the cached settings.
public double Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a number.
)
Numeric value of setting or the default if the setting isn't known.

Get

#
Retrieve a number from the cached settings.
public float Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a number.
)
Numeric value of setting or the default if the setting isn't known.

Get

#
Retrieve a GUID from the cached settings.
public Guid Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a guid.
)
Id value of setting or the default if the setting isn't known.

Get

#
Retrieve an integer from the cached settings.
public int Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent an integer.
)
Integer value of setting or the default if the setting isn't known.

Get

#
Retrieve a colour from the cached settings.
public IStorable Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a colour.
)
Id value of setting or the default if the setting isn't known.

Get

#
Retrieve a point from the cached settings.
public PointF Get(
name,
Name of setting to retrieve.
PointF
default
Default value in case name isn't available, or doesn't represent a point.
)
Point value of setting or the default if the setting isn't known.

Get

#
Retrieve a rectangle from the cached settings.
public RectangleF Get(
name,
Name of setting to retrieve.
RectangleF
default
Default value in case name isn't available, or doesn't represent a rectangle.
)
Rectangle value of setting or the default if the setting isn't known.

Get

#
Retrieve a size from the cached settings.
public SizeF Get(
name,
Name of setting to retrieve.
SizeF
default
Default value in case name isn't available, or doesn't represent a size.
)
Point value of setting or the default if the setting isn't known.

Get

#
Retrieve a string from the cached settings.
public string Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available.
)
String value of setting or the default if the setting isn't known.

Get

#
Retrieve a time span from the cached settings.
public TimeSpan Get(
name,
Name of setting to retrieve.
default
Default value in case name isn't available, or doesn't represent a time span.
)
Id value of setting or the default if the setting isn't known.

InDefaultFolder

#
Create or load a settings file by name in the default Grasshopper 2.0 settings folder.
public static SettingsFile InDefaultFolder(
name
Name of settings to load.
)
Settings file.

Rename

#
Attempt to rename a setting. If another setting with the newName already exists, it will be removed, even if the oldName does not point to an existing setting.
public bool Rename(
oldName,
Old name of setting.
newName
New name of setting.
)
True if setting was renamed, or if conflicting setting was removed.

Set

#
Store a boolean in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a color in the cached settings.
public void Set(
name,
Name of setting to store.
Color
value
Value to store.
)

Set

#
Store a date in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a number in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a number in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a guid in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store an integer in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store an IStorable object in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a point in the cached settings.
public void Set(
name,
Name of setting to store.
PointF
value
Value to store.
)

Set

#
Store a rectangle in the cached settings.
public void Set(
name,
Name of setting to store.
RectangleF
value
Value to store.
)

Set

#
Store a size in the cached settings.
public void Set(
name,
Name of setting to store.
SizeF
value
Value to store.
)

Set

#
Store a string in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

Set

#
Store a time span in the cached settings.
public void Set(
name,
Name of setting to store.
value
Value to store.
)

TryLoadSettingsFromFile

#
Load the settings form the file. This happens automatically on construction, so you only need to call this method if you have reason to believe the settings file was modified by a process other than this SettingsFile.
public bool TryLoadSettingsFromFile()

TrySaveSettingsToFile

#
Write the current state of this SettingsFile to the file on the disk.
public bool TrySaveSettingsToFile()