public void SetMapping(ComponentPropertyMarker property, IColumn column)
        {
            int index = properties.IndexOf(property);

            if (index == -1 && column != null)
            {
                AddPropertyAndColumn(property, column);
                return;
            }

            if (column == null)
            {
                properties.RemoveAt(index);
                columns.RemoveAt(index);
                if (MappingSet != null)
                {
                    MappingSet.InvalidateCache();
                }

                RaisePropertyChanged("Mappings");
                return;
            }

            columns[index] = column;

            if (MappingSet != null)
            {
                MappingSet.InvalidateCache();
            }

            RaisePropertyChanged("Mappings");
        }
        public void AddPropertyAndColumn(ComponentPropertyMarker prop, IColumn col)
        {
            if (FromTable == null)
            {
                FromTable = col.Parent;
            }
            if (ToComponent == null)
            {
                ToComponent = prop.Component;
            }

            if (col.Parent != FromTable)
            {
                throw new ArgumentException("Cannot add columns from multiple tables to a single Mapping object");
            }
            if (prop.Component != ToComponent)
            {
                throw new ArgumentException("Cannot add properties from multiple components to a single Mapping object");
            }

            properties.Add(prop);
            columns.Add(col);

            if (MappingSet != null)
            {
                MappingSet.InvalidateCache();
            }

            RaisePropertyChanged("Mappings");
        }
Esempio n. 3
0
        public void RemoveMappingBetween(ComponentPropertyMarker property, IColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var component = property.Component;
            var table     = column.Parent;

            var mapping = componentMappings.FirstOrDefault(m => m.ToComponent == component && m.FromTable == table);

            if (mapping != null)
            {
                mapping.SetMapping(property, null);
                if (mapping.Mappings.Count() == 0)
                {
                    RemoveMapping(mapping);
                }
            }
            CacheInvalid = true;
        }
Esempio n. 4
0
 public IColumn GetMappedColumnFor(ComponentPropertyMarker property)
 {
     if (CacheInvalid)
     {
         ClearAndRebuildCache();
     }
     return(componentPropertyColumnCache.GetMappedObject(property));
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the MappingSet object that the Component belongs to, or null if it doesn't belong to one.
        /// </summary>
        /// <param name="marker"></param>
        /// <returns></returns>
        public static MappingSet GetMappingSet(this ComponentPropertyMarker marker)
        {
            if (marker == null || marker.Component == null || marker.Component.Specification == null || marker.Component.Specification.EntitySet == null)
            {
                return(null);
            }

            return(marker.Component.Specification.EntitySet.MappingSet);
        }
Esempio n. 6
0
        public IColumn GetMappedColumnFor(ComponentPropertyMarker property)
        {
            int rowIndex = currentProperties.FindIndex(p => ReferenceEquals(p, property));

            if (rowIndex == -1)
            {
                return(null);
            }
            return(currentColumnList[rowIndex]);
        }
        public static IColumn MappedColumn(this ComponentPropertyMarker property)
        {
            MappingSet ms = property.GetMappingSet();

            if (ms == null)
            {
                return(null);
            }

            return(ms.GetMappedColumnFor(property));
        }
Esempio n. 8
0
        private void AddNewColumnPropertyMappingRow(ComponentPropertyMarker marker)
        {
            var row = new DataGridViewRow();

            row.Tag = marker;
            gridMappings.AllowUserToAddRows = true;
            row.CreateCells(gridMappings);
            row.Cells[NameColumn.Index].Value = marker.RepresentedProperty.Name;
            gridMappings.Rows.Add(row);

            gridMappings.AllowUserToAddRows = false;
        }
        public static void SetMappedColumn(this ComponentPropertyMarker property, IColumn column)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            var set = property.GetMappingSet();

            if (set == null)
            {
                throw new Exception(string.Format("Could not set Mapped Column for Property {0}: Could not get its MappingSet", property.PropertyName));
            }
            set.ChangeMappingFor(property).To(column);
        }
Esempio n. 10
0
        private LineWidth GetWidthOfComponentPropertyLine(Graphics g, ComponentPropertyMarker property)
        {
            if (!LineWidths.ContainsKey(property))
            {
                LineWidths.Add(
                    property,
                    new LineWidth(
                        g.MeasureString(property.PropertyName, FontItem).Width,
                        g.MeasureString(property.RepresentedProperty.Type, FontType).Width
                        )
                    );
            }

            return(LineWidths[property]);
        }
        public void RemovePropertyAndMappedColumn(ComponentPropertyMarker property)
        {
            int index = properties.IndexOf(property);

            if (index == -1)
            {
                return;
            }

            properties.RemoveAt(index);
            columns.RemoveAt(index);

            if (MappingSet != null)
            {
                MappingSet.InvalidateCache();
            }

            RaisePropertyChanged("Mappings");
        }
 public ComponentPropertyMappingChanger(MappingSet ms, ComponentPropertyMarker property)
 {
     this.ms       = ms;
     this.property = property;
 }
 public ColumnComponentPropertyMapping(ComponentPropertyMarker property, IColumn column)
 {
     Property = property;
     Column   = column;
 }
