Exemplo n.º 1
0
        public IEnumerable <KeyValuePair <string, string> > AutoMapComponentAndKey(ComponentSpecification spec)
        {
            foreach (var property in spec.Properties)
            {
                var propertyName = property.Name;
                // Try find something by name
                var possibleProperty = _key.Properties.FirstOrDefault(p => p.Name == propertyName);
                if (possibleProperty != null)
                {
                    yield return(new KeyValuePair <string, string>(propertyName, possibleProperty.Name));

                    continue;
                }

                // Try find by type. This is not the best way of doing it, but might find some matches.
                string propertyType = property.Type;
                possibleProperty = _key.Properties.FirstOrDefault(p => p.Type == propertyType);
                if (possibleProperty != null)
                {
                    yield return(new KeyValuePair <string, string>(propertyName, possibleProperty.Name));

                    continue;
                }

                yield return(new KeyValuePair <string, string>(propertyName, ""));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,AttributeName,DateAdded,Primary,HardwareComponentId,ComponentSpecificationCategoryId")] ComponentSpecification componentSpecification)
        {
            if (id != componentSpecification.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(componentSpecification);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComponentSpecificationExists(componentSpecification.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ComponentSpecificationCategoryId"] = new SelectList(_context.ComponentSpecificationCategories, "ID", "Name", componentSpecification.ComponentSpecificationCategoryId);
            ViewData["HardwareComponentId"] = new SelectList(_context.HardwareComponents, "ID", "Name", componentSpecification.HardwareComponentId);
            return(View(componentSpecification));
        }
Exemplo n.º 3
0
        private void MapExistingOnPageLoad()
        {
            wizardPageMapExisting.NextButtonEnabled = ToWizardButtonState(MapExistingValidation());

            var currentComponentSpec = comboBoxExistingComponentDefs.GetSelectedItem <ComponentSpecification>();

            if (currentComponentSpec != _loadedComponentSpec || _loadedComponentSpec == null)
            {
                _loadedComponentSpec = currentComponentSpec;

                // Clear the current mappings
                dataGridViewPropertyMappings.Rows.Clear();

                // Add all the mappings
                var mappings           = _modelInformation.AutoMapComponentAndKey(currentComponentSpec);
                var possibleProperties = _modelInformation.GetKeyProperties();
                foreach (var mapping in mappings)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewPropertyMappings);
                    row.Cells[0].Value = mapping.Key;

                    DataGridViewComboBoxCell column = (DataGridViewComboBoxCell)row.Cells[1];
                    column.Items.Add("");
                    foreach (var item in possibleProperties)
                    {
                        column.Items.Add(item);
                    }

                    column.Value = mapping.Value;

                    dataGridViewPropertyMappings.Rows.Add(row);
                }
            }
        }
 public ConvertKeyToExistingComponentResults(ComponentSpecification existingSpecToUse, string newComponentName, bool deleteExistingProperties, IEnumerable<KeyValuePair<string, string>> propertyMappings)
 {
     this.existingSpecToUse = existingSpecToUse;
     this.newComponentName = newComponentName;
     this.deleteExistingProperties = deleteExistingProperties;
     this.propertyMappings = propertyMappings.ToList();
 }
Exemplo n.º 5
0
        private void slyceGrid1_NewRowAdded(out object newObject)
        {
            ComponentPropertyImpl property = new ComponentPropertyImpl("NewProperty")
            {
                Type = "System.String"
            };

            property.ValidationOptions.FractionalDigits = 0;
            property.ValidationOptions.FutureDate       = false;
            property.ValidationOptions.IntegerDigits    = 0;
            property.ValidationOptions.MaximumLength    = 0;
            property.ValidationOptions.MaximumValue     = 0;
            property.ValidationOptions.MinimumLength    = 0;
            property.ValidationOptions.MinimumValue     = 0;
            property.ValidationOptions.NotEmpty         = false;
            property.ValidationOptions.Nullable         = false;
            property.ValidationOptions.PastDate         = false;
            property.ValidationOptions.RegexPattern     = "";
            property.ValidationOptions.Validate         = false;

            ComponentSpecification.AddProperty(property);
            newObject = property;

            AddPropertyToPropertiesGrid(property);

            if (ComponentChanged != null)
            {
                ComponentChanged(ComponentSpecification, null);
            }
        }
Exemplo n.º 6
0
        public void ReadFrom(CodestreamReader input)
        {
            var dataReader = input.DataReader;

            R_CapabilitiesOfCodestream = dataReader.Read <UInt16>();
            X_ReferenceGridWidth       = checked ((int)dataReader.Read <UInt32>());
            Y_ReferenceGridHeight      = checked ((int)dataReader.Read <UInt32>());
            XO_HorizontalOffsetOfImageAreaInReferenceGrid = checked ((int)dataReader.Read <UInt32>());
            YO_VerticalOffsetOfImageAreaInReferenceGrid   = checked ((int)dataReader.Read <UInt32>());
            XT_TileWidth  = checked ((int)dataReader.Read <UInt32>());
            YT_TileHeight = checked ((int)dataReader.Read <UInt32>());
            XT_HorizontalOffsetOfFirstTileInReferenceGrid = checked ((int)dataReader.Read <UInt32>());
            YTO_VerticalOffsetOfFirstTileInReferenceGrid  = checked ((int)dataReader.Read <UInt32>());
            C_NumberOfImageComponents = dataReader.Read <UInt16>();

            var componentSpecifications = new ComponentSpecification[C_NumberOfImageComponents];

            for (var i = 0; i < componentSpecifications.Length; i++)
            {
                componentSpecifications[i] = ComponentSpecification.ReadFrom(dataReader);
            }
            ComponentSpecifications = componentSpecifications;

            Debug.Assert(dataReader.Input.AtEnd);
        }
 public ConvertKeyToExistingComponentResults(ComponentSpecification existingSpecToUse, string newComponentName, bool deleteExistingProperties, IEnumerable <KeyValuePair <string, string> > propertyMappings)
 {
     this.existingSpecToUse        = existingSpecToUse;
     this.newComponentName         = newComponentName;
     this.deleteExistingProperties = deleteExistingProperties;
     this.propertyMappings         = propertyMappings.ToList();
 }
        public IEnumerable<KeyValuePair<string, string>> AutoMapComponentAndKey(ComponentSpecification spec)
        {
            foreach(var property in spec.Properties)
            {
                var propertyName = property.Name;
                // Try find something by name
                var possibleProperty = _key.Properties.FirstOrDefault(p => p.Name == propertyName);
                if(possibleProperty != null)
                {
                    yield return new KeyValuePair<string, string>(propertyName, possibleProperty.Name);
                    continue;
                }

                // Try find by type. This is not the best way of doing it, but might find some matches.
                string propertyType = property.Type;
                possibleProperty = _key.Properties.FirstOrDefault(p => p.Type == propertyType);
                if (possibleProperty != null)
                {
                    yield return new KeyValuePair<string, string>(propertyName, possibleProperty.Name);
                    continue;
                }

                yield return new KeyValuePair<string, string>(propertyName, "");
            }
        }
Exemplo n.º 9
0
 public void RemoveComponentSpecification(ComponentSpecification spec)
 {
     components.Remove(spec);
     spec.EntitySet = null;
     ComponentSpecsChanged.RaiseDeletionEventEx(this, spec);
     RaisePropertyChanged("ComponentSpecifications");
 }
        public void SetUp()
        {
            ComponentSpecification.Stub(s => s.Create()).Return(new Atom("new atom", null));

            var amendment = new AddComponentAmendment(new[] { 0 }, "new atom");

            this.Visitor.Visit(amendment);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the MappingSet object that the ComponentSpecification belongs to, or null if it doesn't belong to one.
        /// </summary>
        /// <param name="componentSpec"></param>
        /// <returns></returns>
        public static MappingSet GetMappingSet(this ComponentSpecification componentSpec)
        {
            if (componentSpec == null || componentSpec.EntitySet == null)
            {
                return(null);
            }

            return(componentSpec.EntitySet.MappingSet);
        }
        public FormSelectExistingEntity(ComponentSpecification componentSpecification, List<Entity> unavailableEntities, Entity selectedEntity, string title, bool multiSelect)
        {
            InitializeComponent();

            MultiSelect = multiSelect;
            RequestorType = RequestorTypes.Component;
            ComponentSpecification = componentSpecification;
            UnavailableEntities = unavailableEntities;
            Text = title;
            SelectedEntity = selectedEntity;
            Populate();
        }
        public FormSelectExistingEntity(ComponentSpecification componentSpecification, List <Entity> unavailableEntities, Entity selectedEntity, string title, bool multiSelect)
        {
            InitializeComponent();

            MultiSelect            = multiSelect;
            RequestorType          = RequestorTypes.Component;
            ComponentSpecification = componentSpecification;
            UnavailableEntities    = unavailableEntities;
            Text           = title;
            SelectedEntity = selectedEntity;
            Populate();
        }
Exemplo n.º 14
0
        public void AddComponentSpecification(ComponentSpecification componentSpec)
        {
            if (components.Contains(componentSpec))
            {
                return;
            }

            components.Add(componentSpec);
            componentSpec.EntitySet = this;
            RaisePropertyChanged("ComponentSpecifications");
            ComponentSpecsChanged.RaiseAdditionEventEx(this, componentSpec);
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("ID,AttributeName,DateAdded,Primary,HardwareComponentId,ComponentSpecificationCategoryId")] ComponentSpecification componentSpecification)
        {
            if (ModelState.IsValid)
            {
                _context.Add(componentSpecification);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ComponentSpecificationCategoryId"] = new SelectList(_context.ComponentSpecificationCategories, "ID", "Name", componentSpecification.ComponentSpecificationCategoryId);
            ViewData["HardwareComponentId"] = new SelectList(_context.HardwareComponents, "ID", "Name", componentSpecification.HardwareComponentId);
            return(View(componentSpecification));
        }
        public override void DetachFromModel()
        {
            if (Detached || spec == null)
            {
                return;
            }

            spec.PropertyChanged              -= property_PropertyChanged;
            spec.PropertiesChanged            -= spec_PropertiesChanged;
            spec.ImplementedComponentsChanged -= spec_ImplementedComponentsChanged;
            spec     = null;
            Detached = true;
            form.Clear();
        }
        public void AttachToModel(ComponentSpecification obj)
        {
            if (!Detached)
            {
                DetachFromModel();
            }

            spec                               = obj;
            Detached                           = false;
            spec.PropertyChanged              += property_PropertyChanged;
            spec.PropertiesChanged            += spec_PropertiesChanged;
            spec.ImplementedComponentsChanged += spec_ImplementedComponentsChanged;

            SetupForm();
        }
Exemplo n.º 18
0
        private bool slyceGrid1_DeleteClicked(int row, object tag)
        {
            if (MessageBox.Show(this, string.Format("Delete {0}?", ((ComponentPropertyImpl)tag).Name), "Delete Property", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                ComponentSpecification.RemovePropertyAndMarkers((ComponentPropertyImpl)tag);

                if (ComponentChanged != null)
                {
                    ComponentChanged(ComponentSpecification, null);
                }

                return(true);
            }
            return(false);
        }
        public void Show_Property_Grid_Called()
        {
            IComponentSpecificationForm form = MockRepository.GenerateMock <IComponentSpecificationForm>();
            ComponentSpecification      obj  = MockRepository.GenerateMock <ComponentSpecification>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            obj.Stub(o => o.ImplementedComponents).Return(new List <Component>().AsReadOnly());
            obj.Stub(o => o.EntitySet).Return(new EntitySetImpl());

            ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form);

            presenter.AttachToModel(obj);
            presenter.Show();

            panel.AssertWasCalled(p => p.ShowPropertyGrid(form));
        }
        public void Setup()
        {
            set    = new MappingSetImpl();
            entity = new EntityImpl("Entity1");
            set.EntitySet.AddEntity(entity);
            table = new Table("Table1");
            table.AddColumn(new Column("Street"));
            set.Database.AddTable(table);

            spec = new ComponentSpecificationImpl("Address");
            spec.AddProperty(new ComponentPropertyImpl("Street"));
            set.EntitySet.AddComponentSpecification(spec);

            component = spec.CreateImplementedComponentFor(entity, "HomeAddress");
            set.ChangeMappingFor(component.Properties[0]).To(table.Columns[0]);
        }
Exemplo n.º 21
0
        public void Setup()
        {
            set = new MappingSetImpl();
            entity = new EntityImpl("Entity1");
            set.EntitySet.AddEntity(entity);
            table = new Table("Table1");
            table.AddColumn(new Column("Street"));
            set.Database.AddTable(table);

            spec = new ComponentSpecificationImpl("Address");
            spec.AddProperty(new ComponentPropertyImpl("Street"));
            set.EntitySet.AddComponentSpecification(spec);

            component = spec.CreateImplementedComponentFor(entity, "HomeAddress");
            set.ChangeMappingFor(component.Properties[0]).To(table.Columns[0]);
        }
        public void Property_Changed_Registered()
        {
            IComponentSpecificationForm form = MockRepository.GenerateMock <IComponentSpecificationForm>();
            ComponentSpecification      obj  = MockRepository.GenerateMock <ComponentSpecification>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            obj.Stub(o => o.ImplementedComponents).Return(new List <Component>().AsReadOnly());
            obj.Stub(o => o.EntitySet).Return(new EntitySetImpl());

            ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form);

            presenter.AttachToModel(obj);

            obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.ImplementedComponentsChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.PropertiesChanged            += null, c => c.IgnoreArguments());
        }
Exemplo n.º 23
0
        private void SerialiseComponentSpecificationInternal(ComponentSpecification spec, XmlWriter writer)
        {
            writer.WriteStartElement("ComponentSpecification");
            writer.WriteAttributeString("name", spec.Name);

            foreach (var property in spec.Properties.OrderBy(p => p.Name))
            {
                SerialiseComponentPropertyInternal(property, writer);
            }

            foreach (var component in spec.ImplementedComponents.OrderBy(i => i.Name))
            {
                SerialiseComponentInternal(component, writer);
            }

            ProcessScriptBase(spec, writer);
            writer.WriteEndElement();
        }
        public void Setup()
        {
            // Setup Database
            database = new Database("DB1");
            var table = new Table("User");

            table.AddColumn(new Column("Name"));
            table.AddColumn(new Column("AddressStreet"));
            table.AddColumn(new Column("AddressCity"));
            table.AddColumn(new Column("AddressCountry"));
            database.AddTable(table);

            // Setup Entities
            entitySet = new EntitySetImpl();
            Entity userEntity = new EntityImpl("User");

            userEntity.AddProperty(new PropertyImpl("Name"));

            // Create the Address type
            spec = new ComponentSpecificationImpl("Address");

            spec.AddProperty(new ComponentPropertyImpl("Street"));
            spec.AddProperty(new ComponentPropertyImpl("City"));
            spec.AddProperty(new ComponentPropertyImpl("Country"));

            // Create the Address component for the User entity.
            component = spec.CreateImplementedComponentFor(userEntity, "HomeAddress");

            entitySet.AddEntity(userEntity);
            entitySet.AddComponentSpecification(spec);

            // Setup the Mappings
            mappingSet       = new MappingSetImpl(database, entitySet);
            componentMapping = new ComponentMappingImpl();
            mappingSet.AddMapping(componentMapping);

            componentMapping.AddPropertyAndColumn(component.Properties[0], table.Columns[1]);
            componentMapping.AddPropertyAndColumn(component.Properties[1], table.Columns[2]);
            componentMapping.AddPropertyAndColumn(component.Properties[2], table.Columns[3]);

            // Add the mapping between the Name property and the Name column in the database table.
            mappingSet.ChangeMappedColumnFor(userEntity.ConcreteProperties[0]).To(table.Columns[0]);
        }
Exemplo n.º 25
0
        public Component DeserialiseComponent(XmlNode componentNode, ComponentSpecification spec)
        {
            var proc = new NodeProcessor(componentNode);

            string parentName   = proc.Attributes.GetString("parent-type");
            var    parentEntity = spec.EntitySet.GetEntity(parentName);

            if (parentEntity == null)
            {
                throw new DeserialisationException(string.Format("Could not find parent type {0} of component", parentName));
            }

            string componentName = proc.Attributes.GetString("name");

            Component component = spec.CreateImplementedComponentFor(parentEntity, componentName);

            ProcessScriptBase(component, componentNode);

            return(component);
        }
        public void Setup()
        {
            database  = new Database("Db1");
            entitySet = new EntitySetImpl();

            table = new Table("Table1");
            table.AddColumn(new Column("AddressStreet"));

            var entity1 = new EntityImpl("Entity1");

            componentSpec = new ComponentSpecificationImpl("Address");
            entitySet.AddComponentSpecification(componentSpec);
            componentSpec.AddProperty(new ComponentPropertyImpl("Street"));

            component1 = componentSpec.CreateImplementedComponentFor(entity1, "HomeAddress");
            component2 = componentSpec.CreateImplementedComponentFor(entity1, "WorkAddress");

            database.AddTable(table);
            entitySet.AddEntity(entity1);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Writes a component specification.
        /// </summary>
        /// <param name="specification">the component specification</param>
        public virtual void writeComponentSpecification(ComponentSpecification specification)
        {
            if (specification == null)
            {
                return;
            }

            switch (specification.Type)
            {
            case ComponentSpecification.ComponentType.ALL:
                getMiscellaneousElementOutput().allComponentSpecification(specification);
                break;

            case ComponentSpecification.ComponentType.INSTANTIATION_LIST:
                getMiscellaneousElementOutput().instantiationListComponentSpecification(specification);
                break;

            case ComponentSpecification.ComponentType.OTHERS:
                getMiscellaneousElementOutput().othersComponentSpecification(specification);
                break;
            }
        }
Exemplo n.º 28
0
        public ComponentProperty DeserialiseComponentProperty(XmlNode propertyNode, ComponentSpecification spec)
        {
            NodeProcessor proc = new NodeProcessor(propertyNode);

            ComponentProperty property = new ComponentPropertyImpl();

            property.Specification = spec;
            property.Name          = proc.GetString("Name");
            property.Type          = proc.GetString("Type");

            if (proc.Exists("Validation"))
            {
                property.ValidationOptions = DeserialiseValidationOptions(propertyNode.SelectSingleNode("Validation"));
            }
            else
            {
                property.ValidationOptions = new ValidationOptions();
            }

            ProcessScriptBase(property, propertyNode);

            return(property);
        }
Exemplo n.º 29
0
        public void AddComponentSpecification(ComponentSpecification componentSpec)
        {
            if (components.Contains(componentSpec))
                return;

            components.Add(componentSpec);
            componentSpec.EntitySet = this;
            RaisePropertyChanged("ComponentSpecifications");
            ComponentSpecsChanged.RaiseAdditionEventEx(this, componentSpec);
        }
        private void MapExistingOnPageLoad()
        {
            wizardPageMapExisting.NextButtonEnabled = ToWizardButtonState(MapExistingValidation());

            var currentComponentSpec = comboBoxExistingComponentDefs.GetSelectedItem<ComponentSpecification>();
            if (currentComponentSpec != _loadedComponentSpec || _loadedComponentSpec == null)
            {
                _loadedComponentSpec = currentComponentSpec;

                // Clear the current mappings
                dataGridViewPropertyMappings.Rows.Clear();

                // Add all the mappings
                var mappings = _modelInformation.AutoMapComponentAndKey(currentComponentSpec);
                var possibleProperties = _modelInformation.GetKeyProperties();
                foreach(var mapping in mappings)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewPropertyMappings);
                    row.Cells[0].Value = mapping.Key;

                    DataGridViewComboBoxCell column = (DataGridViewComboBoxCell) row.Cells[1];
                    column.Items.Add("");
                    foreach(var item in possibleProperties)
                        column.Items.Add(item);

                    column.Value = mapping.Value;

                    dataGridViewPropertyMappings.Rows.Add(row);
                }
            }
        }
