Beispiel #1
0
        private void enumEntitiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConnectionInfo connection = ActiveConnectionInfo;

            if (connection == null)
            {
                return; // should we try to connect?
            }
            string errorMsg;

            try
            {
                EntityClassGraph entityClassGraph = new EntityClassGraph(connection.Connection);

                EntityClassGraphForm form = new EntityClassGraphForm(entityClassGraph);
                form.Show(this);
                return;
            }
            catch (FaultException <InfoServiceFaultContract> ex)
            {
                log.Error("Failed to connect", ex);
                errorMsg = ex.Detail.Message;
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            if (errorMsg != null)
            {
                errorMsg = string.Format("Unable to connect to generate entity graph. {0}", errorMsg);
                MessageBox.Show(this, errorMsg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadTree(EntityClassGraph entityClassGraph)
        {
            entityClassGraphTreeView.Nodes.Clear();

            if (entityClassGraph.Root == null)
            {
                return;
            }

            Stack <KeyValuePair <EntityMetadata, TreeNode> > baseClasses = new Stack <KeyValuePair <EntityMetadata, TreeNode> >();

            //Add the root node.
            TreeNode node = entityClassGraphTreeView.Nodes.Add(entityClassGraph.Root.FullName, entityClassGraph.Root.FullName, 3);

            baseClasses.Push(new KeyValuePair <EntityMetadata, TreeNode>(entityClassGraph.Root, node));

            foreach (EntityMetadata decendent in entityClassGraph.Root.Descendants)
            {
                //Find the base class that we belong to.  Since the enumeration is pre-fix order, then we can find it as
                //an ancestor of us.
                while (!decendent.BaseClass.Equals(baseClasses.Peek().Key))
                {
                    baseClasses.Pop();
                }

                //Add this child node.
                node = baseClasses.Peek().Value.Nodes.Add(decendent.FullName, decendent.FullName, 3);
                baseClasses.Push(new KeyValuePair <EntityMetadata, TreeNode>(decendent, node));
            }
        }
        private void LoadTree(EntityClassGraph entityClassGraph)
        {
            entityClassGraphTreeView.Nodes.Clear();

            if (entityClassGraph.Root == null)
                return;

            Stack<KeyValuePair<EntityMetadata, TreeNode>> baseClasses = new Stack<KeyValuePair<EntityMetadata, TreeNode>>();
            
            //Add the root node.
            TreeNode node = entityClassGraphTreeView.Nodes.Add(entityClassGraph.Root.FullName, entityClassGraph.Root.FullName, 3);
            baseClasses.Push(new KeyValuePair<EntityMetadata, TreeNode>(entityClassGraph.Root, node));

            foreach (EntityMetadata decendent in entityClassGraph.Root.Descendants)
            {
                //Find the base class that we belong to.  Since the enumeration is pre-fix order, then we can find it as 
                //an ancestor of us.
                while (!decendent.BaseClass.Equals(baseClasses.Peek().Key))
                {
                    baseClasses.Pop();
                }

                //Add this child node.
                node = baseClasses.Peek().Value.Nodes.Add(decendent.FullName, decendent.FullName, 3);
                baseClasses.Push(new KeyValuePair<EntityMetadata, TreeNode>(decendent, node));
            }
        }
        public EntityClassGraphForm(EntityClassGraph entityClassGraph)
        {
            InitializeComponent();

            LoadTree(entityClassGraph);

            //The user will want to always expand the System.Entity node, so let's do it for them.
            entityClassGraphTreeView.Nodes[0].Expand();
        }
        public EntityClassGraphForm(EntityClassGraph entityClassGraph)
        {
            InitializeComponent();

            LoadTree(entityClassGraph);

            //The user will want to always expand the System.Entity node, so let's do it for them.
            entityClassGraphTreeView.Nodes[0].Expand();
        }
Beispiel #6
0
        private void enumEntitiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConnectionInfo connection = ActiveConnectionInfo;
            if (connection == null)
                return; // should we try to connect?

            string errorMsg;

            try
            {
                EntityClassGraph entityClassGraph = new EntityClassGraph(connection.Connection);

                EntityClassGraphForm form = new EntityClassGraphForm(entityClassGraph);
                form.Show(this);
                return;
            }
            catch (FaultException<InfoServiceFaultContract> ex)
            {
                log.Error("Failed to connect", ex);
                errorMsg = ex.Detail.Message;
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            if (errorMsg != null)
            {
                errorMsg = string.Format("Unable to connect to generate entity graph. {0}", errorMsg);
                MessageBox.Show(this, errorMsg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }