Project Description

Silverlight Hierarchical Entity Framework is designed to simplify development of heirarchical data structures with Silverlight.


Hello there, this is a brief documentation note form developer. It's me, hack2root.
See it on the documentation page. Hope will finish it today ;)

Forum

Forum for that project is located here:

http://forums.silverlight.net/forums/t/150651.aspx

Feedbacks are welcome!

Demo: Silverlight.HierarchicalModel

-add, remove objects and its properties hierarchively
-object's name validation

    public class ObjectEntityNameValidationValue : EntityValidationValue<ObjectEntity, string>
    {
        public ObjectEntityNameValidationValue(string name, ObjectEntity owner) : base(name, owner) { }

        public override bool Validate(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException(Name);
            }
            return true;
        }
    }

    public partial class Home : Page
    {
        public Home()
        {
            InitializeComponent();

            CollectionEntity<ObjectEntity> items = new CollectionEntity<ObjectEntity>();
            items.Add(new ObjectEntity() { Name = "Objects" });
            treeView1.ItemsSource = items;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            dataForm1.CurrentItem = dataGrid1.SelectedItem;
        }

        private void dataGrid2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            dataForm2.CurrentItem = dataGrid2.SelectedItem;
        }
    }

    public class ObjectEntity : Entity<ObjectEntity>
    {
        private IEntity<string> _name;
        private CollectionEntity<PropertyEntity> _properties;
        private CollectionEntity<ObjectEntity> _objects;

        public ObjectEntity()
        {
            _objects = new CollectionEntity<ObjectEntity>();
            _properties = new CollectionEntity<PropertyEntity>();
            _name = Entity<ObjectEntity, string>.Create(new ObjectEntityNameValidationValue("Name", this));
        }

        [Display(Name = "name")]
        public string Name { get { return _name.Object; } set { _name.Object = value; } }

        [Display(AutoGenerateField = false)]
        public CollectionEntity<ObjectEntity> Objects { get { return _objects; } }

        [Display(AutoGenerateField = false)]
        public CollectionEntity<PropertyEntity> Properties { get { return _properties; } }
    }

    public class ObjectEntityNameValidationValue : EntityValidationValue<ObjectEntity, string>
    {
        public ObjectEntityNameValidationValue(string name, ObjectEntity owner) : base(name, owner) { }

        public override bool Validate(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException(Name);
            }
            return true;
        }
    }

    public class PropertyEntity : Entity<PropertyEntity>
    {
        private IEntity<string> _name;
        private IEntity<string> _description;
        private IEntity<string> _column1;
        private IEntity<string> _column2;
        private IEntity<string> _column3;
        private IEntity<string> _column4;
        private IEntity<string> _column5;
        private IEntity<string> _column6;
        private IEntity<string> _column7;
        private IEntity<string> _column8;
        private IEntity<string> _column9;
        private IEntity<string> _column10;

        public PropertyEntity()
        {
            _name = Entity<PropertyEntity, string>.Create("Name", this);
            _description = Entity<PropertyEntity, string>.Create("Description", this);
            _column1 = Entity<PropertyEntity, string>.Create("Column1", this);
            _column2 = Entity<PropertyEntity, string>.Create("Column2", this);
            _column3 = Entity<PropertyEntity, string>.Create("Column3", this);
            _column4 = Entity<PropertyEntity, string>.Create("Column4", this);
            _column5 = Entity<PropertyEntity, string>.Create("Column5", this);
            _column6 = Entity<PropertyEntity, string>.Create("Column6", this);
            _column7 = Entity<PropertyEntity, string>.Create("Column7", this);
            _column8 = Entity<PropertyEntity, string>.Create("Column8", this);
            _column9 = Entity<PropertyEntity, string>.Create("Column9", this);
            _column10 = Entity<PropertyEntity, string>.Create("Column10", this);
        }

        [Display(Name = "name")]
        public string Name { get { return _name.Object; } set { _name.Object = value; } }

        [Display(Name = "description")]
        public string Description { get { return _description.Object; } set { _description.Object = value; } }

        [Display(Name = "column1")]
        public string Column1 { get { return _column1.Object; } set { _column1.Object = value; } }

        [Display(Name = "column2")]
        public string Column2 { get { return _column2.Object; } set { _column2.Object = value; } }

        [Display(Name = "column3")]
        public string Column3 { get { return _column3.Object; } set { _column3.Object = value; } }

        [Display(Name = "column4")]
        public string Column4 { get { return _column4.Object; } set { _column4.Object = value; } }

        [Display(Name = "column5")]
        public string Column5 { get { return _column5.Object; } set { _column5.Object = value; } }

        [Display(Name = "column6")]
        public string Column6 { get { return _column6.Object; } set { _column6.Object = value; } }

        [Display(Name = "column7")]
        public string Column7 { get { return _column7.Object; } set { _column7.Object = value; } }

        [Display(Name = "column8")]
        public string Column8 { get { return _column8.Object; } set { _column8.Object = value; } }

        [Display(Name = "column9")]
        public string Column9 { get { return _column9.Object; } set { _column9.Object = value; } }

        [Display(Name = "column10")]
        public string Column10 { get { return _column10.Object; } set { _column10.Object = value; } }
    }

Last edited Dec 24, 2009 at 12:20 AM by hack2root, version 15