Ejemplo n.º 1
0
        public IScriptGenerator ExecuteCompiler(IScriptCompiler compiler)
        {
            _generator = compiler.Compile(this);
            _compiled  = true;

            return(_generator);
        }
Ejemplo n.º 2
0
        public IScriptGenerator ExecuteCompiler( IScriptCompiler compiler )
        {
            _generator = compiler.Compile( this );
            _compiled = true;

            return _generator;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
 }
Ejemplo n.º 6
0
 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");
 }
Ejemplo n.º 7
0
    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;
    }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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());
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 public void Init()
 {
     _generator = null;
 }
Ejemplo n.º 16
0
            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);
            }
Ejemplo n.º 17
0
        public void Init()
        {
            IRepository repository = new RepositoryMock();

            _generator = new ScriptGenerator(repository);
        }
Ejemplo n.º 18
0
 public void Init()
 {
     _generator = new ScriptGenerator(new RepositoryMock());
 }
Ejemplo n.º 19
0
 internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen)
 {
     return(new HxlRenderWorkElement(gen.Start(this), gen.End(this)));
 }
Ejemplo n.º 20
0
            // - 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);
            }
Ejemplo n.º 21
0
 public abstract DomObject Convert(DomObject node, IScriptGenerator gen);
Ejemplo n.º 22
0
 protected abstract DomNode Convert(DomDocument document, DomElement element, IScriptGenerator gen);
Ejemplo n.º 23
0
 public sealed override DomObject Convert(DomObject node, IScriptGenerator gen)
 {
     return(Convert(node.OwnerDocument, (DomElement)node, gen));
 }
Ejemplo n.º 24
0
 public ScriptWriter(IScriptGenerator generator)
 {
     _generator = generator;
 }
 public sealed override DomObject Convert(DomObject node, IScriptGenerator gen)
 {
     return(Convert(node.OwnerDocument, (DomProcessingInstruction)node));
 }
Ejemplo n.º 26
0
 public ScriptWriter(IScriptGenerator generator)
 {
     _generator = generator;
 }
Ejemplo n.º 27
0
 // - 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));
 }
Ejemplo n.º 28
0
 internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 29
0
 public void Init()
 {
     _generator = new ScriptGenerator(new RepositoryMock());
 }
Ejemplo n.º 30
0
 public override DomObject Convert(DomObject node, IScriptGenerator gen)
 {
     return(node);
 }
Ejemplo n.º 31
0
 internal override HxlRenderWorkElement ToIsland(IScriptGenerator gen)
 {
     return(BindConditional(Test, false));
 }
Ejemplo n.º 32
0
 public EmberHttpHandler()
 {
     _generator = new EmberScriptGenerator();
 }
Ejemplo n.º 33
0
 internal abstract HxlRenderWorkElement ToIsland(IScriptGenerator gen);
Ejemplo n.º 34
0
            // 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));
            }