Ejemplo n.º 1
0
        public EditRelationDialog(ActiveRecordDescriptor descriptor, Project project, ActiveRecordPropertyRelationDescriptor prop) : base(descriptor, project)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            AssociationEnum assoc = AssociationEnum.Undefined;

            if (prop is ActiveRecordHasManyDescriptor)
            {
                hasManyButton.Checked = true;
                assoc = AssociationEnum.HasMany;
            }
            else if (prop is ActiveRecordBelongsToDescriptor)
            {
                belongsToButton.Checked = true;
                assoc = AssociationEnum.BelongsTo;
            }
            else if (prop is ActiveRecordHasAndBelongsToManyDescriptor)
            {
                hasAndBelongsToManyButton.Checked = true;
                assoc = AssociationEnum.HasAndBelongsToMany;
            }

            SelectedTarget = prop.TargetType;

            SwitchViewTo(assoc);
        }
Ejemplo n.º 2
0
        public AddRelationDialog(ActiveRecordDescriptor descriptor, Project project) : this()
        {
            _descriptor = descriptor;
            _project    = project;

            _relationBuilder = (IRelationshipBuilder)ServiceRegistry.Instance[typeof(IRelationshipBuilder)];

            className.Text = _descriptor.ClassName;

            targetTableList.ValueMember = "ClassName";

            foreach (IActiveRecordDescriptor desc in _project.Descriptors)
            {
                if (desc is ActiveRecordBaseDescriptor)
                {
                    continue;
                }
                if (desc.ClassName == null)
                {
                    continue;
                }

                targetTableList.Items.Add(desc);
            }
        }
Ejemplo n.º 3
0
        public void PostBelongsToBlog()
        {
            InitKernel();
            IRelationshipInferenceService relService = ObtainService();

            TableDefinition blogTable;
            TableDefinition postTable;

            BuildBlogPostsStructure(out blogTable, out postTable);

            BuildContext context = new BuildContext();

            ActiveRecordDescriptor arDesc = new ActiveRecordDescriptor();

            ActiveRecordPropertyDescriptor[] descs = relService.InferRelations(arDesc, postTable, context);

            Assert.IsNotNull(descs);
            Assert.AreEqual(1, descs.Length);

            ActiveRecordBelongsToDescriptor desc1 = descs[0] as ActiveRecordBelongsToDescriptor;

            Assert.IsNotNull(desc1);
            Assert.IsNotNull(desc1.TargetType);
            Assert.IsNull(desc1.PropertyType);

            Assert.AreEqual("Blog", desc1.PropertyName);
            Assert.AreEqual("blog_id", desc1.ColumnName);

            ActiveRecordDescriptor targetARDescriptor = context.GetNextPendent();

            Assert.AreSame(blogTable, targetARDescriptor.Table);
        }
Ejemplo n.º 4
0
 private void AddToNewlyCreated(ActiveRecordDescriptor descriptor)
 {
     if (!_newlyCreated.Contains(descriptor))
     {
         _newlyCreated.Add(descriptor);
     }
 }
        public void HasMany()
        {
            InitKernel();
            IRelationshipBuilder relService = ObtainService();

            TableDefinition blogTable;
            TableDefinition postTable;

            BuildBlogPostsStructure(out blogTable, out postTable);

            ActiveRecordDescriptor desc       = new ActiveRecordDescriptor("Blog");
            ActiveRecordDescriptor targetDesc = new ActiveRecordDescriptor("Post");

            RelationshipInfo info = new RelationshipInfo(AssociationEnum.HasMany, desc, targetDesc);

            info.ChildCol = new ColumnDefinition("blog_id", false, true, true, false, OleDbType.Numeric);

            ActiveRecordPropertyRelationDescriptor propDesc = relService.Build(info);

            Assert.IsNotNull(propDesc);
            Assert.IsNotNull(propDesc as ActiveRecordHasManyDescriptor);
            Assert.AreEqual("Posts", propDesc.PropertyName);
            Assert.AreEqual(targetDesc, propDesc.TargetType);
            Assert.AreEqual("blog_id", propDesc.ColumnName);
        }
