Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task Run()
        {
            // root file path
            var rootFilePath = "src/SDK/Foundation";

            var entities = Config["entities"];

            EntityFactoryGenerator.GenerateEntityFactory(entities, rootFilePath, CompilationContainer);

            // generate entities
            foreach (var entity in entities)
            {
                var entityGroup      = entity["group_id"].GetStringValue().ToPascal();
                var entityNamePascal = entity["_key"].GetStringValue().ToPascal();

                // generate entity enums
                EnumGenerator.GenerateEnums(entity, rootFilePath, entityGroup, entityNamePascal, CompilationContainer);

                // generate entity class
                EntityClassGenerator.GenerateEntityClass(entity, entityNamePascal, rootFilePath, entityGroup, CompilationContainer);

                if (entity["methods"].Any())
                {
                    EntityRepositoryGenerator.GenerateRepository(entity, entityNamePascal, rootFilePath, entityGroup, CompilationContainer);
                }
            }

            await CompilationContainer.Compile();

            CompilationContainer.WriteFiles();
        }
Ejemplo n.º 2
0
        public void Import(Stream input, string path)
        {
            var lookupTable = new FoxLookupTable(GlobalHashNameDictionary);
            var foxFile     = FoxFile.ReadFoxFile(input, lookupTable);

            IEntityReferenceResolver referenceResolver = new EntityReferenceResolver();

            Framework.Tpp.Classes.DataSet dataSet = null;

            // Load each Entity.
            ICollection <Entity> entities = new List <Entity>();

            foreach (var entry in foxFile.Entities)
            {
                var entity = EntityFactory.MakeEntity(entry, entityTypes, unimplementedTypeTable, commandDispatcher, referenceResolver);

                if (entity != null)
                {
                    entities.Add(entity);
                }

                if (!(entity is Framework.Tpp.Classes.DataSet))
                {
                    continue;
                }
                dataSet = entity as Framework.Tpp.Classes.DataSet;
                dataSet.SetPath(path);
            }

            // Call OnLoaded() on the new Entities.
            var autoResetEvent = commandDispatcher.DispatchCommand(new InitializeEntities(dataSet, entities));

            autoResetEvent.WaitOne();

            // Generate new Entity classes.
            foreach (var unimplementedType in unimplementedTypeTable)
            {
                Debug.Log("Generating C# class for type " + unimplementedType.Key);
                EntityClassGenerator.GenerateEntityClass(unimplementedType.Value);
            }
        }