/// <summary> /// Generates source code files and writes them to disk /// </summary> public void Generate(TemplateGenerationMetadata metadata) { // this is a hack hack hack. Use parameters, lazybones. _metadata = metadata; _parameters = metadata.Parameters; // for source generation we want to split the generated code into separate units (files) CodeCompileUnit interfaceUnit = CreateCodeCompileUnit(); CodeCompileUnit concreteUnit = CreateCodeCompileUnit(); GenerateInterfaceCode(interfaceUnit); GenerateTemplateCode(concreteUnit); SortCodeCompileUnit(concreteUnit); SortCodeCompileUnit(interfaceUnit); var itemOutputPath = ProcessOutputPath(_parameters.ItemOutputPath); var interfaceOutputPath = ProcessOutputPath(_parameters.InterfaceOutputPath); if (itemOutputPath != interfaceOutputPath) { WriteFileWithBackups(itemOutputPath, concreteUnit); WriteFileWithBackups(interfaceOutputPath, interfaceUnit); } else { WriteFileWithBackups(itemOutputPath, interfaceUnit, concreteUnit); } }
public DOTGenerator(GeneratorParameters generatorParameters) { DOTGeneratorOptions options = new DOTGeneratorOptions(); generatorParameters.Populate(options); this.options = options; }
//var generator = GeneratorFactory.Create(DataProviderTypes.PostgreSql); //var metadataProvider = MetadataProviderFactory.Create(MetadataProviderTypes.PostgreSql); //var schema = metadataProvider.Import("User ID=postgres;Password=1234;Host=localhost;Port=5432;Database=TaxService;"); private static void Main(string[] args) { var columns = new[] { new Column() { Name = "column1", Type = new DataType() { Name = "INTEGER" } }, new Column() { Name = "column2", Type = new DataType() { Name = "VARCHAR", Length = 2000 } } }; var parameters = new[] { new Parameter() { Name = "p_column1", Type = new DataType() { Name = "INTEGER" } }, new Parameter() { Name = "p_column2", Type = new DataType() { Name = "VARCHAR", Length = 2000 } } }; var table = new Table() { Name = "tableName", Columns = columns }; var generatorParameters = new GeneratorParameters() { Name = "test_procedure", Columns = table.Columns, Parameters = parameters, TableName = "test_table_name", FilterColumns = new[] { columns[0] }, FilterParameters = new[] { new Parameter() { Name = "p_column3", Type = new DataType() { Name = "INTEGER" } } } }; var serializer = new XmlSerializer(typeof(Table)); serializer.Serialize(Console.Out, table); Console.WriteLine("\r\n"); var generator = GeneratorFactory.Create(DataProviderTypes.Oracle); Console.WriteLine(generator.GenerateProcedureScript(ProcedureActionTypes.Add, generatorParameters)); Console.WriteLine(); Console.WriteLine(generator.GenerateProcedureScript(ProcedureActionTypes.Modify, generatorParameters)); Console.WriteLine(); Console.WriteLine(generator.GenerateProcedureScript(ProcedureActionTypes.Remove, generatorParameters)); }
/// <summary> /// Calculates castling moves. /// </summary> /// <param name="generatorParameters">The generator parameters.</param> private void CalculateCastling(GeneratorParameters generatorParameters) { if ((generatorParameters.Mode & GeneratorMode.CalculateMoves) != 0) { KingMovesGenerator.CalculateCastling(generatorParameters); } }
public virtual void Init(GeneratorParameters parameters) { if (parameters == null) { parameters = new GeneratorParameters(); } Templates = GetTemplateFiles(Options.TemplateDirectory); Logs.AppendLine($"发现Template '{Templates.Count}' 个。"); foreach (var item in parameters) { Parameters.Add(item.Key, item.Value); } var pathBuilder = new GeneratorPathBuilder(Options, Parameters); foreach (var template in Templates) { CodeFileInfos.Add(pathBuilder.Build(template)); } TemplateGenerator = new TemplateGenerator(); TemplateGenerator.Refs.Add(Path.Combine(AppContext.BaseDirectory, "System.CodeDom.dll")); TemplateGenerator.Refs.Add("System.ComponentModel.Primitives.dll"); foreach (var item in Parameters) { TemplateGenerator.TryAddParameter(item.Key + "=" + item.Value); } }
private void InitSmallGenerator() { var firstPeriod = new GeneratorParameters(10, 100, 200, 10, 10, 10); var secondPeriod = new GeneratorParameters(10, 100, 200, 10, 10, 10); InitGenerator(firstPeriod, secondPeriod); }
private void InitHundredThousandGenerator() { var firstPeriod = new GeneratorParameters(200, 30000, 10000, 2000, 2000, 200); var secondPeriod = new GeneratorParameters(100, 15000, 10000, 1000, 1000, 100); InitGenerator(firstPeriod, secondPeriod); }
private void InitQuarterMillionGenerator() { var firstPeriod = new GeneratorParameters(400, 60000, 20000, 4000, 4000, 400); var secondPeriod = new GeneratorParameters(200, 30000, 10000, 2000, 2000, 200); InitGenerator(firstPeriod, secondPeriod); }
private void InitHalfMillionGenerator() { var firstPeriod = new GeneratorParameters(1000, 150000, 50000, 10000, 10000, 1000); var secondPeriod = new GeneratorParameters(500, 75000, 25000, 5000, 5000, 500); InitGenerator(firstPeriod, secondPeriod); }
public static Type GenerateView(GeneratorParameters generatorParameters) { // Generate View Generator.GenerateView(generatorParameters); var generatedFile = generatorParameters.OutputDir + $"/{generatorParameters.View.Name}.cs"; var desiredClass = $"{generatorParameters.NamespaceName}.{generatorParameters.View.Name}"; Assert.IsTrue(File.Exists(generatedFile)); // Generate controller Generator.GenerateController(generatorParameters); var generatedControllerFile = generatorParameters.OutputDir + $"/{generatorParameters.Controller.Name}.cs"; // Generate Model Generator.GenerateModel(generatorParameters); var generatedModelFile = generatorParameters.OutputDir + $"/{generatorParameters.Model.Name}.cs"; var additionalTypesToCompile = new List <Type> { typeof(BaseModel), typeof(MonoBehaviour) }; return(CompileInRAMGeneratedClasses( new[] { generatedFile, generatedModelFile, generatedControllerFile }, desiredClass, additionalTypesToCompile )); }
protected virtual void ConfigureGeneratorParameters(GeneratorParameters parameters) { parameters.InterfaceNamespace = RootGeneratedNamespace; parameters.InterfaceOutputPath = ModelOutputFilePath; parameters.ItemNamespace = RootGeneratedNamespace + ".Concrete"; parameters.ItemOutputPath = ModelOutputFilePath; parameters.TemplatePathRoot = NamespaceTemplatePathRoot; }
/// <summary> /// fills the theme through the generation file /// </summary> private void EnsureThemes() { if (themes.Count > 0) { return; } try { var assembly = typeof(ThemeManager).Assembly; string resourceName = assembly.GetManifestResourceNames().FirstOrDefault(x => x.Contains(GeneratedParameterFile)); GeneratorParameters generatorParameters = null; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { using (StreamReader sr = new StreamReader(stream)) { generatorParameters = JsonConvert.DeserializeObject <GeneratorParameters>(sr.ReadToEnd()); } } string nameSpace = typeof(ThemeManager).Namespace; string basePath = resourceName.Replace(GeneratedParameterFile, string.Empty) .Replace(nameSpace, string.Empty) .Replace(".", "/"); basePath = nameSpace + basePath; List <string> availableXamlThemes = new List <string>(); foreach (var colorScheme in generatorParameters.ColorSchemes.Select(x => x.Name)) { foreach (var baseColorScheme in generatorParameters.BaseColorSchemes.Select(x => x.Name)) { string themeName = $"{baseColorScheme}.{colorScheme}"; string xamlPathName = basePath + $"{themeName}.xaml"; availableXamlThemes.Add(xamlPathName); } } availableXamlThemes = availableXamlThemes.OrderBy(x => x).ToList(); foreach (string xamlFile in availableXamlThemes) { string tempXamlPath = xamlFile.Replace("/", "."); var theme = new StyleInclude(new Uri("resm:Styles?assembly=Avalonia.ExtendedToolkit")) { //resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid Source = new Uri($"avares://{xamlFile}") //Source = new Uri($"resm:{tempXamlPath}?assembly=Avalonia.ExtendedToolkit") }; themesInternal.Add(new Theme(theme)); } } catch (Exception e) { throw new InvalidOperationException(e.Message); } }
public DaysSeriesDateTimeGenerator(ColumnDataTypeDefinition datatype) : base(GENERATOR_NAME, datatype) { GeneratorParameters.Add(new GeneratorParameter("Shift Days", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Hours", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Minutes", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Seconds", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Milliseconds", 0, GeneratorParameterParser.IntegerParser)); }
public void Init() { var parameters = new GeneratorParameters(); parameters.Add("Namespace", _projectInfo.Namespace); parameters.Add("IsModule", _projectInfo.IsModule.ToString()); base.Init(parameters); }
public ForeignKeyGeneratorBase(string generatorName, List <string> foreignKeys) : base(generatorName, false) { // add foreign keys to parameters GeneratorParameters.Add(new GeneratorParameter("Foreign keys" , foreignKeys , GeneratorParameterParser.ObjectParser , false)); }
public ValueFromOtherColumnDateTimeGenerator(ColumnDataTypeDefinition datatype) : base(GENERATOR_NAME, datatype, true) { GeneratorParameters.Add(new GeneratorParameter("Value From Column", null, GeneratorParameterParser.ObjectParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Days", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Hours", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Minutes", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Seconds", 0, GeneratorParameterParser.IntegerParser)); GeneratorParameters.Add(new GeneratorParameter("Shift Milliseconds", 0, GeneratorParameterParser.IntegerParser)); }
private void GenerateData(GeneratorParameters period) { _clientHandler.Generate(period.Clients); _architectHandler.Generate(period.Architects, _doneProjectHandler.CurrentDate); _outerSubjectHandler.Generate(period.Clients); _projectHandler.Generate(period.Projects, _doneProjectHandler.CurrentDate); _supervisionHandler.Generate(period.Supervisions); _outerProjectHandler.Generate(period.OuterProjects); _doneProjectHandler.Generate(0); // amount needed by interface, but here will be calculated on handler's side }
private string ResolveAutoProjectPath(GeneratorParameters parameters) { var outputPath = parameters.ItemOutputPath; outputPath = Path.GetDirectoryName(outputPath); Debug.Assert(outputPath != null, "outputPath != null"); return(ResolveProject(new DirectoryInfo(outputPath))); }
public void InitGenerator(GeneratorParameters firstPeriod, GeneratorParameters secondPeriod) { _firstPeriod = firstPeriod; _secondPeriod = secondPeriod; _architectHandler = new ArchitectHandler(); _clientHandler = new ClientHandler(); _outerSubjectHandler = new OuterSubjectHandler(); _projectHandler = new ProjectHandler(_clientHandler); _outerProjectHandler = new OuterProjectHandler(_projectHandler, _outerSubjectHandler); _supervisionHandler = new SupervisionHandler(_projectHandler, _outerSubjectHandler); _doneProjectHandler = new DoneProjectHandler(_projectHandler, _architectHandler, _supervisionHandler, _outerProjectHandler); }
/// <summary> /// Calculates available moves. /// </summary> /// <param name="generatorParameters">The generator parameters.</param> private void CalculateAvailableMoves(GeneratorParameters generatorParameters) { PawnMovesGenerator.Generate(generatorParameters); KnightMovesGenerator.Generate(generatorParameters); KingMovesGenerator.Generate(generatorParameters); RookMovesGenerator.Generate(PieceType.Rook, generatorParameters); BishopMovesGenerator.Generate(PieceType.Bishop, generatorParameters); RookMovesGenerator.Generate(PieceType.Queen, generatorParameters); BishopMovesGenerator.Generate(PieceType.Queen, generatorParameters); }
private void AsyncGenerator(object param) { Console.WriteLine("Hello World"); try { GeneratorParameters parameters = (GeneratorParameters)param; // MazeGenerator = MazeGenerator.ImageSize size; if (parameters.filesizetag == "Tiny") { size = MazeGenerator.ImageSize.VerySmall; } else if (parameters.filesizetag == "Small") { size = MazeGenerator.ImageSize.Small; } else if (parameters.filesizetag == "Medium") { size = MazeGenerator.ImageSize.Medium; } else if (parameters.filesizetag == "Large") { size = MazeGenerator.ImageSize.Large; } else // Default to medium in the case of a bad input { size = MazeGenerator.ImageSize.Medium; } MazeGenerator.MazeGenerator generator = new MazeGenerator.MazeGenerator(size); ImageFormat format = ImageFormat.Png; string extension = Path.GetExtension(parameters.outfilename); if (extension == ".jpg" || extension == ".jpeg") { format = ImageFormat.Jpeg; } else if (extension == ".bmp") { format = ImageFormat.Bmp; } generator.Image.Save(parameters.outfilename, format); Invoke(generatorHandler, true); } catch (Exception e) { Console.Write(e.StackTrace); Invoke(generatorHandler, false); } }
protected override object ApplyGeneratorTypeSpecificLimits(object value) { if (value is DBNull) { return(value); } decimal max = GeneratorParameters.GetValueOf <decimal>("MaxValue"); decimal min = GeneratorParameters.GetValueOf <decimal>("MinValue"); decimal newvalue = (decimal)value; // return the value if it is smaller than the max value and larger than the min value. return(Math.Max(Math.Min(newvalue, max), min)); }
public static object GenerateModel(GeneratorParameters generatorParameters) { // Generate Model Generator.GenerateModel(generatorParameters); var generatedFile = generatorParameters.OutputDir + $"/{generatorParameters.Model.Name}.cs"; var desiredClass = $"{generatorParameters.NamespaceName}.{generatorParameters.Model.Name}"; Assert.IsTrue(File.Exists(generatedFile)); var additionalTypesToCompile = new List <Type> { typeof(BaseModel) }; return(Activator.CreateInstance(CompileInRAMGeneratedClass(generatedFile, desiredClass, additionalTypesToCompile))); }
private static GeneratorParameters CreateGeneratorParameters() { var parameters = new GeneratorParameters { Clients = ReadInput(Resources.Program_CustomGenerator_Ilu_klientów_ma_zostać_wygenerowanych_), Architects = ReadInput(Resources.Program_CustomGenerator_Ilu_architektów_ma_zostać_wygenerowanych_), Projects = ReadInput(Resources.Program_CustomGenerator_Ile_projektów_ma_zostać_wygenerowanych_), Supervisions = ReadInput(Resources.Program_CustomGenerator_Ile_nadzorów_ma_zostać_wygenerowanych_), OuterProjects = ReadInput(Resources.Program_CustomGenerator_Ile_zewnętrznych_podmiotów_ma_zostać_wygenerowanych_), OuterSubjects = ReadInput(Resources.Program_CustomGenerator_Ile_zewnętrznych_projektów_ma_zostać_wygenerowanych_) }; Console.WriteLine(Resources.Program_CustomGenerator_BreakLine); return(parameters); }
public List <int> GetLevelRange() { List <int> levelSpan = new List <int>(); GeneratorParameters stageParameters = GetCurrentStagesData(); int levelCount = stageParameters.levelRange.y - stageParameters.levelRange.x + 1; for (int i = 0; i < levelCount; i++) { for (int j = 0; j < helpFunction(levelCount, i); j++) { levelSpan.Add(stageParameters.levelRange.x + i); } } return(levelSpan); }
public virtual IActionResult Generate([FromBody] GeneratorParameters generateParameters) { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(200, default(StringOperationResult)); string exampleJson = null; exampleJson = "\"\""; var example = exampleJson != null ? JsonConvert.DeserializeObject <StringOperationResult>(exampleJson) : default(StringOperationResult); //TODO: Change the data returned return(new ObjectResult(example)); }
protected override object ApplyGeneratorTypeSpecificLimits(object value) { if (value is DBNull) { return(value); } int maxLength = GeneratorParameters.GetValueOf <int>("MaxLength"); if (value is string) { return((value as string).SubstringWithMaxLength(maxLength)); } else { return(value.ToString().SubstringWithMaxLength(maxLength)); } }
public VoiceParameters() { BlockBuffer = new SampleArray(SynthConstants.DefaultBlockSize); //create default number of each component PData = new UnionData[SynthConstants.MaxVoiceComponents]; GeneratorParams = new GeneratorParameters[SynthConstants.MaxVoiceComponents]; Envelopes = new Envelope[SynthConstants.MaxVoiceComponents]; Filters = new Filter[SynthConstants.MaxVoiceComponents]; Lfos = new Lfo[SynthConstants.MaxVoiceComponents]; //initialize each component for (int x = 0; x < SynthConstants.MaxVoiceComponents; x++) { GeneratorParams[x] = new GeneratorParameters(); Envelopes[x] = new Envelope(); Filters[x] = new Filter(); Lfos[x] = new Lfo(); } }
private GeneratorParameters GetCurrentStagesData() { GeneratorParameters stageParameters = stageData[currentStage - 1]; if (stageParameters.stageNumber == currentStage) { return(stageParameters); } foreach (var data in stageData) { if (data.stageNumber == currentStage) { return(data); } } return(null); }
public VoiceParameters() { blockBuffer = new float[Synthesizer.DefaultBlockSize]; //create default number of each component pData = new UnionData[Synthesizer.MaxVoiceComponents]; generatorParams = new GeneratorParameters[Synthesizer.MaxVoiceComponents]; envelopes = new Envelope[Synthesizer.MaxVoiceComponents]; filters = new Filter[Synthesizer.MaxVoiceComponents]; lfos = new Lfo[Synthesizer.MaxVoiceComponents]; //initialize each component for (int x = 0; x < Synthesizer.MaxVoiceComponents; x++) { generatorParams[x] = new GeneratorParameters(); envelopes[x] = new Envelope(); filters[x] = new Filter(); lfos[x] = new Lfo(); } }
/// <summary> /// Generates source code files and writes them to disk /// </summary> public void Generate(TemplateGenerationMetadata metadata) { // this is a hack hack hack. Use parameters, lazybones. _metadata = metadata; _parameters = metadata.Parameters; // for source generation we want to split the generated code into separate units (files) CodeCompileUnit interfaceUnit = CreateCodeCompileUnit(); CodeCompileUnit concreteUnit = CreateCodeCompileUnit(); GenerateInterfaceCode(interfaceUnit); GenerateTemplateCode(concreteUnit); SortCodeCompileUnit(concreteUnit); SortCodeCompileUnit(interfaceUnit); WriteFileWithBackups(_parameters.ItemOutputPath, concreteUnit); WriteFileWithBackups(_parameters.InterfaceOutputPath, interfaceUnit); }
public GeneString[] generatePopulation(GeneratorParameters parameters) { ByteGeneStringGeneratorParameters bgsParameters = (ByteGeneStringGeneratorParameters)parameters.parameters; int minimalPopulationSize = parameters.initial.Length; if (parameters.populationSize > minimalPopulationSize) minimalPopulationSize = parameters.populationSize; ByteGeneString[] genes = new ByteGeneString[minimalPopulationSize]; for (int n = 0; n < parameters.initial.Length; n++) { if (!(parameters.initial[n] is ByteGeneString)) throw new WrongGeneTypeException("ByteGeneStringGenerator only accepts ByteGeneStrings"); genes[n] = (ByteGeneString)parameters.initial[n]; } for (int n = parameters.initial.Length; n < genes.Length; n++) { genes[n] = new ByteGeneString(parameters.numGenes, bgsParameters.geneSize, true); } return genes; }
public TemplateGenerationMetadata(bool useRelativeNamespaces, string namespaceRoot, GeneratorParameters parameters) { _parameters = parameters; _templateNovelizer = new TypeNovelizer(useRelativeNamespaces, namespaceRoot); _interfaceNovelizer = new TypeNovelizer(useRelativeNamespaces, namespaceRoot); }