Ejemplo n.º 6
0
        private void AddActiveRecordAttribute(CodeTypeDeclaration declaration, ActiveRecordDescriptor descriptor)
        {
            CodeAttributeDeclaration att = new CodeAttributeDeclaration("ActiveRecord");

            if (!(descriptor is ActiveRecordDescriptorSubClass))
            {
                att.Arguments.Add(new CodeAttributeArgument(
                                      new CodeSnippetExpression(Quote(descriptor.Table.Name))));

                if (descriptor.DiscriminatorField != null && descriptor.DiscriminatorField.Length != 0)
                {
                    att.Arguments.Add(new CodeAttributeArgument("DiscriminatorColumn",
                                                                new CodeSnippetExpression(Quote(descriptor.DiscriminatorField))));
                }
                if (descriptor.DiscriminatorType != null && descriptor.DiscriminatorType.Length != 0)
                {
                    att.Arguments.Add(new CodeAttributeArgument("DiscriminatorType",
                                                                new CodeSnippetExpression(Quote(descriptor.DiscriminatorType))));
                }
            }

            if (descriptor.DiscriminatorValue != null && descriptor.DiscriminatorValue.Length != 0)
            {
                att.Arguments.Add(new CodeAttributeArgument("DiscriminatorValue",
                                                            new CodeSnippetExpression(Quote(descriptor.DiscriminatorValue))));
            }


            declaration.CustomAttributes.Add(att);
        }
Ejemplo n.º 7
0
        public override void Activated(IDictionary context)
        {
            TableDefinition table = context["selectedtable"] as TableDefinition;

            if (table != _oldTable)
            {
                _oldTable = table;

                IPlainFieldInferenceService fieldInference = ServiceRegistry.Instance[typeof(IPlainFieldInferenceService)] as IPlainFieldInferenceService;

                ActiveRecordPropertyDescriptor[] properties =
                    fieldInference.InferProperties(table);

                ActiveRecordDescriptor ar = context["ardesc"] as ActiveRecordDescriptor;
                ar.Properties.Clear();
                ar.Properties.AddRange(properties);

                listView1.Items.Clear();

                foreach (ActiveRecordPropertyDescriptor desc in properties)
                {
                    ListViewItem item = listView1.Items.Add(desc.PropertyName);
                    item.Tag     = desc;
                    item.Checked = desc.Generate;
                    item.SubItems.Add(desc.PropertyType.Name);
                    item.SubItems.Add(desc.ColumnName);
                    item.SubItems.Add(desc.ColumnTypeName);
                }
            }
        }
