Class BaseOptionModel<T>
A base class for specifying options
Inheritance
Inherited Members
Namespace: Community.VisualStudio.Toolkit
Assembly: Community.VisualStudio.Toolkit.dll
Syntax
public abstract class BaseOptionModel<T>
where T : BaseOptionModel<T>, new()
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceBaseOptionModel()
Creates a new instance of the option model.
Declaration
protected BaseOptionModel()
Properties
| Improve this Doc View SourceCollectionName
The name of the options collection as stored in the registry.
Declaration
protected virtual string CollectionName { get; }
Property Value
Type | Description |
---|---|
System.String |
Instance
A singleton instance of the options. MUST be called from UI thread only.
Declaration
public static T Instance { get; }
Property Value
Type | Description |
---|---|
T |
Remarks
Call GetLiveInstanceAsync() instead if on a background thread or in an async context on the main thread.
Methods
| Improve this Doc View SourceCreateAsync()
Creates a new instance of the options class and loads the values from the store. For internal use only
Declaration
public static Task<T> CreateAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> |
DeserializeValue(String, Type)
Deserializes a string to an object using the binary serializer.
Declaration
protected virtual object DeserializeValue(string value, Type type)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | |
System.Type | type |
Returns
Type | Description |
---|---|
System.Object |
GetLiveInstanceAsync()
Get the singleton instance of the options. Thread safe.
Declaration
public static Task<T> GetLiveInstanceAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> |
Load()
Hydrates the properties from the registry.
Declaration
public virtual void Load()
LoadAsync()
Hydrates the properties from the registry asyncronously.
Declaration
public virtual Task LoadAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Save()
Saves the properties to the registry.
Declaration
public virtual void Save()
SaveAsync()
Saves the properties to the registry asyncronously.
Declaration
public virtual Task SaveAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SerializeValue(Object)
Serializes an object value to a string using the binary serializer.
Declaration
protected virtual string SerializeValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.String |
Events
| Improve this Doc View SourceSaved
The Saved event is fired after the options have been persisted.
Declaration
public static event EventHandler<T> Saved
Event Type
Type | Description |
---|---|
System.EventHandler<T> |