Class SettingsCollection
public class SettingsCollection : IEnumerable<Page>, IEnumerable
Inheritance
Inherited Members
Namespace: HomeSeer.Jui.Views
Assembly: PluginSdk.dll
A collection of JUI settings pages.
Remarks
This is the primary container for settings pages used by plugins. It is integrated into the AbstractPlugin class and automatically initialized to an empty collection.
Constructors
View SourceSettingsCollection()
Default, empty constructor
Declaration
public SettingsCollection()
SettingsCollection(List<Page>)
Create a new SettingsCollection with the given list of pages
Declaration
[JsonConstructor]
public SettingsCollection(List<Page> pages)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Page> | pages | The list of pages for the collection |
See Also
Fields
View Source_hiddenPages
Declaration
[JsonIgnore]
Dictionary<string, Page> _hiddenPages
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, Page> |
_pageOrder
Declaration
[JsonIgnore]
List<string> _pageOrder
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
_pages
Declaration
[JsonIgnore]
Dictionary<string, Page> _pages
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, Page> |
Properties
View SourceAllPages
The list of all of the pages in the collection, including hidden ones.
Declaration
[JsonIgnore]
public List<Page> AllPages { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Page> |
Count
The number of pages in this collection
Declaration
[JsonIgnore]
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[String]
Get the page with the specified ID
Declaration
public Page this[string pageId] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the desired page |
Property Value
Type | Description |
---|---|
Page |
See Also
View SourcePages
The list of pages in this collection, excluding hidden pages.
Declaration
[JsonProperty("pages")]
public List<Page> Pages { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Page> |
See Also
View SourceSelectedPageIndex
The index of the page that is selected and will be shown first to users
Declaration
[JsonProperty("selected_page")]
public int SelectedPageIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
View SourceAdd(Page)
Add a page to the collection
Declaration
public void Add(Page page)
Parameters
Type | Name | Description |
---|---|---|
Page | page | The page to add. Should be a page of type Settings |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The supplied page or its ID is null |
System.ArgumentException | Thrown if a page with the same ID already exists in the collection |
See Also
View SourceContainsPageId(String)
Determine if the collection contains a page with the specified ID
Declaration
public bool ContainsPageId(string pageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the page to look for |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the collection contains the page, FALSE if the page was not found |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when pageId is null or whitespace |
FromJsonString(String)
Deserialize a JSON string to a settings collection
This should always be wrapped in a try/catch in case the data received is malformed
Declaration
public static SettingsCollection FromJsonString(string jsonString)
Parameters
Type | Name | Description |
---|---|---|
System.String | jsonString | The JSON string containing the settings collection |
Returns
Type | Description |
---|---|
SettingsCollection | A SettingsCollection |
Exceptions
Type | Condition |
---|---|
JsonDataException | Thrown when there was a problem deserializing the settings collection |
GetEnumerator()
Declaration
public IEnumerator<Page> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<Page> |
HidePageById(String)
Mark the page with the specified ID as hidden when the collection is converted to HTML so that it is not included.
Declaration
public void HidePageById(string pageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the page to hide |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when an invalid page ID is specified |
System.Collections.Generic.KeyNotFoundException | Thrown when a page with the specified ID doesn't exist |
IndexOf(String)
Get the index of the page with the specified ID
Declaration
public int IndexOf(string pageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the page to look for |
Returns
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when pageId is null or whitespace |
System.Collections.Generic.KeyNotFoundException | Thrown when the pageId was not found in the collection |
RemoveAll()
Remove all pages from the collection
Declaration
public void RemoveAll()
RemoveById(String)
Remove the page with the specified ID from the collection
Declaration
public void RemoveById(string pageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the page to remove |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when pageId is null or whitespace |
System.Collections.Generic.KeyNotFoundException | Thrown when the pageId was not found in the collection |
ShowPageById(String)
Mark the page with the specified ID as shown when the collection is converted to HTML so that it is included.
Declaration
public void ShowPageById(string pageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageId | The ID of the page to show |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when an invalid page ID is specified |
System.Collections.Generic.KeyNotFoundException | Thrown when a page with the specified ID doesn't exist |
Swap(Int32, Int32)
Swap the pages at the specified indexes
Declaration
public void Swap(int index1, int index2)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index1 | The index of the first page |
System.Int32 | index2 | The index of the second page |
Remarks
When this method finishes, the page at index1 will be located at index2, and the page at index2 will be located at index1.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if either index is out of range of the collection |
ToHtml()
Convert the settings collection into a tabbed HTML page.
Declaration
public string ToHtml()
Returns
Type | Description |
---|---|
System.String | A string containing a tabbed HTML page |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the list of pages is null |
System.ArgumentException | Thrown if the list of pages is empty |
ToJsonString()
Serialize the settings collection as JSON
Declaration
public string ToJsonString()
Returns
Type | Description |
---|---|
System.String | A string containing the settings collection formatted as JSON |
Explicit Interface Implementations
View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |