internal static void GetEntityCollectionDefaults(
			bool topLevelLazy,
			ArchAngel.Interfaces.NHibernateEnums.TopLevelCascadeTypes topLevelCascade,
			ArchAngel.Interfaces.NHibernateEnums.TopLevelAccessTypes topLevelAccess,
			Entity entity,
			out CollectionLazyTypes entityDefaultLazy,
			out CascadeTypes entityDefaultCascade,
			out PropertyAccessTypes entityDefaultAccess)
        {
            entityDefaultLazy = entity.GetEntityDefaultCollectionLazy();

            if (entityDefaultLazy == CollectionLazyTypes.inherit_default)
            {
                if (topLevelLazy) entityDefaultLazy = CollectionLazyTypes.@true;
                else entityDefaultLazy = CollectionLazyTypes.@false;
            }
            entityDefaultCascade = entity.GetEntityDefaultCascade();

            if (entityDefaultCascade == CascadeTypes.inherit_default)
                entityDefaultCascade = (CascadeTypes)Enum.Parse(typeof(CascadeTypes), topLevelCascade.ToString(), false);

            entityDefaultAccess = entity.GetEntityDefaultAccess();

            if (entityDefaultAccess == PropertyAccessTypes.inherit_default)
                entityDefaultAccess = (PropertyAccessTypes)Enum.Parse(typeof(PropertyAccessTypes), topLevelAccess.ToString(), false);
        }
Exemple #2
0
        private void PopulateTestCrumbBar(ArchAngel.Interfaces.Template.IteratorTypes iteratorType)
        {
            try
            {
                BusyPopulatingCrumbBarTest = true;
                crumbBarTestObjects.Items.Clear();
                crumbBarTestObjects.Enabled = true;
                DevComponents.DotNetBar.CrumbBarItem rootItem = new DevComponents.DotNetBar.CrumbBarItem();
                rootItem.Text = "Project";
                rootItem.ImageIndex = (int)CrumbBarImages.Project;
                crumbBarTestObjects.Items.Add(rootItem);

                switch (iteratorType)
                {
                    case ArchAngel.Interfaces.Template.IteratorTypes.Entity:

                        foreach (var entity in ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.Entities)
                        {
                            DevComponents.DotNetBar.CrumbBarItem item = new DevComponents.DotNetBar.CrumbBarItem();
                            item.Text = entity.Name;
                            item.Tag = entity;
                            item.ImageIndex = (int)CrumbBarImages.Entity;
                            rootItem.SubItems.Add(item);
                        }
                        if (rootItem.SubItems.Count > 0)
                            crumbBarTestObjects.SelectedItem = (DevComponents.DotNetBar.CrumbBarItem)rootItem.SubItems[0];
                        else
                            crumbBarTestObjects.SelectedItem = rootItem;
                        break;
                    case ArchAngel.Interfaces.Template.IteratorTypes.Component:

                        foreach (var component in ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.Components)
                        {
                            DevComponents.DotNetBar.CrumbBarItem item = new DevComponents.DotNetBar.CrumbBarItem();
                            item.Text = component.Name;
                            item.Tag = component;
                            item.ImageIndex = (int)CrumbBarImages.Component;
                            rootItem.SubItems.Add(item);
                        }
                        if (rootItem.SubItems.Count > 0)
                            crumbBarTestObjects.SelectedItem = (DevComponents.DotNetBar.CrumbBarItem)rootItem.SubItems[0];
                        else
                            crumbBarTestObjects.SelectedItem = rootItem;
                        break;
                    case ArchAngel.Interfaces.Template.IteratorTypes.Table:

                        foreach (var table in ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.Tables)
                        {
                            DevComponents.DotNetBar.CrumbBarItem item = new DevComponents.DotNetBar.CrumbBarItem();
                            item.Text = table.Name;
                            item.Tag = table;
                            item.ImageIndex = (int)CrumbBarImages.Table;
                            rootItem.SubItems.Add(item);
                        }
                        if (rootItem.SubItems.Count > 0)
                            crumbBarTestObjects.SelectedItem = (DevComponents.DotNetBar.CrumbBarItem)rootItem.SubItems[0];
                        else
                            crumbBarTestObjects.SelectedItem = rootItem;
                        break;
                    case ArchAngel.Interfaces.Template.IteratorTypes.Column:

                        foreach (var table in ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.Tables)
                        {
                            DevComponents.DotNetBar.CrumbBarItem tableItem = new DevComponents.DotNetBar.CrumbBarItem();
                            tableItem.Text = table.Name;
                            tableItem.Tag = table;
                            tableItem.ImageIndex = (int)CrumbBarImages.Table;
                            rootItem.SubItems.Add(tableItem);

                            foreach (var column in table.Columns)
                            {
                                DevComponents.DotNetBar.CrumbBarItem columnItem = new DevComponents.DotNetBar.CrumbBarItem();
                                columnItem.Text = table.Name;
                                columnItem.Tag = table;
                                columnItem.ImageIndex = (int)CrumbBarImages.Table;
                                tableItem.SubItems.Add(columnItem);
                            }
                            if (tableItem.SubItems.Count > 0)
                                crumbBarTestObjects.SelectedItem = (DevComponents.DotNetBar.CrumbBarItem)tableItem.SubItems[0];
                            else
                                crumbBarTestObjects.SelectedItem = rootItem;
                        }
                        if (rootItem.SubItems.Count > 0)
                            crumbBarTestObjects.SelectedItem = (DevComponents.DotNetBar.CrumbBarItem)rootItem.SubItems[0];
                        else
                            crumbBarTestObjects.SelectedItem = rootItem;
                        break;
                    default:
                        throw new NotImplementedException("Iterator not handled yet: " + iteratorType.ToString());
                }
                if (LatestTestObjects.ContainsKey(iteratorType) &&
                    LatestTestObjects[iteratorType] != null)
                {
                    object currentObj = LatestTestObjects[iteratorType];
                    bool itemFoundInCollection = false;

                    foreach (DevComponents.DotNetBar.CrumbBarItem item in crumbBarTestObjects.Items)
                    {
                        if (item.Tag == currentObj)
                        {
                            crumbBarTestObjects.SelectedItem = item;
                            itemFoundInCollection = true;
                            break;
                        }
                        else
                        {
                            bool found = false;

                            foreach (DevComponents.DotNetBar.CrumbBarItem subItem in item.SubItems)
                            {
                                if (subItem.Tag == currentObj)
                                {
                                    crumbBarTestObjects.SelectedItem = item;
                                    crumbBarTestObjects.SelectedItem = subItem;
                                    found = true;
                                    itemFoundInCollection = true;
                                    break;
                                }
                            }
                            if (found)
                                break;
                        }
                    }
                    if (!itemFoundInCollection)
                        LatestTestObjects[iteratorType] = false;
                }
            }
            finally
            {
                BusyPopulatingCrumbBarTest = false;
            }
        }