Ejemplo n.º 8
0
        public ActiveRecordDescriptor Build(TableDefinition tableDef, BuildContext context)
        {
            ActiveRecordDescriptor desc = ObtainDescriptor(tableDef);

            // ClassName

            desc.ClassName = _namingService.CreateClassName(tableDef.Name);

            // Plain fields

            desc.Properties.AddRange(_plainFieldsService.InferProperties(tableDef));

            // Relations

            desc.PropertiesRelations.AddRange(_relationsService.InferRelations(desc, tableDef, context));

            // Operations

            // TODO!

            context.RemovePendent(desc);

            Build(context);

            return(desc);
        }
        public ActiveRecordPropertyRelationDescriptor[] InferRelations(ActiveRecordDescriptor desc,
                                                                       TableDefinition tableDef, BuildContext context)
        {
            if (desc == null)
            {
                throw new ArgumentNullException("desc");
            }
            if (tableDef == null)
            {
                throw new ArgumentNullException("tableDef");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
//			if (tableDef.RelatedDescriptor != null && tableDef.RelatedDescriptor != desc) {
//				throw new ArgumentException("Different descriptors");
//			}

            ArrayList list = new ArrayList();

            CreateHasManyRelations(desc, tableDef, list, context);

            CreateBelongsToRelations(desc, tableDef, list, context);

            return((ActiveRecordPropertyRelationDescriptor[])list.ToArray(typeof(ActiveRecordPropertyRelationDescriptor)));
        }
Ejemplo n.º 10
0
 public void AddPendentDescriptor(object key, ActiveRecordDescriptor descriptor)
 {
     if (!_key2Desc.Contains(key))
     {
         _key2Desc[key] = descriptor;
     }
 }
Ejemplo n.º 11
0
        public override void Deactivated(System.Collections.IDictionary context)
        {
            base.Deactivated(context);

            ActiveRecordDescriptor desc = context["ardesc"] as ActiveRecordDescriptor;

            desc.ClassName = className.Text;
        }
Ejemplo n.º 12
0
        private void UpdateTree(Project project)
        {
            treeView1.Nodes.Clear();

            TreeNode projectNode = new TreeNode(project.Name, ImageConstants.Database_Views, ImageConstants.Database_Views);

            treeView1.Nodes.Add(projectNode);

            foreach (DatabaseDefinition def in project.Databases)
            {
                TreeNode dbNode = new TreeNode(def.Alias, ImageConstants.Database_Catalog, ImageConstants.Database_Catalog);
                projectNode.Nodes.Add(dbNode);
                dbNode.EnsureVisible();

                foreach (TableDefinition table in def.Tables)
                {
                    TreeNode tableNode = new TreeNode(table.Name, ImageConstants.Database_Table, ImageConstants.Database_Table);
                    dbNode.Nodes.Add(tableNode);

                    foreach (ColumnDefinition colDef in table.Columns)
                    {
                        TreeNode colNode = new TreeNode(colDef.Name, ImageConstants.Database_Field, ImageConstants.Database_Field);
                        tableNode.Nodes.Add(colNode);
                    }
                }
            }

            Hashtable db2Node = new Hashtable();

            foreach (DictionaryEntry entry in project.BaseClasses)
            {
                IActiveRecordDescriptor baseDesc = entry.Value as IActiveRecordDescriptor;

                TreeNode arBaseNode = new TreeNode(baseDesc.ClassName, ImageConstants.Classes_Entity, ImageConstants.Classes_Entity);
                arBaseNode.Tag = baseDesc;

                projectNode.Nodes.Add(arBaseNode);

                db2Node[entry.Key] = arBaseNode;
            }

            foreach (IActiveRecordDescriptor desc in project.Descriptors)
            {
                ActiveRecordDescriptor arDesc = desc as ActiveRecordDescriptor;

                if (arDesc == null)
                {
                    continue;
                }

                TreeNode arNode = new TreeNode(desc.ClassName, ImageConstants.Classes_Entity, ImageConstants.Classes_Entity);
                arNode.Tag = arDesc;

                TreeNode parent = db2Node[arDesc.Table.DatabaseDefinition] as TreeNode;

                parent.Nodes.Add(arNode);
            }
        }
Ejemplo n.º 13
0
        public override void Deactivated(System.Collections.IDictionary context)
        {
            context["selectedtable"] = listBox1.SelectedItem;
            context["buildcontext"]  = new BuildContext();

            ActiveRecordDescriptor ar = context["ardesc"] as ActiveRecordDescriptor;

            ar.Table = listBox1.SelectedItem as TableDefinition;
        }
        private void CreateHasManyRelations(ActiveRecordDescriptor desc, TableDefinition tableDef,
                                            IList list, BuildContext context)
        {
            foreach (TableDefinition fkTable in tableDef.TablesReferencedByHasRelation)
            {
                String propertyName = _namingService.CreateRelationName(fkTable.Name);
                ActiveRecordDescriptor targetType = null;
                String           colName          = null;
                bool             pendentNecessary = false;
                ColumnDefinition selectedCol      = null;

                foreach (ColumnDefinition col in fkTable.Columns)
                {
                    if (col.RelatedTable == tableDef)
                    {
                        colName = col.Name;

                        if (col.RelatedTable.RelatedDescriptor == null && col.RelatedTable != fkTable)
                        {
                            col.RelatedTable.RelatedDescriptor = new ActiveRecordDescriptor(fkTable);

                            pendentNecessary = true;
                        }
                        else if (col.RelatedTable == tableDef)
                        {
                            targetType = desc;
                        }

                        if (targetType == null)
                        {
                            targetType = col.RelatedTable.RelatedDescriptor;
                        }

                        selectedCol = col;

                        break;
                    }
                }

                // Just to protect ourselves from awkward conditions
                if (colName == null)
                {
                    continue;
                }

                ActiveRecordHasManyDescriptor hasMany =
                    new ActiveRecordHasManyDescriptor(colName, propertyName, targetType);

                if (pendentNecessary)
                {
                    context.AddPendentDescriptor(hasMany, selectedCol.RelatedTable.RelatedDescriptor);
                }

                list.Add(hasMany);
            }
        }
Ejemplo n.º 15
0
        public ActiveRecordDescriptor[] Build(BuildContext context)
        {
            while (context.HasPendents)
            {
                ActiveRecordDescriptor pendent = context.GetNextPendent();
                Build(pendent.Table, context);
            }

            ActiveRecordDescriptor[] array = new ActiveRecordDescriptor[context.NewlyCreatedDescriptors.Count];
            context.NewlyCreatedDescriptors.CopyTo(array, 0);
            return(array);
        }
Ejemplo n.º 16
0
        public override void Deactivated(IDictionary context)
        {
            base.Deactivated(context);

            ActiveRecordDescriptor desc = context["ardesc"] as ActiveRecordDescriptor;

            foreach (ListViewItem item in listView1.Items)
            {
                ActiveRecordPropertyDescriptor property = item.Tag as ActiveRecordPropertyDescriptor;
                property.Generate = item.Checked;
            }
        }
Ejemplo n.º 17
0
        private void FillClassDetails(ActiveRecordDescriptor descriptor)
        {
            className.Text = descriptor.ClassName;

            parentClass.Items.Add("ActiveRecordBase");

            foreach (TableDefinition table in descriptor.Table.DatabaseDefinition.Tables)
            {
                if (table.RelatedDescriptor == null)
                {
                    continue;
                }
                if (table.RelatedDescriptor.ClassName == null)
                {
                    continue;
                }
                if (table.RelatedDescriptor == descriptor)
                {
                    continue;
                }

                parentClass.Items.Add(table.RelatedDescriptor.ClassName);
            }

            parentClass.Enabled = false;
            groupBox2.Enabled   = false;

            discColumn.ValueMember = "Name";

            foreach (ColumnDefinition col in descriptor.Table.Columns)
            {
                discColumn.Items.Add(col);

                if (col.Name.Equals(descriptor.DiscriminatorField))
                {
                    discColumn.SelectedItem = col;
                }
            }

            useDiscriminator.Checked = descriptor.DiscriminatorField != null;

            if (descriptor.DiscriminatorValue != null)
            {
                discValue.Text = descriptor.DiscriminatorValue;
            }

            if (descriptor is ActiveRecordDescriptorSubClass ||
                descriptor is ActiveRecordDescriptorJoinedSubClass)
            {
                useDiscriminator.Enabled = false;
                isJoinedSubClass.Enabled = false;
            }
        }
Ejemplo n.º 18
0
        private void FillClassRelationships(ActiveRecordDescriptor descriptor)
        {
            listView2.Items.Clear();

            IList added = new ArrayList();

            foreach (ActiveRecordPropertyRelationDescriptor prop in descriptor.PropertiesRelations)
            {
                ListViewItem item = listView2.Items.Add(prop.PropertyName);
                item.Tag     = prop;
                item.Checked = prop.Generate;

                if (prop.TargetType == null)
                {
                    throw new ApplicationException("Information missing");
                }

                item.SubItems.Add(prop.TargetType.ClassName);
                item.SubItems.Add(prop.RelationType);
                item.SubItems.Add(prop.ColumnName);

                added.Add(prop);
            }

            if (descriptor is ActiveRecordDescriptorSubClass)
            {
                // This code might look strange, but we're
                // only showing the fields on the parent class that haven't been
                // marked for generation, so the user might have the
                // oportunity to add them

                foreach (ActiveRecordPropertyRelationDescriptor prop in _parent.PropertiesRelations)
                {
                    if (prop.Generate || added.Contains(prop))
                    {
                        continue;
                    }

                    ListViewItem item = listView2.Items.Add(prop.PropertyName);
                    item.Tag     = prop;
                    item.Checked = prop.Generate;

                    if (prop.TargetType == null)
                    {
                        throw new ApplicationException("Information missing");
                    }

                    item.SubItems.Add(prop.TargetType.ClassName);
                    item.SubItems.Add(prop.RelationType);
                    item.SubItems.Add(prop.ColumnName);
                }
            }
        }
Ejemplo n.º 19
0
        public void RemovePendent(ActiveRecordDescriptor descriptor)
        {
            foreach (DictionaryEntry entry in _key2Desc)
            {
                if (entry.Value == descriptor)
                {
                    _key2Desc.Remove(entry.Key);
                    break;
                }
            }

            AddToNewlyCreated(descriptor);
        }
Ejemplo n.º 20
0
        private void AddProperties(ActiveRecordDescriptor arDescriptor, CodeTypeDeclaration declaration)
        {
            foreach (ActiveRecordPropertyDescriptor property in arDescriptor.Properties)
            {
                if (!property.Generate)
                {
                    continue;
                }

                CodeMemberProperty memberProperty = CreatePropertyMember(property, declaration);

                AddAppropriateAttribute(memberProperty, property);

                declaration.Members.Add(memberProperty);
            }
        }
Ejemplo n.º 21
0
        public void Run(ActiveRecordDescriptor descriptor)
        {
            using (NewSubClassDialog dialog = new NewSubClassDialog())
            {
                if (dialog.ShowDialog(Workspace.ActiveWindow) == DialogResult.OK)
                {
                    ActiveRecordDescriptorSubClass subclass = new ActiveRecordDescriptorSubClass(descriptor);
                    subclass.Table = descriptor.Table;
                    subclass.DiscriminatorValue = dialog.DiscriminatorValue;
                    subclass.ClassName          = dialog.ClassName;

                    Model.CurrentProject.AddActiveRecordDescriptor(subclass);
                    Model.Update();
                }
            }
        }
Ejemplo n.º 22
0
        private void ShowShapeProperties(Shape shape)
        {
            if (shape is ActiveRecordBaseClassShape)
            {
                ActiveRecordBasePropertiesDialog d = new ActiveRecordBasePropertiesDialog();
                d.ShowDialog();
            }
            else if (shape is ActiveRecordShape)
            {
                ActiveRecordDescriptor ar = (shape as ActiveRecordShape).ActiveRecordDescriptor;

                ActiveRecordPropertiesDialog dlg =
                    new ActiveRecordPropertiesDialog(ar, _model.CurrentProject);

                dlg.ShowDialog();
            }
        }
Ejemplo n.º 23
0
        protected override void DoProcess()
        {
            ActiveRecordDescriptor ar = Context["ardesc"] as ActiveRecordDescriptor;

            ar.Table = (Context["selectedtable"] as TableDefinition);
            ar.Table.RelatedDescriptor = ar;
//			_shape.ActiveRecordDescriptor = ar;

            // Build dependencies

            IActiveRecordDescriptorBuilder builder =
                ServiceRegistry.Instance[typeof(IActiveRecordDescriptorBuilder)]
                as IActiveRecordDescriptorBuilder;

            BuildContext buildContext = Context["buildcontext"] as BuildContext;

            Dependents = builder.Build(buildContext);
        }
Ejemplo n.º 24
0
        public ActiveRecordPropertiesDialog(ActiveRecordDescriptor descriptor, Project project)
        {
            _project    = project;
            _descriptor = descriptor;

            if (descriptor is ActiveRecordDescriptorSubClass)
            {
                _parent = ((ActiveRecordDescriptorSubClass)descriptor).BaseClass;
            }

            InitializeComponent();

            Title = descriptor.ClassName + " Properties";

            FillClassDetails(descriptor);
            FillClassProperties(descriptor);
            FillClassRelationships(descriptor);
        }
Ejemplo n.º 25
0
        public override void Activated(IDictionary context)
        {
            TableDefinition table = context["selectedtable"] as TableDefinition;

            if (table != _oldTable)
            {
                _oldTable = table;

                ActiveRecordDescriptor ar = context["ardesc"] as ActiveRecordDescriptor;

                listView1.Items.Clear();

                BuildContext buildCtx = context["buildcontext"] as BuildContext;

                IRelationshipInferenceService relationInference =
                    ServiceRegistry.Instance[typeof(IRelationshipInferenceService)] as IRelationshipInferenceService;

                ActiveRecordPropertyRelationDescriptor[] properties =
                    relationInference.InferRelations(ar, table, buildCtx);

                ar.PropertiesRelations.Clear();
                ar.PropertiesRelations.AddRange(properties);

                foreach (ActiveRecordPropertyRelationDescriptor property in properties)
                {
                    ListViewItem item = listView1.Items.Add(property.PropertyName);
                    item.Tag     = property;
                    item.Checked = property.Generate;

                    if (property.TargetType != null)
                    {
                        item.SubItems.Add(
                            property.TargetType.ClassName != null ? property.TargetType.ClassName : "<Pendent>");
                    }
                    else
                    {
                        throw new ApplicationException("Information missing");
                    }

                    item.SubItems.Add(property.RelationType);
                    item.SubItems.Add(property.ColumnName);
                }
            }
        }
Ejemplo n.º 26
0
        protected void SwitchViewTo(AssociationEnum association)
        {
            // Nothing's changed?
            if (_oldDescSelection == SelectedTarget && association == _association)
            {
                // Aparently not
                return;
            }

            // Saves
            _oldDescSelection = SelectedTarget;
            _association      = association;

            // Disabling
            associationTable.Enabled = associationTableLabel.Enabled = false;
            parentCols.Enabled       = parentColsLabel.Enabled = false;
            relatedCols.Enabled      = relatedColsLabel.Enabled = false;

            if (association == AssociationEnum.BelongsTo)
            {
                parentCols.Enabled = parentColsLabel.Enabled = true;

                PopulateColumnsInListBox(parentCols, _descriptor.Table);
            }
            else if (association == AssociationEnum.HasAndBelongsToMany)
            {
                associationTable.Enabled = associationTableLabel.Enabled = true;
                parentCols.Enabled       = parentColsLabel.Enabled = true;
                relatedCols.Enabled      = relatedColsLabel.Enabled = true;

                associationTable.SelectedIndex = -1;

                parentCols.Items.Clear();
                relatedCols.Items.Clear();

                PopulateTablesInComboBox(associationTable, _descriptor.Table.DatabaseDefinition);
            }
            else if (association == AssociationEnum.HasMany)
            {
                relatedCols.Enabled = relatedColsLabel.Enabled = true;

                PopulateColumnsInListBox(relatedCols, SelectedTarget.Table);
            }
        }
Ejemplo n.º 27
0
        public void SelfReference()
        {
            InitKernel();
            IRelationshipInferenceService relService = ObtainService();

            DatabaseDefinition dbdef = new DatabaseDefinition("alias");

            TableDefinition categoryTable = new TableDefinition("categories", dbdef);

            categoryTable.AddColumn(new ColumnDefinition("id", true, false, true, false, OleDbType.Integer));
            categoryTable.AddColumn(new ColumnDefinition("name", false, false, false, false, OleDbType.VarChar));
            categoryTable.AddColumn(new ColumnDefinition("parent_id", false, true, false, false, OleDbType.Integer, categoryTable));

            categoryTable.AddManyRelation(categoryTable);

            BuildContext context = new BuildContext();

            ActiveRecordDescriptor arDesc = new ActiveRecordDescriptor();

            ActiveRecordPropertyDescriptor[] descs = relService.InferRelations(arDesc, categoryTable, context);

            Assert.IsFalse(context.HasPendents);

            Assert.IsNotNull(descs);
            Assert.AreEqual(2, descs.Length);

            ActiveRecordHasManyDescriptor desc1 = descs[0] as ActiveRecordHasManyDescriptor;

            Assert.IsNotNull(desc1);
            Assert.IsNotNull(desc1.TargetType);
            Assert.IsNotNull(desc1.PropertyType);

            Assert.AreEqual("Categories", desc1.PropertyName);
            Assert.AreEqual("parent_id", desc1.ColumnName);
            Assert.AreEqual(typeof(IList), desc1.PropertyType);

            ActiveRecordBelongsToDescriptor desc2 = descs[1] as ActiveRecordBelongsToDescriptor;

            Assert.IsNotNull(desc2);
            Assert.IsNotNull(desc2.TargetType);
            Assert.IsNull(desc2.PropertyType);
            Assert.AreEqual("Category", desc2.PropertyName);
            Assert.AreEqual("parent_id", desc2.ColumnName);
        }
Ejemplo n.º 28
0
        private void FillClassProperties(ActiveRecordDescriptor descriptor)
        {
            listView1.Items.Clear();

            IList added = new ArrayList();

            foreach (ActiveRecordPropertyDescriptor prop in descriptor.Properties)
            {
                ListViewItem item = listView1.Items.Add(prop.PropertyName);
                item.Tag     = prop;
                item.Checked = prop.Generate;
                item.SubItems.Add(prop.PropertyType.ToString());
                item.SubItems.Add(prop.ColumnName);
                item.SubItems.Add(prop.ColumnTypeName);
                item.SubItems.Add((prop is ActiveRecordPrimaryKeyDescriptor) ? "Yes" : "");

                added.Add(prop);
            }

            if (descriptor is ActiveRecordDescriptorSubClass)
            {
                // This code might look strange, but we're
                // only showing the fields on the parent class that haven't been
                // marked for generation, so the user might have the
                // oportunity to add them

                foreach (ActiveRecordPropertyDescriptor prop in _parent.Properties)
                {
                    if (prop.Generate || added.Contains(prop))
                    {
                        continue;
                    }

                    ListViewItem item = listView1.Items.Add(prop.PropertyName);
                    item.Tag     = prop;
                    item.Checked = prop.Generate;
                    item.SubItems.Add(prop.PropertyType.ToString());
                    item.SubItems.Add(prop.ColumnName);
                    item.SubItems.Add(prop.ColumnTypeName);
                    item.SubItems.Add((prop is ActiveRecordPrimaryKeyDescriptor) ? "Yes" : "");
                }
            }
        }
Ejemplo n.º 29
0
        public RelationshipInfo(AssociationEnum association, ActiveRecordDescriptor descriptor, ActiveRecordDescriptor targetDescriptor)
        {
            if (association == AssociationEnum.Undefined)
            {
                throw new ArgumentException("association");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            if (targetDescriptor == null)
            {
                throw new ArgumentNullException("targetDescriptor");
            }

            this.association      = association;
            this.descriptor       = descriptor;
            this.targetDescriptor = targetDescriptor;
        }
Ejemplo n.º 30
0
        public NewARClassWizard(Model model) : base(model)
        {
//			if (shape.ActiveRecordDescriptor == null)
//			{
//				throw new ArgumentException("No AR instance in shape");
//			}

            _arDesc           = new ActiveRecordDescriptor();
            Context["ardesc"] = _arDesc;

            InitializeComponent();

            Title = "New ActiveRecord class";

            AddPage(new WelcomePage());
            AddPage(new TableSelectionPage());
            AddPage(new MappingPage());
            AddPage(new RelationsPage());
            AddPage(new ClassNamePage());
        }