Esempio n. 14
0
 public ComponentPropertyMappingChanger ChangeMappingFor(ComponentPropertyMarker component)
 {
     return new ComponentPropertyMappingChanger(this, component);
 }
Esempio n. 15
0
        public void AddPropertyAndColumn(ComponentPropertyMarker prop, IColumn col)
        {
            if (FromTable == null)
            {
                FromTable = col.Parent;
            }
            if (ToComponent == null)
            {
                ToComponent = prop.Component;
            }

            if (col.Parent != FromTable)
            {
                throw new ArgumentException("Cannot add columns from multiple tables to a single Mapping object");
            }
            if (prop.Component != ToComponent)
            {
                throw new ArgumentException("Cannot add properties from multiple components to a single Mapping object");
            }

            properties.Add(prop);
            columns.Add(col);

            if (MappingSet != null) MappingSet.InvalidateCache();

            RaisePropertyChanged("Mappings");
        }
Esempio n. 16
0
 public IColumn GetMappedColumnFor(ComponentPropertyMarker property)
 {
     int rowIndex = currentProperties.FindIndex(p => ReferenceEquals(p, property));
     if (rowIndex == -1) return null;
     return currentColumnList[rowIndex];
 }
Esempio n. 17
0
        public void SetMapping(ComponentPropertyMarker property, IColumn column)
        {
            int index = properties.IndexOf(property);

            if (index == -1 && column != null)
            {
                AddPropertyAndColumn(property, column);
                return;
            }

            if (column == null)
            {
                properties.RemoveAt(index);
                columns.RemoveAt(index);
                if (MappingSet != null) MappingSet.InvalidateCache();

                RaisePropertyChanged("Mappings");
                return;
            }

            columns[index] = column;

            if (MappingSet != null) MappingSet.InvalidateCache();

            RaisePropertyChanged("Mappings");
        }
Esempio n. 18
0
 public IColumn GetMappedColumnFor(ComponentPropertyMarker property)
 {
     if (CacheInvalid) ClearAndRebuildCache();
     return componentPropertyColumnCache.GetMappedObject(property);
 }
        private LineWidth GetWidthOfComponentPropertyLine(Graphics g, ComponentPropertyMarker property)
        {
            if (!LineWidths.ContainsKey(property))
                LineWidths.Add(
                    property,
                    new LineWidth(
                        g.MeasureString(property.PropertyName, FontItem).Width,
                        g.MeasureString(property.RepresentedProperty.Type, FontType).Width
                        )
                    );

            return LineWidths[property];
        }
Esempio n. 20
0
        public void RemoveMappingBetween(ComponentPropertyMarker property, IColumn column)
        {
            if (column == null) throw new ArgumentNullException("column");
            if (property == null) throw new ArgumentNullException("property");

            var component = property.Component;
            var table = column.Parent;

            var mapping = componentMappings.FirstOrDefault(m => m.ToComponent == component && m.FromTable == table);
            if (mapping != null)
            {
                mapping.SetMapping(property, null);
                if (mapping.Mappings.Count() == 0)
                    RemoveMapping(mapping);
            }
            CacheInvalid = true;
        }
Esempio n. 21
0
 public ComponentPropertyMappingChanger(MappingSet ms, ComponentPropertyMarker property)
 {
     this.ms = ms;
     this.property = property;
 }
Esempio n. 22
0
 public ColumnComponentPropertyMapping(ComponentPropertyMarker property, IColumn column)
 {
     Property = property;
     Column = column;
 }
Esempio n. 23
0
        private void AddNewColumnPropertyMappingRow(ComponentPropertyMarker marker)
        {
            var row = new DataGridViewRow();
            row.Tag = marker;
            gridMappings.AllowUserToAddRows = true;
            row.CreateCells(gridMappings);
            row.Cells[NameColumn.Index].Value = marker.RepresentedProperty.Name;
            gridMappings.Rows.Add(row);

            gridMappings.AllowUserToAddRows = false;
        }
Esempio n. 24
0
 public ComponentPropertyMappingChanger ChangeMappingFor(ComponentPropertyMarker component)
 {
     return(new ComponentPropertyMappingChanger(this, component));
 }
Esempio n. 25
0
        public void RemovePropertyAndMappedColumn(ComponentPropertyMarker property)
        {
            int index = properties.IndexOf(property);
            if (index == -1)
                return;

            properties.RemoveAt(index);
            columns.RemoveAt(index);

            if (MappingSet != null) MappingSet.InvalidateCache();

            RaisePropertyChanged("Mappings");
        }