private List <EntityStorage> InitTypes()
        {
            List <EntityStorage> output = new List <EntityStorage>();

            foreach (var storage in _generatorManager.GetRequiredResources().OfType <EntityStorage>())
            {
                var modeledStorage = _generatorManager.GetGenerable()
                                     .Files.OfType <Modelable>()
                                     .FirstOrDefault(x => x.Key.Equals(storage.Name));
                var adapter = new StorageInterfaceAdapter(GetInstanceFromGenerator(modeledStorage));
                _storages.Add(adapter, new Dictionary <EntitySet, EntityFactory>());
                foreach (var entitySet in storage.EntitySets)
                {
                    var entity        = _prototype.Entities.Single(x => x.Name == entitySet.EntityName);
                    var modeledEntity = _generatorManager.GetGenerable()
                                        .Files.OfType <Modelable>()
                                        .FirstOrDefault(x => x.Key.Equals(entity.Name));
                    _storages[adapter].Add(entitySet, new EntityFactory(
                                               entity,
                                               GetTypeFromGenerator(modeledEntity),
                                               entitySet,
                                               storage,
                                               Utils.FindAllInstances <LoadEntitiesFromEntityStorage>(_prototype).Where(x => x.EntitySetName == entitySet.Name && x.EntityStorageName == storage.Name && x.EntityName == entity.Name).ToList()));
                    output.Add(storage);
                }
            }

            return(output);
        }
Example #2
0
        /// <summary>
        /// Generates and build prototype with resources informations within.
        /// </summary>
        public void Generate()
        {
            _dataLayer = new DataLayerManager(_configProvider, _prototype);

            Type data =
                Utils.LoadTypes(AppDomain.CurrentDomain.BaseDirectory)
                .Where(y => !y.IsAbstract && y.GetInterfaces().Contains(typeof(IBuilder)))
                .FirstOrDefault(type => ((IBuilder)Activator.CreateInstance(type)).IsPlatformSupported(_dataLayer.Platform));

            if (data == null)
            {
                throw new ArgumentException("Data cannot be prepared.");
            }
            _dataLayerBuilder = (IBuilder)Activator.CreateInstance(data);


            _prototypeGenerator.Generate(_dataLayer.GetGenerable(), _configProvider);
            _dataLayerBuilder.Build(_configProvider, _dataLayer);

            var supportedStorages = _entityGenerator.Setup(_prototype, _dataLayer, _configProvider);

            _entityGenerator.Generate();
            _dataLayer.Dispose();
            CleanOutput();

            GenerateApplications();
            BuildApplications();
        }