Class Item
- Namespace
- Dynamicweb.Content.Items
- Assembly
- Dynamicweb.dll
Represents an item whose fields can be dynamically added and removed at run time. This class cannot be inherited.
public sealed class Item : ItemEntry, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
- Inheritance
-
Item
- Implements
- Inherited Members
- Extension Methods
Remarks
For implementing your own item types, use ItemEntry as a base type.
Constructors
Item()
Initializes a new instance of an object.
public Item()
Item(ItemEntry)
Initializes a new instance of an object.
public Item(ItemEntry item)
Parameters
itemItemEntry- Item whose data is used to fill this object with.
Item(IDictionary<string, object>)
Initializes a new instance of an object.
public Item(IDictionary<string, object> fields)
Parameters
fieldsIDictionary<string, object>- Fields to fill this object with.
Item(DataRow)
Initializes a new instance of an object.
public Item(DataRow row)
Parameters
rowDataRow- A data row to reader fields from.
Item(IDataReader)
Initializes a new instance of an object.
public Item(IDataReader reader)
Parameters
readerIDataReader- A data reader to read fields from.
Item(string)
Initializes a new instance of an object.
public Item(string systemName)
Parameters
systemNamestring- Item system name.
Item(string, string)
Initializes a new instance of an object.
public Item(string systemName, string id)
Parameters
Fields
SortColumnName
public const string SortColumnName = "Sort"
Field Value
Properties
Count
Gets the total number of fields within the given item.
public int Count { get; }
Property Value
Id
Gets or sets the item Id.
public override string Id { get; set; }
Property Value
IsReadOnly
Gets value indicating whether this item is read-only and no more fields can be added or removed.
public bool IsReadOnly { get; }
Property Value
this[string]
Gets or sets the field with the given name.
public object this[string key] { get; set; }
Parameters
keystring- Field name.
Property Value
- object
- Field value.
Names
Gets all field names.
public ICollection<string> Names { get; }
Property Value
Sort
Gets or sets the number indicating the position of the item within a list of items.
public override int Sort { get; set; }
Property Value
SystemName
Gets or sets the system name of the associated item type.
public string SystemName { get; set; }
Property Value
Values
Gets all field values.
public ICollection<object> Values { get; }
Property Value
Methods
Add(KeyValuePair<string, object>)
Adds new field to this item.
public void Add(KeyValuePair<string, object> item)
Parameters
itemKeyValuePair<string, object>- Field to add.
Remarks
If the field with the given name already exists, its value will be overwritten.
Clear()
Removes all fields from this item.
public void Clear()
Contains(KeyValuePair<string, object>)
Returns value indicating whether the given field is defined on a given item.
public bool Contains(KeyValuePair<string, object> item)
Parameters
itemKeyValuePair<string, object>- Field to search for.
Returns
- bool
- Value indicating whether the given field is defined on a given item.
ContainsKey(string)
Returns value indicating whether item contains the field with the given name.
public bool ContainsKey(string key)
Parameters
keystring- Field name.
Returns
- bool
- Value indicating whether item contains the field with the given name.
CopyTo(KeyValuePair<string, object>[], int)
Copies all fields from the given item into the given array.
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<string, object>[]- Array to copy to.
arrayIndexint- Array index.
DeserializeFrom(ItemEntry)
Deserializes the state of the current object from a given item.
public void DeserializeFrom(ItemEntry item)
Parameters
itemItemEntry- Item to to deserialize this object from.
DeserializeFrom(IDictionary<string, object>)
Deserializes the state of the current object from a given set of key-value pairs.
public override void DeserializeFrom(IDictionary<string, object> dictionary)
Parameters
dictionaryIDictionary<string, object>- A set of key-value pairs to deserialize this object from.
DeserializeFrom(DataRow)
Deserializes the state of the current object from a given data row.
public void DeserializeFrom(DataRow row)
Parameters
rowDataRow- A data row to deserialize this object from.
DeserializeFrom(IDataReader)
Deserializes the state of the current object from a given data reader.
public void DeserializeFrom(IDataReader reader)
Parameters
readerIDataReader- A data reader to deserialize this object from.
GetEnumerator()
Returns an enumerator object that is used to iterate over the fields of this item.
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, object>>
- An enumerator object that is used to iterate over the fields of this item.
GetItem(string)
[Obsolete("Use index accessor instead.")]
public object GetItem(string key)
Parameters
keystring
Returns
GetItemById(string, string)
Returns the item by its Id.
public static Item GetItemById(string itemType, string id)
Parameters
Returns
- Item
- The item.
GetItemsByPageId(int)
Returns items by their page Id.
[Obsolete("Use PageService instead.", true)]
public static ItemCollection GetItemsByPageId(int pageId)
Parameters
pageIdint- Page Id.
Returns
- ItemCollection
- The items.
GetItemsByPageId(string, int)
Returns items by their page Id.
[Obsolete("Use PageService instead.", true)]
public static ItemCollection GetItemsByPageId(string itemType, int pageId)
Parameters
Returns
- ItemCollection
- The items.
Remove(KeyValuePair<string, object>)
Removes the given field from the item.
public bool Remove(KeyValuePair<string, object> item)
Parameters
itemKeyValuePair<string, object>- Field to remove.
Returns
- bool
- Value indicating whether field has been removed successfully.
SerializeTo(IDictionary<string, object>)
Serializes the state of the current object into the given dictionary.
public override void SerializeTo(IDictionary<string, object> dictionary)
Parameters
dictionaryIDictionary<string, object>- Dictionary to serialize this object into.
SerializeTo(DataRow)
Serializes the state of the current object into the given data row.
public void SerializeTo(DataRow row)
Parameters
rowDataRow- Data row to serialize this object into.
SetDefaultValues()
public void SetDefaultValues()
SetDefaultValues(ItemType)
public void SetDefaultValues(ItemType itemType)
Parameters
itemTypeItemType
SetDefaultValues(ItemType, bool)
public void SetDefaultValues(ItemType itemType, bool force)
Parameters
TryGetValue(string, out object)
Tries to get the value of a given field.
public bool TryGetValue(string key, out object value)
Parameters
Returns
- bool
- Value indicating whether field value was successfully retrieved.