Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="database"></param>
        public SchemaExplorerEntityProvider(DatabaseSchema database)
        {
            _database = database;

            if (_database != null)
            {
                if (!_database.DeepLoad)
                {
                    _database.DeepLoad = true;
                    _database.Refresh();
                }

                _tables   = _database.Tables;
                _views    = _database.Views;
                _commands = _database.Commands;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="tables"></param>
        /// <param name="views"></param>
        /// <param name="commands"></param>
        public SchemaExplorerEntityProvider(TableSchemaCollection tables, ViewSchemaCollection views, CommandSchemaCollection commands)
        {
            _tables   = tables;
            _views    = views;
            _commands = commands;

            if (_tables != null && _tables.Count > 0)
            {
                _database = _tables[0].Database;
            }
            else if (_views != null && _views.Count > 0)
            {
                _database = _views[0].Database;
            }
            else if (_commands != null && _commands.Count > 0)
            {
                _database = _commands[0].Database;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loop through all the commands and create the command objects.
        /// </summary>
        /// <param name="commands"></param>
        protected virtual void LoadCommands(CommandSchemaCollection commands)
        {
            if (Configuration.Instance.IncludeFunctions && commands != null && commands.Count > 0)
            {
                foreach (CommandSchema command in commands)
                {
                    if (!Configuration.Instance.IncludeRegexIsMatch(command.FullName) || Configuration.Instance.ExcludeRegexIsMatch(command.FullName) || EntityStore.Instance.GetEntity(command.FullName) != null)
                    {
                        Trace.WriteLine(String.Format("Skipping command: '{0}'", command.FullName));
                        Debug.WriteLine(String.Format("Skipping command: '{0}'", command.FullName));

                        EntityStore.Instance.ExcludedEntityCollection.Add(command.FullName, null);
                        continue;
                    }

                    var commandEntity = new CommandEntity(command);
                    EntityStore.Instance.CommandCollection.Add(command.FullName, commandEntity);
                    EntityStore.Instance.EntityCollection.Add(command.FullName, commandEntity);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load all the Entities into the EntityStore.
        /// </summary>
        protected virtual void Initialize(TableSchemaCollection tables, ViewSchemaCollection views, CommandSchemaCollection commands)
        {
            LoadTables(tables);

            LoadViews(views);

            LoadCommands(commands);

            foreach (IEntity entity in EntityStore.Instance.EntityCollection.Values)
            {
                List <IEntity> entities = EntityStore.Instance.EntityCollection.Values.Where(e => e.Name == entity.Name).ToList();
                if (entities.Count > 1)
                {
                    for (int index = 1; index < entities.Count(); index++)
                    {
                        entities[index].AppendNameSuffix(index);
                    }
                }
            }

            // For all entities, Initialize them.
            foreach (IEntity entity in EntityStore.Instance.EntityCollection.Values)
            {
                entity.Initialize();
            }

            foreach (IEntity entity in EntityStore.Instance.EntityCollection.Values)
            {
                entity.ValidateAllMembers();
            }
        }