Class ItemEntry
- Namespace
- Dynamicweb.Content.Items
- Assembly
- Dynamicweb.dll
Represents a base class for all strongly-typed items.
public abstract class ItemEntry
- Inheritance
-
ItemEntry
- Derived
- Inherited Members
Examples
using System;
using System.Collections.Generic;
using Dynamicweb.Content.Items;
using Dynamicweb.Content.Items.Annotations;
using Dynamicweb.Content.Items.Metadata;
using Dynamicweb.Content.Items.Activation;
using Dynamicweb.Content.Items.Editors;
using Dynamicweb.Core.UI.Icons;
namespace Dynamicweb.Examples.Items
{
[Item("Item with all field types", "The example of code-first item")]
[AreaRule,
ModuleAttachmentRule(true),
StructureRule(StructureContextType.Pages, StructureContextType.Paragraphs),
ParentRule(ParentRestrictionRule.ParentType.RootOfWebsite, ParentRestrictionRule.ParentType.RegularPage),
ChildRule(true), ChildRule("ExampleCategory", "ExampleRegion")]
[Category("Example"),CustomizedUrls,
PageDefaultView(PageDefaultView.Paragraph),
Icon(KnownIcon.Archive)]
public class ExampleAllFieldTypesItem : ItemEntry
{
[Group("StandardFields")]
[Checkbox]
public bool FieldCheckbox { get; set; }
[Group("StandardFields")]
[Color("Color", Presets = "#FFF, #151515, #444544, #5E5E5E, #005731, #287D59, #31988D, #2D73AB, #384E9A, #703F96, #9F3F95, #A93948, #E6A04B, #DD823A, #9BBF53, #0085CA, #1C588F")]
[DefaultValue("#151515")]
public string FieldColor { get; set; }
[Group("StandardFields")]
[DefaultValue("Now")]
public DateTime FieldDate { get; set; }
[Group("StandardFields")]
[DefaultValue("Now")]
[DateTime]
public DateTime FieldDateTime { get; set; }
[Group("StandardFields")]
[Decimal]
public decimal FieldDecimal { get; set; }
[Group("StandardFields")]
[File("File", "/Images/Products", "gif,jpg,png", AllowFrontendUpload = true, ShowAsImageSelector = true, UseFocalSelector = true)]
public string FieldFile { get; set; }
[Group("StandardFields")]
[Folder("Folder", "*.png")]
public string FieldFolder{ get; set; }
[Group("StandardFields")]
[Geolocation("Geolocation", AddressFields = "Street,Number,City,Zip")]
public string FieldGeolocation { get; set; }
[Group("StandardFields")]
[GoogleFont("Google font", "Lato", "italic")]
public string FieldGoogleFont { get; set; }
[Group("StandardFields")]
[ColorSwatch("Font color")]
public string FieldFontColor { get; set; }
[Group("StandardFields")]
[HiddenField]
public string FieldHidden { get; set; }
[Group("StandardFields")]
[InputHtml5("Html5", InputType = "Number", Min = 0, Max = 10)]
public int FieldHtml5 { get; set; }
[Group("StandardFields")]
[Integer]
public int FieldInteger { get; set; }
[Group("StandardFields")]
[Link]
public string FieldLink { get; set; }
[Group("StandardFields")]
[LinkToItem]
public string FieldLinkToItem { get; set; }
[Group("StandardFields")]
[ItemTypeEditor("Item", "ExampleCustomer")]
public string FieldItem { get; set; }
[Group("StandardFields")]
[Password]
public string FieldPassword { get; set; }
[Group("StandardFields")]
public string FieldText{ get; set; }
[Group("StandardFields")]
[LongText]
public string FieldLongText { get; set; }
[Group("StandardFields")]
[RichText]
public string FieldRichText { get; set; }
[Group("StandardFields")]
[ItemRelationList("Relation list", "ExampleNewsItem", ItemRelationListEditor.ItemListSource.Page, "Title", "SubTitle")]
[Option("Title"), Option("Subtitle"), Option("NewsType")]
public int FieldRelationList{ get; set; }
[Group("ListFields", LayoutGroupMetadata.GroupCollapsibleState.Collapsed)]
[DropdownList(RemoveNothingSelected = true)]
[OptionItem("ExampleCategory", "Name", "Id", SourceType = FieldOptionItemSourceType.CurrentArea)]
public string FieldDropdownList { get; set; }
[Group("ListFields")]
[CheckboxList(AllowOptionsSorting = true)]
[OptionSql("SELECT TOP 10 ProductId, ProductName FROM EcomProducts WHERE ProductPrice > 100", "ProductName", "ProductId")]
public IEnumerable<string> FieldCheckboxList { get; set; }
[Group("ListFields")]
[RadiobuttonList]
[Option("News"), Option("Featured"), Option("Add")]
[DefaultValue("News")]
public string FieldRadiobuttonList { get; set; }
[Group("ListFields")]
[RadiobuttonList(IconPosition = 1, IconMaxWidth = 140, IconMaxHeight = 100)]
[OptionFolder("/Images")]
public string FieldRadioFolderList { get; set; }
[Group("ListFields")]
[EditableList]
public string FieldEditableList { get; set; }
[Group("SpecialFields")]
[User(Name ="User")]
public string FieldUser { get; set; }
[Group("SpecialFields")]
[User(Name = "Group", ShowType = UserAttribute.ShowTypes.Groups)]
public string FieldGroup { get; set; }
[Group("SpecialFields")]
[User(Name = "Group and users", ShowType = UserAttribute.ShowTypes.GroupsAndUsers)]
public string FieldGroupsAndUsers { get; set; }
}
}
Constructors
ItemEntry()
Initializes a new instance of an object.
protected ItemEntry()
Properties
Id
Gets or sets the item Id.
public virtual string Id { get; set; }
Property Value
Sort
Gets or sets the number indicating the position of the item within a list of items.
public virtual int Sort { get; set; }
Property Value
Methods
Copy()
Creates a copy of current item which empty ID(unsaved)
public ItemEntry Copy()
Returns
Copy(ItemContext)
Creates a copy of current item which empty ID(unsaved)
public ItemEntry Copy(ItemContext context)
Parameters
context
ItemContextContext of the current item.
Returns
Copy<T>()
Creates a copy of current item which empty ID(unsaved)
public T Copy<T>() where T : ItemEntry, new()
Returns
- T
Type Parameters
T
Create(string)
Creates a new instance of an item with the given system name.
public static ItemEntry Create(string systemName)
Parameters
systemName
stringItem system name.
Returns
- ItemEntry
A new instance of an item with the given system name.
Delete()
Deletes the curren item.
public void Delete()
Exceptions
- InvalidOperationException
Cannot resolve the system name for the given item type.
Delete(ItemContext)
Deletes the curren item.
public virtual void Delete(ItemContext context)
Parameters
context
ItemContext
Exceptions
- InvalidOperationException
Cannot resolve the system name for the given item type.
DeserializeFrom(IDictionary<string, object>)
Deserializes the state of the current object from a given set of key-value pairs.
public virtual void DeserializeFrom(IDictionary<string, object> dictionary)
Parameters
dictionary
IDictionary<string, object>A set of key-value pairs to deserialize this object from.
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Save()
Saves the current item.
public void Save()
Exceptions
- InvalidOperationException
Cannot resolve the system name for the given item type.
Save(ItemContext)
Saves the current item.
public virtual void Save(ItemContext context)
Parameters
context
ItemContextContext of the current item.
Exceptions
- InvalidOperationException
Cannot resolve the system name for the given item type.
SerializeTo(IDictionary<string, object>)
Serializes the state of the current object into the given dictionary.
public virtual void SerializeTo(IDictionary<string, object> dictionary)
Parameters
dictionary
IDictionary<string, object>Dictionary to serialize this object into.
ToCodeFirstItem<T>()
Yields the code first item representation of this object.
public T ToCodeFirstItem<T>() where T : ItemEntry, new()
Returns
- T
codeFirstItem
Type Parameters
T
Code first item type