Hello there, this is a brief documentation note form developer. It's me, hack2root.

Ok, let's start from scratch.

Source code contains class diagram in cd and image formats.

Interfaces

public IEntity<T>

generic entity interface

    public class ObjectEntity : Entity<ObjectEntity>
    {
        private IEntity<string> _name;
        public ObjectEntity()
        {
            _name = Entity<ObjectEntity, string>.Create("Name", this);
        }
        [Display(Name = "Имя")]
        public string Name { get { return _name.Object; } set { _name.Object = value; } }
    }
  • T IEntity<T>.Object property
represents an abstract entity an gives aacces to its contained value.

public IEntityValue<T>

generic entity value interface

        private IEntityValue<ValueType> _obj;
        public ValueType Object
        {
            get { return _obj.Value; }
            set
            {
                if (!object.Equals(value, _obj.Value))
                {
                    _obj.Value = value;
                    if (_event != null)
                    {
                        _event.NotifyPropertyChanged(_obj.Name);
                    }
                }
            }
        }

  • string IEntityValue<T>.Name property
name of the abstract value instance
  • T IEntityValue<T>.Value property
value holded by this container

public public interface IEntityValue<EntityType, ValueType>where EntityType : Entity<EntityType>

generic entity value interface
implements interfaces IEntityValue<ValueType>
  • EntityType IEntityValue<EntityType, ValueType>.Entity property
abstract entity owner for the entity value instance

public IEntityNotifyPropertyChanged

interface fo the internal ObservableCollection<T>.OnPropertyChange method support
  • void IEntityNotifyPropertyChanged.NotifyPropertyChanged
method call to call protected ObservableCollection<T> method OnPropertyChange

(watch it, silverlight team!)

Classes

public sealed EntityValue<T>

simple class that holds named entity values

    public sealed class EntityValue<ValueType> : IEntityValue<ValueType>
    {
        private string _name;

        public EntityValue(string name)
        {
            _name = name;
        }

        public string Name { get { return _name; } }

        public ValueType Value { get; set; }
    }
  • string EntityValue<T>.Name property
name of the entity value
implements IEntityValue<T> interface

used internally for the IEntityNotifyPropertyChanged.NotifyPropertyChanged calls
  • T EntityValue<T>.Value property
strongly-typed entity value of the instance

public sealed CollectionEntity<EntityType> where EntityType : Entity<EntityType>

implements IEntityNotifyPropertyChanged interface
  • CollectionEntity<EntityType>.NotifyPropertyChanged
calls ObservableCollection<EntityType>.OnPropertyChange protected method

public sealed Entity<EntityType, ValueType> where EntityType : Entity<EntityType>

class used to create named entities
implements interfaces IEditableObject, IEntityNotifyPropertyChanged

    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("Name", this);*
        }

        [Display(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 Entity<EntityType>

class to derive from. API central point of interest.
implements interfaces IEntityValue<T>, IEntityNotifyPropertyChanged intefaces

public EntityValidationValue<EntityType, ValueType>

class to derive from. API central point of interest.
simple class that holds named entity values which support validation
  • string EntityValidationValue<EntityType, ValueType>.Name property
implements IEntityValue<EntityType, ValueType> interface

available for the EntityValidationValue<EntityType, ValueType>.Validate(ValueType value) validation method call
  • ValueType EntityValidationValue<EntityType, ValueType>.Value property
implements IEntityValue<EntityType, ValueType> interface

available for the EntityValidationValue<EntityType, ValueType>.Validate(ValueType value) validation method call
  • EntityType EntityValidationValue<EntityType, ValueType>.Entity property

available for the EntityValidationValue<EntityType, ValueType>.Validate(ValueType value) validation method call
  • public abstract bool EntityValidationValue<EntityType, ValueType>.Validate(ValueType value) methods
validates values assigned to the entity value instances

    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;
        }
    }



Last edited Dec 15, 2009 at 6:53 AM by hack2root, version 15

Comments

No comments yet.