public static void Main(String[] args) { Console.WriteLine("start"); ExpComp.Clear(); Scanner scanner = new Scanner("D:\\temp\\1.exp"); ExpComp.parser = new Parser(scanner); ExpComp.parser.Parse(); // foreach (DataFrame frame in ExpComp.dataFrames.Values) { // Console.WriteLine(frame.ToString()); // } IModelBuilder modelBuilder = ModelBuilderFactory.getInstance().createBuilder(ModelBuilderFactory.KIF); converters.Converter converter = new converters.Converter(modelBuilder); IModel model = converter.convert(ExpComp.dataFrames.Values); SimpleKifFormatter formatter = new SimpleKifFormatter(); formatter.write(model, Console.Out); // model.store(Console.Out); /* * string text = IOUtils.readText("d:\\test\\t.txt"); * Console.WriteLine(text); * DependenciesManager dependenciesManager = new DependenciesManager("d:\\test\\t.txt"); * dependenciesManager.print(); */ Console.ReadKey(); }
public SqlServerDataStoreServices( [NotNull] SqlServerDataStore store, [NotNull] SqlServerDataStoreCreator creator, [NotNull] SqlServerConnection connection, [NotNull] SqlServerValueGeneratorCache valueGeneratorCache, [NotNull] SqlServerDatabase database, [NotNull] ModelBuilderFactory modelBuilderFactory, [NotNull] SqlServerMigrator migrator) { Check.NotNull(store, "store"); Check.NotNull(creator, "creator"); Check.NotNull(connection, "connection"); Check.NotNull(valueGeneratorCache, "valueGeneratorCache"); Check.NotNull(database, "database"); Check.NotNull(modelBuilderFactory, "modelBuilderFactory"); Check.NotNull(migrator, "migrator"); _store = store; _creator = creator; _connection = connection; _valueGeneratorCache = valueGeneratorCache; _database = database; _modelBuilderFactory = modelBuilderFactory; _migrator = migrator; }
private static IModel BuildModel() { var builder = new ModelBuilderFactory().CreateConventionBuilder(); builder.Entity <Product>(b => { b.Reference(e => e.AlternateProduct).InverseReference(e => e.OriginalProduct) .ForeignKey <Product>(e => e.AlternateProductId); b.Reference(e => e.Detail).InverseReference(e => e.Product) .ForeignKey <ProductDetail>(e => e.Id); }); builder.Entity <Category>().Collection(e => e.Products).InverseReference(e => e.Category); builder.Entity <ProductDetail>(); builder.Entity <ProductPhoto>(b => { b.Key(e => new { e.ProductId, e.PhotoId }); b.Collection(e => e.ProductTags).InverseReference(e => e.Photo) .ForeignKey(e => new { e.ProductId, e.PhotoId }); }); builder.Entity <ProductReview>(b => { b.Key(e => new { e.ProductId, e.ReviewId }); b.Collection(e => e.ProductTags).InverseReference(e => e.Review) .ForeignKey(e => new { e.ProductId, e.ReviewId }); }); builder.Entity <ProductTag>(); return(builder.Model); }
private void Test(Action <ModelBuilder> buildModel, string expectedCode, Action <IModel> assert) { var modelBuilder = new ModelBuilderFactory().CreateConventionBuilder(); buildModel(modelBuilder); var model = modelBuilder.Model; var generator = new CSharpModelGenerator(new CSharpHelper()); var builder = new IndentedStringBuilder(); generator.Generate(model, builder); var code = builder.ToString(); Assert.Equal(expectedCode, code); var build = new BuildSource { References = { BuildReference.ByName("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), BuildReference.ByName("System.Linq.Expressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), BuildReference.ByName("System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), BuildReference.ByName("EntityFramework.Core"), BuildReference.ByName("EntityFramework.Relational"), }, Sources = { @" using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; using Microsoft.Data.Entity.Metadata.ModelConventions; using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; public static class ModelSnapshot { public static IModel Model { get { var builder = new ModelBuilder(new ConventionSet()); " + code + @" return builder.Model; } } } " } }; var assembly = build.BuildInMemory(); var factoryType = assembly.GetType("ModelSnapshot"); var property = factoryType.GetProperty("Model"); var value = (IModel)property.GetValue(null); Assert.NotNull(value); assert(value); }
private static Model CreateModel() { var model = new Model(); var modelBuilder = new ModelBuilderFactory().CreateConventionBuilder(model); modelBuilder.Entity <Customer>(); return(model); }
public FakeDataStoreServices( FakeDataStore store, RecordingDataStoreCreator creator, FakeRelationalConnection connection, FakeValueGeneratorCache valueGeneratorCache, FakeDatabase database, ModelBuilderFactory modelBuilderFactory, TestMigrator migrator) { _store = store; _creator = creator; _connection = connection; _valueGeneratorCache = valueGeneratorCache; _database = database; _modelBuilderFactory = modelBuilderFactory; _migrator = migrator; }
private string[] CONVERTER_TYPES = { ModelBuilderFactory.KIF, ModelBuilderFactory.ONTOLINGUA };//TODO: private void okButtonClick(object sender, EventArgs e) { //TODO: validate(); string fileName = _outputPathField.Text; string converterType = CONVERTER_TYPES[_outputFormatBox.SelectedIndex]; // IConverter converter = ConverterFactory.getInstance().getConverter(converterType); //TODO: ask rewrite if exists IOUtils.createOrRewriteFile(fileName); /* IWriter writer = WriterFactory.createFileWriter(fileName); * writer.open();*/ StreamWriter writer = new StreamWriter(fileName); IModelBuilder modelBuilder = ModelBuilderFactory.getInstance().createBuilder(converterType); converters.Converter converter = new converters.Converter(modelBuilder); IModel model = converter.convert(ExpComp.dataFrames.Values); SimpleKifFormatter formatter = new SimpleKifFormatter(); formatter.write(model, writer); // ICollection<Object> convertedItems = converter.convert(getSourceModel()); // writer.write(convertedItems); writer.Flush(); writer.Close(); Close(); //ACTION DialogResult reply = MessageBox.Show("Would you like to view generated file?", "Transformation finished", MessageBoxButtons.YesNo, MessageBoxIcon.Question);//TODO: if (reply == DialogResult.Yes) { Window textEditor = _environment.OpenFile(Constants.vsViewKindCode, fileName); textEditor.Visible = true; textEditor.Activate(); } }
protected static Model CreateModel() { var model = new Model(); var modelBuilder = new ModelBuilderFactory().CreateConventionBuilder(model); modelBuilder .Entity <Address>(e => e.HasOne(a => a.Resident).WithOne(p => p.Address)); // TODO: Bug #1116 modelBuilder.Entity <Address>().Property(a => a.Id).GenerateValueOnAdd(false); modelBuilder.Entity <Address2>().Property <int>("PersonId"); modelBuilder .Entity <Person2>( e => e.HasOne(p => p.Address).WithOne(a => a.Resident) .ForeignKey(typeof(Address2), "PersonId")); return(model); }
/// <summary> /// This Operation is called, when the module shall initialize itself. /// </summary> /// <param name="typeRegistry">The type registry for service requests or registrations.</param> /// <inheritdoc/> public void Initialize(ITypeRegistry typeRegistry) { var odataObjectFactory = new ODataObjectFactory(); var pathService = new ODataPathService(); var modelItemNamingService = new ModelItemNamingService(); var navigationPropertyBuilderFactory = new NavigationPropertyBuilderFactory(modelItemNamingService); var modelBuilderFactory = new ModelBuilderFactory(pathService, navigationPropertyBuilderFactory); var queryBuilderFactory = new QueryBuilderFactory(); var operationContextFactory = new OperationContextFactory(pathService); var dataTypeRegistry = new DataTypeRegistry(new DefaultDataTypeKeyLookupStrategy()); typeRegistry.RegisterInstance <IModelBuilderFactory>(modelBuilderFactory); typeRegistry.RegisterInstance <IDataTypeRegistry>(dataTypeRegistry); typeRegistry.RegisterInstance <IODataObjectFactory>(odataObjectFactory); typeRegistry.RegisterInstance <IODataPathService>(pathService); typeRegistry.RegisterInstance <IOperationContextFactory>(operationContextFactory); typeRegistry.RegisterInstance <IModelItemNamingService>(modelItemNamingService); typeRegistry.RegisterInstance <IQueryBuilderFactory>(queryBuilderFactory); }
public SQLiteDataStoreServices( [NotNull] SQLiteDataStore store, [NotNull] SQLiteDataStoreCreator creator, [NotNull] SQLiteConnection connection, [NotNull] SQLiteValueGeneratorCache valueGeneratorCache, [NotNull] RelationalDatabase database, [NotNull] ModelBuilderFactory modelBuilderFactory) { Check.NotNull(store, "store"); Check.NotNull(creator, "creator"); Check.NotNull(connection, "connection"); Check.NotNull(valueGeneratorCache, "valueGeneratorCache"); Check.NotNull(database, "database"); Check.NotNull(modelBuilderFactory, "modelBuilderFactory"); _store = store; _creator = creator; _connection = connection; _valueGeneratorCache = valueGeneratorCache; _database = database; _modelBuilderFactory = modelBuilderFactory; }
private static IModel BuildModel() { var model = new Model(); var builder = new ModelBuilderFactory().CreateConventionBuilder(model); builder.Entity <Product>(b => { b.HasOne(e => e.AlternateProduct).WithOne(e => e.OriginalProduct) .ForeignKey <Product>(e => e.AlternateProductId); b.HasOne(e => e.Detail).WithOne(e => e.Product) .ForeignKey <ProductDetail>(e => e.Id); }); builder.Entity <Category>().HasMany(e => e.Products).WithOne(e => e.Category); builder.Entity <ProductDetail>(); builder.Entity <ProductPhoto>(b => { b.Key(e => new { e.ProductId, e.PhotoId }); b.HasMany(e => e.ProductTags).WithOne(e => e.Photo) .ForeignKey(e => new { e.ProductId, e.PhotoId }); }); builder.Entity <ProductReview>(b => { b.Key(e => new { e.ProductId, e.ReviewId }); b.HasMany(e => e.ProductTags).WithOne(e => e.Review) .ForeignKey(e => new { e.ProductId, e.ReviewId }); }); builder.Entity <ProductTag>(); return(model); }
private void Test(Action<ModelBuilder> buildModel, string expectedCode, Action<IModel> assert) { var modelBuilder = new ModelBuilderFactory().CreateConventionBuilder(); buildModel(modelBuilder); var model = modelBuilder.Model; var generator = new CSharpModelGenerator(new CSharpHelper()); var builder = new IndentedStringBuilder(); generator.Generate(model, builder); var code = builder.ToString(); Assert.Equal(expectedCode, code); var build = new BuildSource { References = { BuildReference.ByName("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), BuildReference.ByName("System.Linq.Expressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), BuildReference.ByName("System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), BuildReference.ByName("EntityFramework.Core"), BuildReference.ByName("EntityFramework.Relational"), }, Sources = { @" using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; using Microsoft.Data.Entity.Metadata.ModelConventions; using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; public static class ModelSnapshot { public static IModel Model { get { var builder = new ModelBuilder(new ConventionSet()); " + code + @" return builder.Model; } } } " } }; var assembly = build.BuildInMemory(); var factoryType = assembly.GetType("ModelSnapshot"); var property = factoryType.GetProperty("Model"); var value = (IModel)property.GetValue(null); Assert.NotNull(value); assert(value); }