Exemplo n.º 31
0
        public void Setup()
        {
            // Setup Database
            database = new Database("DB1");
            var table = new Table("User");
            table.AddColumn(new Column("Name"));
            table.AddColumn(new Column("AddressStreet"));
            table.AddColumn(new Column("AddressCity"));
            table.AddColumn(new Column("AddressCountry"));
            database.AddTable(table);

            // Setup Entities
            entitySet = new EntitySetImpl();
            Entity userEntity = new EntityImpl("User");
            userEntity.AddProperty(new PropertyImpl("Name"));

            // Create the Address type
            spec = new ComponentSpecificationImpl("Address");

            spec.AddProperty(new ComponentPropertyImpl("Street"));
            spec.AddProperty(new ComponentPropertyImpl("City"));
            spec.AddProperty(new ComponentPropertyImpl("Country"));

            // Create the Address component for the User entity.
            component = spec.CreateImplementedComponentFor(userEntity, "HomeAddress");

            entitySet.AddEntity(userEntity);
            entitySet.AddComponentSpecification(spec);

            // Setup the Mappings
            mappingSet = new MappingSetImpl(database, entitySet);
            componentMapping = new ComponentMappingImpl();
            mappingSet.AddMapping(componentMapping);

            componentMapping.AddPropertyAndColumn(component.Properties[0], table.Columns[1]);
            componentMapping.AddPropertyAndColumn(component.Properties[1], table.Columns[2]);
            componentMapping.AddPropertyAndColumn(component.Properties[2], table.Columns[3]);

            // Add the mapping between the Name property and the Name column in the database table.
            mappingSet.ChangeMappedColumnFor(userEntity.ConcreteProperties[0]).To(table.Columns[0]);
        }
 private void comboBoxExEntities_SelectedIndexChanged(object sender, EventArgs e)
 {
     Entity = (Entity)comboBoxExEntities.SelectedItem;
     ComponentSpecification.CreateImplementedComponentFor(Entity, textBoxComponentName.Text);
     Populate();
 }
