internal static void DeserialiseExtenders(Domain domain, XmlNode parentNode) { foreach (DomainContainer container in domain.Containers) { DomainEntityExtender.Deserialise(container, parentNode.SelectSingleNode("container[@guid='" + container.Guid.ToString() + "']")); } }
/// <summary> /// Creates a new entity extender within the container. /// </summary> public DomainEntityExtender CreateEntityExtender() { DomainEntityExtender entity = new DomainEntityExtender(this); _containerEntities.Add(entity); return(entity); }
protected override void OnInit() { // Get the list of columns that can be filtered by (including a null value) List <KeyValuePair <DomainTableColumn, String> > columns = null; if (this.DomainEntity.ReferencedTable != null) { columns = this.DomainEntity.ReferencedTable.TableColumns.Where(c => c.Exists).ToDictionary(c => c, c => c.ColumnName).ToList(); columns.Insert(0, new KeyValuePair <DomainTableColumn, String>(null, EntityEditor.NONE)); } // Get the list of entities that can be inherited (including a null value) IEnumerable <DomainEntity> fullEntityList = this.DomainEntity.Container.Domain.Containers.SelectMany(c => c.ContainerEntities); IEnumerable <DomainEntity> okayEntityList = fullEntityList.Where(e => e.Exists && e != this.DomainEntity && !e.Inherits(this.DomainEntity)); IEnumerable <DomainEntity> sortEntityList = okayEntityList.OrderBy(e => e.Container.ContainerName).ThenBy(e => e.EntityName); List <KeyValuePair <DomainEntity, String> > entities = sortEntityList.ToDictionary(e => e, e => e.Container.ContainerName + "." + e.EntityName).ToList(); entities.Insert(0, new KeyValuePair <DomainEntity, String>(null, EntityEditor.NONE)); // Populate the container dropdown this.ContainerDropdown.DisplayMember = "ContainerName"; this.ContainerDropdown.DataSource = this.DomainEntity.Container.Domain.Containers.Where(c => c.Exists).ToArray(); // Populate the table dropdown this.TableDropdown.DisplayMember = "TableName"; this.TableDropdown.DataSource = this.DomainEntity.Container.Domain.Tables.Where(t => t.Exists).ToArray(); // Populate the inheritence dropdown this.InheritenceDropdown.DisplayMember = "Value"; this.InheritenceDropdown.ValueMember = "Key"; this.InheritenceDropdown.DataSource = entities.ToArray(); // Populate the filter dropdown this.FilterDropdown.DisplayMember = "Value"; this.FilterDropdown.ValueMember = "Key"; this.FilterDropdown.DataSource = columns; this.FilterDropdown.Enabled = columns != null; // Populate the filter type dropdown this.FilterTypeDropdown.ValueMember = "Key"; this.FilterTypeDropdown.DisplayMember = "Value"; this.FilterTypeDropdown.DataSource = Enum.GetValues(typeof(DomainEntityFilterType)).OfType <DomainEntityFilterType>().ToDictionary(e => e, e => e.ConvertTo <String>()).ToList(); // Populate the form controls DomainEntityExtender extender = this.DomainEntity as DomainEntityExtender; this.ContainerDropdown.SelectedItem = this.DomainEntity.Container; this.NameTextbox.Text = this.DomainEntity.EntityName; this.DescriptionTextbox.Text = this.DomainEntity.EntityDescription; this.TableDropdown.SelectedItem = this.DomainEntity.ReferencedTable; this.InheritenceDropdown.SelectedItem = entities.FirstOrDefault(kvp => kvp.Key == (extender == null ? null : extender.ReferencedEntity)); this.FilterDropdown.SelectedItem = columns == null ? null : (Object)columns.FirstOrDefault(kvp => kvp.Key == this.DomainEntity.FilterColumn); this.FilterTypeDropdown.SelectedItem = this.DomainEntity.FilterType; this.FilterTextbox.Text = this.DomainEntity.FilterValue; this.AbstractCheckbox.Checked = this.DomainEntity.EntityIsAbstract; this.CreateCheckbox.Checked = this.DomainEntity.EntityIsCreatable; this.ModifyCheckbox.Checked = this.DomainEntity.EntityIsModifiable; this.RemoveCheckbox.Checked = this.DomainEntity.EntityIsRemovable; }
/// <summary> /// Deserialises the version history from the specified xml element. /// </summary> internal static new void Deserialise(DomainContainer container, XmlNode parentNode) { foreach (XmlNode xmlNode in parentNode.SelectNodes("extender")) { DomainEntityExtender result = container.CreateEntityExtender(); result.Deserialise(xmlNode); result.EntityAttributes.Execute(item => item.Deserialise(xmlNode)); } }
private static IEnumerable <String> GetReferences(DomainEntity entity) { List <String> namespaces = new List <String>(); // If an attribute is exposed and references an entity that is defined within another namespace, the namespace will need to be referenced. namespaces.AddRange(entity.EntityAttributes.Where(attr => attr.Exists && attr.Entity == entity && attr.AttributeExposed && attr.ReferencedEntity != null && attr.ReferencedEntity.Container != entity.Container).Select(attr => attr.ReferencedEntity.Container.ContainerName)); // If an attribute is exposed within another entity that is defined within another namespace, the attribute references this entity, the namespace will need to be referenced. namespaces.AddRange(entity.Container.Domain.Containers .Where(cont => cont.Exists) .SelectMany(cont => cont.ContainerEntities) .Where(ent => ent.Exists) .SelectMany(ent => ent.EntityAttributes) .Where(attr => attr.Exists && attr.ReferencedEntity == entity && attr.Entity.Container != entity.Container) .Select(attr => attr.Entity.Container.ContainerName)); // If this entity extends another, and the base entity is in another namespace, the namespace will need to be referenced. DomainEntityExtender extender = entity as DomainEntityExtender; if (extender != null && extender.Container != extender.ReferencedEntity.Container) { namespaces.Add(extender.ReferencedEntity.Container.ContainerName); } // If this entity extends another, the namespaces required for that entity will also need to be references if (extender != null) { namespaces.AddRange(ClientConsumerProxyFromEntityDynamic.GetReferences(extender.ReferencedEntity)); } return(namespaces); }