public IScriptGenerator ExecuteCompiler(IScriptCompiler compiler) { _generator = compiler.Compile(this); _compiled = true; return(_generator); }
public IScriptGenerator ExecuteCompiler( IScriptCompiler compiler ) { _generator = compiler.Compile( this ); _compiled = true; return _generator; }
public static bool GenerateScript(string folderPath, string filename, IScriptGenerator generator) { try { string path = folderPath + Path.AltDirectorySeparatorChar + filename; if (!File.Exists(path)) { using (var streamW = new StreamWriter(path)) { generator.Generate(streamW); } AssetDatabase.Refresh(); return(true); } else { Debug.LogError("Script with the same name already exists at path " + path); } } catch (Exception e) { Debug.LogException(e); } return(false); }
public Form1(IScriptGenerator scriptGenerator) { InitializeComponent(); LoadConstants(); this.scriptGenerator = scriptGenerator; }
public ScriptsGenerator( [NotNull] IGenerateOptions options, [NotNull] IPathService pathService, [NotNull] IScriptGenerator scriptGenerator) { _options = options ?? throw new ArgumentNullException(nameof(options)); _pathService = pathService ?? throw new ArgumentNullException(nameof(pathService)); _scriptGenerator = scriptGenerator ?? throw new ArgumentNullException(nameof(scriptGenerator)); }
public Program( IMapStore mapStore, IScriptStore scriptStore, IScriptGenerator scriptGenerator, IScriptPostprocessor scriptPostprocessor) { _mapStore = Guard.NotNull(mapStore, "mapStore"); _scriptStore = Guard.NotNull(scriptStore, "scriptStore"); _scriptGenerator = Guard.NotNull(scriptGenerator, "scriptGenerator"); _scriptPostprocessor = Guard.NotNull(scriptPostprocessor, "scriptPostprocessor"); }
public BaseRepository(DatabaseType dbType, string ConnectionString) { DB = InitDB(dbType, ConnectionString); ScriptGenerator = InitScriptGenerator(dbType); DBEntityMetadataAttribute attrib = Reflect.GetEntityMetadata(typeof(T)); _tableName = attrib.TableName; _default_sortExpression = attrib.DefaultSort; _IDColumn = attrib.KeyName; _autoIncrement = attrib.AutoIncrementKey; }
new public void FileInsertNewSingleFileScript(string filename, string file) { CSScriptFile csfile = new CSScriptFile(filename, file); SingleFileScriptPackage package = new SingleFileScriptPackage(csfile); IScriptGenerator generator = package.ExecuteCompiler(new SingleFileProjectCompiler()); ArrayList simulators = MetaverseController.Singleton.GetSimulators(); ISim sim = (ISim)simulators[0]; SimController.Singleton.InsertScript(sim, generator.Generate()); return; }
private IScriptGenerator InitScriptGenerator(DatabaseType dbType) { IScriptGenerator scriptManager = null; switch (dbType) { //case DatabaseType.SQLite: // scriptManager = new DBHelper.SQLite.ScriptGenerator(); // break; case DatabaseType.SQLServer: scriptManager = new DBHelper.SQLServer.ScriptGenerator(); break; } return(scriptManager); }
static DomElement ProcessChildren(DomElement result, DomElement input, IScriptGenerator gen) { // TODO ToArray() is wasteful (performance) foreach (var m in input.ChildNodes.ToArray()) { var conv = HxlCompilerConverter.ChooseConverter(m); conv.ConvertAndAppend(result, m, gen); } foreach (var m in input.Attributes.ToArray()) { var conv = HxlCompilerConverter.ChooseConverter(m); conv.ConvertAndAppend(result, m, gen); } return(result); }
public void ConvertAndAppend(DomNode parent, DomObject m, IScriptGenerator gen) { var child = Convert(m, gen); if (child == null) { return; } if (object.ReferenceEquals(child, m)) { parent.Append(child); } else { parent.Append(child); } }
static void Main(string[] args) { ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType <UserTextFileRepository>().As <IUserRepository>(); builder.RegisterType <UserValueLineGenerator>().As <IValueLineGenerator <User> >(); builder.RegisterType <ScriptGenerator <User> >().As <IScriptGenerator <User> >(); builder.RegisterType <BusinessCardTextFileRepository>().As <IBusinessCardRepository>(); builder.RegisterType <BusinessCardValueLineGenerator>().As <IValueLineGenerator <BusinessCard> >(); builder.RegisterType <ScriptGenerator <BusinessCard> >().As <IScriptGenerator <BusinessCard> >(); IContainer container = builder.Build(); IScriptGenerator <User> userScriptGen = container.Resolve <IScriptGenerator <User> >(); IScriptGenerator <BusinessCard> cardScriptGen = container.Resolve <IScriptGenerator <BusinessCard> >(); Console.WriteLine("Generated entity model and value line for User class: "); var user = userScriptGen.GetEntityModel(); Console.WriteLine(userScriptGen.GetValueLine(user)); Console.WriteLine("Generated script for User class: "); Console.WriteLine(userScriptGen.GenerateScript(20)); Console.WriteLine("//////////////////////////////////////////////"); Console.WriteLine("//////////////////////////////////////////////"); Console.WriteLine("//////////////////////////////////////////////"); Console.WriteLine("Generated entity model and value line for BusinessCard class: "); var card = cardScriptGen.GetEntityModel(); Console.WriteLine(cardScriptGen.GetValueLine(card)); Console.WriteLine("Generated script for User class: "); Console.WriteLine(cardScriptGen.GenerateScript(20)); Console.ReadKey(); }
public void Setup() { generator = new ScriptGenerator <BusinessCard>(new BusinessCardValueLineGeneratorMock()); }
public void Run(string rootPath, EFCore.Extensions.IDbContext context, IScriptGenerator scriptProvider) { var modelPath = Path.Combine(rootPath, "Models"); var initializePath = Path.Combine(rootPath, "1_Initialize"); var scriptPath = Path.Combine(rootPath, "2_Migrations"); var createPath = Path.Combine(rootPath, "3_Create"); var customScriptPath = Path.Combine(rootPath, "4_Programmability"); var finializeScriptPath = Path.Combine(rootPath, "5_Finalize"); if (!Directory.Exists(modelPath)) { Directory.CreateDirectory(modelPath); } if (!Directory.Exists(initializePath)) { Directory.CreateDirectory(initializePath); } if (!Directory.Exists(scriptPath)) { Directory.CreateDirectory(scriptPath); } if (!Directory.Exists(createPath)) { Directory.CreateDirectory(createPath); } if (!Directory.Exists(customScriptPath)) { Directory.CreateDirectory(customScriptPath); } if (!Directory.Exists(finializeScriptPath)) { Directory.CreateDirectory(finializeScriptPath); } EnsureReadme(initializePath, true); EnsureReadme(scriptPath); EnsureReadme(createPath); EnsureReadme(customScriptPath, true); EnsureReadme(finializeScriptPath, true); //Create SQL generation object var sqlCreate = scriptProvider.GenerateCreateScript(); File.WriteAllText(Path.Combine(createPath, "Create.sql"), sqlCreate); //Load version file var versionFile = Path.Combine(modelPath, "version.json"); var oldVersion = new Versioning(); if (File.Exists(versionFile)) { oldVersion = ScriptingExtensions.FromJson <Versioning>(File.ReadAllText(versionFile)); } var newVersion = new Versioning(oldVersion.ToString()); newVersion.Increment(); File.WriteAllText(versionFile, newVersion.ToJson()); //Load last model (if one) DataModel oldModel = null; var oldVersionFile = Path.Combine(modelPath, oldVersion.GetDiffFileName()) + ".model"; if (File.Exists(oldVersionFile)) { oldModel = ScriptingExtensions.FromJson <DataModel>(File.ReadAllText(oldVersionFile)); } //Diff Script if (oldModel != null) { var sqlDiff = scriptProvider.GenerateDiffScript(oldModel, newVersion); File.WriteAllText(Path.Combine(scriptPath, newVersion.GetDiffFileName() + ".sql"), sqlDiff); } //Write model to installer project var modelJson = scriptProvider.Model.ToJson(); File.WriteAllText(Path.Combine(modelPath, newVersion.GetDiffFileName()) + ".model", modelJson); }
public void Init() { _generator = null; }
protected override DomNode Convert(DomDocument document, DomElement element, IScriptGenerator gen) { var lang = ((HxlLangElement)element); var result = lang.ToIsland(gen); ProcessChildren(result, element, gen); lang.RewriteIslandChildren(result); return(result); }
public void Init() { IRepository repository = new RepositoryMock(); _generator = new ScriptGenerator(repository); }
public void Init() { _generator = new ScriptGenerator(new RepositoryMock()); }
internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen) { return(new HxlRenderWorkElement(gen.Start(this), gen.End(this))); }
// - Element is an ElementFragment protected override DomNode Convert(DomDocument document, DomElement element, IScriptGenerator gen) { // TODO This will not work if expressions are in non-string types var myValues = element.Attributes.Select(t => new KeyValuePair <string, object>(t.Name, t.Value)); // Locate the property handling inner text // TODO Using inner text (but it could contain markup, which would technically require special handling logic) // TODO Memoize this lookup (performance) foreach (PropertyInfo p in Utility.ReflectGetProperties(element.GetType())) { if (p.IsDefined(typeof(ValueAttribute))) { var kvp = new KeyValuePair <string, object>(p.Name, element.InnerText); myValues = Utility.Cons(kvp, myValues); } } Activation.Initialize(element, myValues); return(element); }
public abstract DomObject Convert(DomObject node, IScriptGenerator gen);
protected abstract DomNode Convert(DomDocument document, DomElement element, IScriptGenerator gen);
public sealed override DomObject Convert(DomObject node, IScriptGenerator gen) { return(Convert(node.OwnerDocument, (DomElement)node, gen)); }
public ScriptWriter(IScriptGenerator generator) { _generator = generator; }
public sealed override DomObject Convert(DomObject node, IScriptGenerator gen) { return(Convert(node.OwnerDocument, (DomProcessingInstruction)node)); }
// - Element is NOT an ElementFragment // - Element contains no AttributeFragments // - Element has no children OR has descendents which are all marked as inlining public override DomObject Convert(DomObject node, IScriptGenerator gen) { return(InlineOuterText(node.OwnerDocument, node)); }
internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen) { throw new NotImplementedException(); }
public override DomObject Convert(DomObject node, IScriptGenerator gen) { return(node); }
internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen) { return(BindConditional(Test, false)); }
public EmberHttpHandler() { _generator = new EmberScriptGenerator(); }
internal abstract HxlRenderWorkElement ToIsland(IScriptGenerator gen);
// Just process children protected override DomNode Convert(DomDocument document, DomElement element, IScriptGenerator gen) { var e = document.CreateElement(element.Name); // Copy annotations to the new element e.AddAnnotations(element.Annotations <object>().Except(HxlAnnotations.Retained)); return(ProcessChildren(e, element, gen)); }