Search Results for

    Show / Hide Table of Contents

    Class PlugExtraData

    • C#
    • Visual Basic
    [Obfuscation(Exclude = true, ApplyToMembers = true)]
    [Serializable]
    public class PlugExtraData
    <Obfuscation(Exclude:=True, ApplyToMembers:=True)>
    <Serializable>
    Public Class PlugExtraData
    Inheritance
    System.Object
    PlugExtraData
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: HomeSeer.PluginSdk.Devices
    Assembly: PluginSdk.dll


    A collection of keyed and non-keyed data items attached to an AbstractHsDevice


    Remarks

    Use this to store any data specific to the operation of your plugin.

    Please note that all keys will be converted to lower case when stored in the HS database

    Fields

    View Source

    _namedData

    Declaration
    • C#
    • Visual Basic
    Dictionary<string, string> _namedData
    _namedData As Dictionary(Of String, String)
    Field Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.String>
    View Source

    _unNamedData

    Declaration
    • C#
    • Visual Basic
    List<string> _unNamedData
    _unNamedData As List(Of String)
    Field Value
    Type Description
    System.Collections.Generic.List<System.String>

    Properties

    View Source

    Item[Int32]

    Access the non-keyed item located at the specified index in the collection.

    Declaration
    • C#
    • Visual Basic
    public string this[int index] { get; set; }
    Public Property Item(index As Integer) As String
    Parameters
    Type Name Description
    System.Int32 index

    The index of the non-keyed item.

    Property Value
    Type Description
    System.String
    Remarks

    This returns the value as is.

    See Also
    Item[Int32]
    View Source

    Item[String]

    Access the item with the specified key

    Declaration
    • C#
    • Visual Basic
    public string this[string key] { get; set; }
    Public Property Item(key As String) As String
    Parameters
    Type Name Description
    System.String key

    The key of the item

    Property Value
    Type Description
    System.String
    Remarks

    This returns the value as is.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the specified key is null or whitespace.

    See Also
    Item[String]
    View Source

    NamedCount

    The number of keyed data items stored in the PlugExtraData

    Declaration
    • C#
    • Visual Basic
    public int NamedCount { get; }
    Public ReadOnly Property NamedCount As Integer
    Property Value
    Type Description
    System.Int32
    View Source

    NamedKeys

    A list of keys for data items stored in this PlugExtraData

    Declaration
    • C#
    • Visual Basic
    public List<string> NamedKeys { get; }
    Public ReadOnly Property NamedKeys As List(Of String)
    Property Value
    Type Description
    System.Collections.Generic.List<System.String>
    View Source

    UnNamed

    A collection of non-keyed data items stored in the PlugExtraData

    Declaration
    • C#
    • Visual Basic
    public List<string> UnNamed { get; }
    Public ReadOnly Property UnNamed As List(Of String)
    Property Value
    Type Description
    System.Collections.Generic.List<System.String>
    Remarks

    Use Item[Int32] or GetUnNamed(Int32) to retrieve the value as is. If the stored value is a JSON string, use GetUnNamed<TData>(Int32) to retrieve the value while using Newtonsoft to deserialize it.

    View Source

    UnNamedCount

    The number of non-keyed items in the PlugExtraData

    Declaration
    • C#
    • Visual Basic
    public int UnNamedCount { get; }
    Public ReadOnly Property UnNamedCount As Integer
    Property Value
    Type Description
    System.Int32

    Methods

    View Source

    AddNamed(String, String)

    Add a new keyed data item to the collection

    Declaration
    • C#
    • Visual Basic
    public bool AddNamed(string key, string data)
    Public Function AddNamed(key As String, data As String) As Boolean
    Parameters
    Type Name Description
    System.String key

    The key for the data

    System.String data

    The data to save

    Returns
    Type Description
    System.Boolean

    TRUE if the item was saved, FALSE if it already exists

    Remarks

    If you are trying to store an object, serialize it as a string using Newtonsoft before saving it or use AddNamed<TData>(String, TData). Do not serialize primitives. Serializing primitives may produce unintended results.

    Please note that all keys will be converted to lower case when stored in the HS database

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the key is null or whitespace

    View Source

    AddNamed<TData>(String, TData)

    Add a new keyed data item to the collection. Serialize the data to a string before saving.

    Declaration
    • C#
    • Visual Basic
    public bool AddNamed<TData>(string key, TData data)
    Public Function AddNamed(Of TData)(key As String, data As TData) As Boolean
    Parameters
    Type Name Description
    System.String key

    The key for the data

    TData data

    The data to save in the collection of type TData

    Returns
    Type Description
    System.Boolean

    TRUE if the item was saved, FALSE if it already exists

    Type Parameters
    Name Description
    TData

    The type of the data being saved.

    Remarks

    Please note that all keys will be converted to lower case when stored in the HS database

    Do not serialize primitives. Serializing primitives may produce unintended results. Use AddNamed(String, String) to save primitive values.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the key or data is null

    JsonDataException

    Thrown when there is an error while serializing the data

    View Source

    AddUnNamed(String)

    Add a new item to the collection without a key.

    Declaration
    • C#
    • Visual Basic
    public int AddUnNamed(string data)
    Public Function AddUnNamed(data As String) As Integer
    Parameters
    Type Name Description
    System.String data

    The data for the item to save.

    Returns
    Type Description
    System.Int32

    The index of the item in the collection.

    Remarks

    If you are trying to store an object, serialize it as a string using Newtonsoft before saving it or use AddUnNamed<TData>(TData). Do not serialize primitives. Serializing primitives may produce unintended results.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the data to be stored is null or whitespace.

    View Source

    AddUnNamed<TData>(TData)

    Add a new item to the collection without a key. Serialize the data to a string before saving.

    Declaration
    • C#
    • Visual Basic
    public int AddUnNamed<TData>(TData data)
    Public Function AddUnNamed(Of TData)(data As TData) As Integer
    Parameters
    Type Name Description
    TData data

    The data to save in the collection of type TData

    Returns
    Type Description
    System.Int32

    The index of the item in the collection.

    Type Parameters
    Name Description
    TData

    The type of the data being saved.

    Remarks

    Do not serialize primitives. Serializing primitives may produce unintended results. Use AddUnNamed(String) to save primitive values.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the data is null

    JsonDataException

    Thrown when there is an error while serializing the data

    See Also
    AddUnNamed(String)
    GetUnNamed<TData>(Int32)
    View Source

    ContainsNamed(String)

    Determine if a data item with the specified key exists in the collection

    Declaration
    • C#
    • Visual Basic
    public bool ContainsNamed(string key)
    Public Function ContainsNamed(key As String) As Boolean
    Parameters
    Type Name Description
    System.String key

    The key of the data item to look for

    Returns
    Type Description
    System.Boolean

    TRUE if the item exists in the collection, FALSE if it does not.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the specified key is null or whitespace.

    View Source

    GetNamed(String)

    Get the item with the specified key. This does not process the data at all. It returns the value as it is stored.

    Declaration
    • C#
    • Visual Basic
    public string GetNamed(string key)
    Public Function GetNamed(key As String) As String
    Parameters
    Type Name Description
    System.String key

    The key of the item to get

    Returns
    Type Description
    System.String

    The string represented by the specified key

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the specified key is null or whitespace.

    See Also
    Item[String]
    GetNamed<TData>(String)
    View Source

    GetNamed<TData>(String)

    Get the item with the specified key deserialized as the specified type. To retrieve the value without deserializing it, use Item[String] or GetNamed(String)

    Declaration
    • C#
    • Visual Basic
    public TData GetNamed<TData>(string key)
    Public Function GetNamed(Of TData)(key As String) As TData
    Parameters
    Type Name Description
    System.String key

    The key of the item to get

    Returns
    Type Description
    TData

    The data stored at the specified key as an instance of the specified object type

    Type Parameters
    Name Description
    TData

    The type of the object stored as a JSON serialized string

    Remarks

    This method uses Newtonsoft to deserialize the value to the type specified by TData. Do not use this to deserialize primitives.

    Exceptions
    Type Condition
    JsonDataException

    Thrown when there was a problem deserializing the data

    System.ArgumentNullException

    Thrown when the specified key is null or whitespace.

    See Also
    Item[String]
    GetNamed(String)
    View Source

    GetUnNamed(Int32)

    Get the non-keyed item located at the specified index in the collection. This does not process the data at all. It returns the value as it is stored.

    Declaration
    • C#
    • Visual Basic
    public string GetUnNamed(int index)
    Public Function GetUnNamed(index As Integer) As String
    Parameters
    Type Name Description
    System.Int32 index

    The index of the non-keyed item to get.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    Thrown if the index is out of bounds

    See Also
    Item[Int32]
    GetUnNamed<TData>(Int32)
    View Source

    GetUnNamed<TData>(Int32)

    Get the non-keyed item located at the specified index in the collection deserialized to the specified type. Use Item[Int32] or GetUnNamed(Int32) to retrieve the value as is.

    Declaration
    • C#
    • Visual Basic
    public TData GetUnNamed<TData>(int index)
    Public Function GetUnNamed(Of TData)(index As Integer) As TData
    Parameters
    Type Name Description
    System.Int32 index

    The index of the non-keyed item to get.

    Returns
    Type Description
    TData

    An instance of the specified type of the data at the specified index in the collection.

    Type Parameters
    Name Description
    TData

    The type the data should be deserialized to.

    Remarks

    This method uses Newtonsoft to deserialize the value to the type specified by TData. Do not use this to deserialize primitives.

    Exceptions
    Type Condition
    JsonDataException

    Thrown when there is an error deserializing the data to the type specified.

    See Also
    Item[Int32]
    GetUnNamed(Int32)
    View Source

    RemoveAllNamed()

    Remove all keyed items from the collection.

    Declaration
    • C#
    • Visual Basic
    public void RemoveAllNamed()
    Public Sub RemoveAllNamed
    View Source

    RemoveAllUnNamed()

    Remove all non-keyed items from the collection.

    Declaration
    • C#
    • Visual Basic
    public void RemoveAllUnNamed()
    Public Sub RemoveAllUnNamed
    View Source

    RemoveNamed(String)

    Remove the data item with the specified key from the collection.

    Declaration
    • C#
    • Visual Basic
    public bool RemoveNamed(string key)
    Public Function RemoveNamed(key As String) As Boolean
    Parameters
    Type Name Description
    System.String key

    The key of the data item to remove

    Returns
    Type Description
    System.Boolean

    TRUE if the item was removed from the collection, FALSE if it was not.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the specified key is null or whitespace.

    View Source

    RemoveUnNamed(String)

    Remove the specified non-keyed item from the collection using the default Equals implementation of the strings.

    Declaration
    • C#
    • Visual Basic
    public bool RemoveUnNamed(string data)
    Public Function RemoveUnNamed(data As String) As Boolean
    Parameters
    Type Name Description
    System.String data

    The non-keyed item to remove from the collection.

    Returns
    Type Description
    System.Boolean

    TRUE if the item was removed, FALSE if it wasn't.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when the specified data is null or an empty string.

    View Source

    RemoveUnNamedAt(Int32)

    Remove the non-keyed item at the specified index from the collection.

    Declaration
    • C#
    • Visual Basic
    public void RemoveUnNamedAt(int index)
    Public Sub RemoveUnNamedAt(index As Integer)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the non-keyed item to remove from the collection.

    • View Source
    In This Article
    Back to top HomeSeer Technologies