Exemplo n.º 33
0
 /// <summary>
 /// Creates a component configuration.
 /// </summary>
 /// <param name="componentSpecification">specifies the configured components</param>
 public ComponentConfiguration(ComponentSpecification componentSpecification)
 {
     this.componentSpecification = componentSpecification;
 }
Exemplo n.º 34
0
 public void RemoveComponentSpecification(ComponentSpecification spec)
 {
     components.Remove(spec);
     spec.EntitySet = null;
     ComponentSpecsChanged.RaiseDeletionEventEx(this, spec);
     RaisePropertyChanged("ComponentSpecifications");
 }
 public void Fill(ComponentSpecification componentSpecification, Entity entity)
 {
     ComponentSpecification = componentSpecification;
     Entity = entity;
     Populate();
 }
 public void instantiationListComponentSpecification(ComponentSpecification specification)
 {
     writer.AppendStrings(specification.Labels, ", ");
     writer.Append(" : ").AppendIdentifier(specification.Component);
 }
 public void othersComponentSpecification(ComponentSpecification specification)
 {
     writer.Append(KeywordEnum.OTHERS.ToString()).Append(" : ");
     writer.AppendIdentifier(specification.Component);
 }
 public void allComponentSpecification(ComponentSpecification specification)
 {
     writer.Append(KeywordEnum.ALL.ToString()).Append(" : ");
     writer.AppendIdentifier(specification.Component);
 }