Daniel's XL Toolbox NG
XLToolbox.WorkbookStorage.Store Class Reference

Stores stuff (strings, ints, objects) in a very hidden worksheet of a workbook, and retrieves stuff from it. The store supports 'namespaces' where a worksheet can be used as a 'context', i.e. namespace. Empty context constitutes a global namespace. Uses a cache that is automatically written to the worksheet when finalizing. More...

Inheritance diagram for XLToolbox.WorkbookStorage.Store:
Collaboration diagram for XLToolbox.WorkbookStorage.Store:

Public Member Functions

 Store ()
 Instantiates the class and associates it with the active workbook of the Excel instance that is currently associated with the add-in. More...
 
 Store (Workbook workbook)
 Instantiates the class and associates it with a workbook. More...
 
 Store (bool activeSheetContext)
 Creates a new Store instance with the active sheet as current context. More...
 
void Dispose ()
 
int Get (string key, int def, int min, int max)
 Retrieves an integer from the storage, given a key. More...
 
string Get (string key, string def)
 
bool Get (string key, bool def)
 
Get< T > (string key)
 Deserializes a stored object. Returns null upon failure. More...
 
void Put (string key, int i)
 
void Put (string key, string s)
 
void Put (string key, bool b)
 
void Put< T > (string key, T obj)
 
void UseActiveSheet ()
 Sets the active sheet of the current workbook as the context. More...
 
bool HasKey (string key)
 Determines if the current context has a stored item with given key. More...
 
void Flush ()
 Writes out the values to the hidden worksheet, if values were changed. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 
void PutObject (string key, object o)
 Central method to put objects into the store. More...
 
dynamic GetDynamicValue (string key)
 
void ReadFromWorksheet ()
 Reads all settings from the hidden storage worksheet More...
 
void WriteToWorksheet ()
 Writes all settings to the hidden storage worksheet. More...
 

Properties

Workbook Workbook [get, set]
 Gets or sets the associated workbook. If a new workbook is set, writes the values to the old workbook, then reads the values from the new workbook. More...
 
string Context [get, set]
 Sets the context of the current storage object. This may be a worksheet name or an empty string for the global context of the workbook. More...
 
Worksheet StoreSheet [get]
 
bool Dirty [get, set]
 

Detailed Description

Stores stuff (strings, ints, objects) in a very hidden worksheet of a workbook, and retrieves stuff from it. The store supports 'namespaces' where a worksheet can be used as a 'context', i.e. namespace. Empty context constitutes a global namespace. Uses a cache that is automatically written to the worksheet when finalizing.

Constructor & Destructor Documentation

◆ Store() [1/3]

XLToolbox.WorkbookStorage.Store.Store ( )
inline

Instantiates the class and associates it with the active workbook of the Excel instance that is currently associated with the add-in.

Exceptions
NoExcelInstanceExceptionIf no Excel instance is running (see ExcelInstance).

◆ Store() [2/3]

XLToolbox.WorkbookStorage.Store.Store ( Workbook  workbook)
inline

Instantiates the class and associates it with a workbook.

Parameters
workbookWorkbook object to associate the storage with.

◆ Store() [3/3]

XLToolbox.WorkbookStorage.Store.Store ( bool  activeSheetContext)
inline

Creates a new Store instance with the active sheet as current context.

Parameters
activeSheetContextTrue if the active sheet is the desired context.

Member Function Documentation

◆ Dispose() [1/2]

void XLToolbox.WorkbookStorage.Store.Dispose ( )
inline

◆ Dispose() [2/2]

virtual void XLToolbox.WorkbookStorage.Store.Dispose ( bool  disposing)
inlineprotectedvirtual

◆ Flush()

void XLToolbox.WorkbookStorage.Store.Flush ( )
inline

Writes out the values to the hidden worksheet, if values were changed.

◆ Get() [1/3]

int XLToolbox.WorkbookStorage.Store.Get ( string  key,
int  def,
int  min,
int  max 
)
inline

Retrieves an integer from the storage, given a key.

Parameters
keyKey to look up.
Returns
Integer value

◆ Get() [2/3]

string XLToolbox.WorkbookStorage.Store.Get ( string  key,
string  def 
)
inline

◆ Get() [3/3]

bool XLToolbox.WorkbookStorage.Store.Get ( string  key,
bool  def 
)
inline

◆ Get< T >()

T XLToolbox.WorkbookStorage.Store.Get< T > ( string  key)
inline

Deserializes a stored object. Returns null upon failure.

Template Parameters
TType name of the object to be deserialized.
Parameters
keyKey that this object is stored under.
Returns
Deserialized object of type T, or null.
Type Constraints
T :class 
T :new() 

◆ GetDynamicValue()

dynamic XLToolbox.WorkbookStorage.Store.GetDynamicValue ( string  key)
inlineprotected

◆ HasKey()

bool XLToolbox.WorkbookStorage.Store.HasKey ( string  key)
inline

Determines if the current context has a stored item with given key.

Parameters
keyKey to look up.
Returns
True if key exists in current context, false if not.

◆ Put() [1/3]

void XLToolbox.WorkbookStorage.Store.Put ( string  key,
int  i 
)
inline

◆ Put() [2/3]

void XLToolbox.WorkbookStorage.Store.Put ( string  key,
string  s 
)
inline

◆ Put() [3/3]

void XLToolbox.WorkbookStorage.Store.Put ( string  key,
bool  b 
)
inline

◆ Put< T >()

void XLToolbox.WorkbookStorage.Store.Put< T > ( string  key,
obj 
)
inline
Type Constraints
T :class 
T :new() 

◆ PutObject()

void XLToolbox.WorkbookStorage.Store.PutObject ( string  key,
object  o 
)
inlineprotected

Central method to put objects into the store.

Parameters
keyKey to store the object under.
oObject to store.

◆ ReadFromWorksheet()

void XLToolbox.WorkbookStorage.Store.ReadFromWorksheet ( )
inlineprotected

Reads all settings from the hidden storage worksheet

◆ UseActiveSheet()

void XLToolbox.WorkbookStorage.Store.UseActiveSheet ( )
inline

Sets the active sheet of the current workbook as the context.

◆ WriteToWorksheet()

void XLToolbox.WorkbookStorage.Store.WriteToWorksheet ( )
inlineprotected

Writes all settings to the hidden storage worksheet.

Property Documentation

◆ Context

string XLToolbox.WorkbookStorage.Store.Context
getset

Sets the context of the current storage object. This may be a worksheet name or an empty string for the global context of the workbook.

◆ Dirty

bool XLToolbox.WorkbookStorage.Store.Dirty
getsetprotected

◆ StoreSheet

Worksheet XLToolbox.WorkbookStorage.Store.StoreSheet
getprotected

◆ Workbook

Workbook XLToolbox.WorkbookStorage.Store.Workbook
getset

Gets or sets the associated workbook. If a new workbook is set, writes the values to the old workbook, then reads the values from the new workbook.


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