void ImportEnums(List <TypeDefinition> enums) { foreach (var @enum in enums) { var entity = ToEnumEntity(@enum); if (entity != null) { database.Add(entity); } } }
private uFrameDatabaseConfig GetConfig(TypeDatabase db, string title) { var config = db.GetSingle <uFrameDatabaseConfig>(); if (config == null) { config = new uFrameDatabaseConfig { CodeOutputPath = "Assets/Code", Namespace = title, BuildVersion = uFrameVersion.BuildVersion, MajorVersion = uFrameVersion.MajorVersion, MinorVersion = uFrameVersion.MinorVersion, }; db.Add(config); db.Commit(); } config.Database = db; config.Title = title; if (!Configurations.ContainsKey(config.Identifier)) { Configurations.Add(config.Identifier, config); } return(config); }
public void RoundTripStruct() { ModuleDeclaration module = ReflectToModules("public struct Foo {\npublic var x:Int\n } ", "SomeModule").Find(m => m.Name == "SomeModule"); StructDeclaration fooClass = module.AllStructs.Where(cl => cl.Name == "Foo").FirstOrDefault(); Assert.IsNotNull(fooClass); StructDeclaration unrootedFoo = fooClass.MakeUnrooted() as StructDeclaration; Entity entity = new Entity { SharpNamespace = "SomeModule", SharpTypeName = "Foo", Type = unrootedFoo }; TypeDatabase db = new TypeDatabase(); db.Add(entity); MemoryStream ostm = new MemoryStream(); db.Write(ostm, "SomeModule"); ostm.Seek(0, SeekOrigin.Begin); TypeDatabase dbread = new TypeDatabase(); var errors = dbread.Read(ostm); Utils.CheckErrors(errors); Entity entityRead = dbread.EntityForSwiftName("SomeModule.Foo"); Assert.IsNotNull(entityRead); Assert.AreEqual(entity.SharpNamespace, entityRead.SharpNamespace); Assert.AreEqual(entity.SharpTypeName, entityRead.SharpTypeName); Assert.IsTrue(entity.Type is StructDeclaration); }