public GenerationParameter(Dictionary<string, Model> models, Dictionary<string, List<String>> generationObjects,GenerationSettings settings) { this._models = models; this._generationObjects = generationObjects; this._settings = settings; }
private static GenerationSettings GetGenerationSettings(string[] templateNames, string tablePrefix, bool isOmitTablePrefix, bool isCamelCaseName) { GenerationSettings settings = new GenerationSettings(language, templateEngine, packagename, tablePrefix, author, version, templateNames, codeFileEncoding, isOmitTablePrefix, isCamelCaseName); return(settings); }
public GenerationParameter(Dictionary <string, Model> models, Dictionary <string, List <String> > generationObjects, GenerationSettings settings) { this._models = models; this._generationObjects = generationObjects; this._settings = settings; }
void DrawContentSettings() { GUILayout.Space(20); GUILayout.BeginArea(editSection); if (generationSettings == null) { EditorGUILayout.HelpBox("Need Generation Settings", MessageType.Warning); } else { if (GUILayout.Button("Edit", GUILayout.Height(150), GUILayout.Width(Screen.width / 2 - 5))) { EditSettingsWindow.OpenWindow(generationSettings); } } GUILayout.EndArea(); GUILayout.BeginArea(createSection); if (GUILayout.Button("Create new Settings", GUILayout.Height(150), GUILayout.Width(Screen.width / 2 - 5))) { GenerationSettings asset = ScriptableObject.CreateInstance <GenerationSettings>(); AssetDatabase.CreateAsset(asset, "Assets/NewScripableObject.asset"); AssetDatabase.SaveAssets(); } GUILayout.EndArea(); }
public TestGeneratorTestsBase() { net35CSSettings = new ProjectPlatformSettings { Language = GenerationTargetLanguage.CSharp, LanguageVersion = new Version("3.0"), Platform = GenerationTargetPlatform.DotNet, PlatformVersion = new Version("3.5"), }; net35VBSettings = new ProjectPlatformSettings { Language = GenerationTargetLanguage.VB, LanguageVersion = new Version("9.0"), Platform = GenerationTargetPlatform.DotNet, PlatformVersion = new Version("3.5"), }; net35CSProjectSettings = new ProjectSettings { ProjectFolder = Path.GetTempPath(), ProjectPlatformSettings = net35CSSettings }; net35VBProjectSettings = new ProjectSettings { ProjectFolder = Path.GetTempPath(), ProjectPlatformSettings = net35VBSettings }; defaultSettings = new GenerationSettings(); TestHeaderWriterStub = new Mock <ITestHeaderWriter>(); TestUpToDateCheckerStub = new Mock <ITestUpToDateChecker>(); }
private static List <Point> UniformDistribution(GenerationSettings settings) { var points = new List <Point>(); var width = settings.Width; var length = settings.Length; int gran = 20000; int widthM = 0, lengthM = 0; if (width > length) { lengthM = gran; widthM = (int)Math.Floor(gran * width / length); } else { widthM = gran; lengthM = (int)Math.Floor(gran * length / width); } for (int i = 0; i < settings.Amount; i++) { var p = Point.Zero; p.X = width * RandomHelper.RandomInt((int)settings.StartX, widthM) / widthM; p.Y = length * RandomHelper.RandomInt((int)settings.StartY, lengthM) / lengthM; points.Add(p); } return(points); }
public Matchup GenerateMatchup(GenerationSettings settings) { var random = new Random(); DowMap map = settings.Maps[random.Next(settings.Maps.Count)]; var info = new GameInfo() { Options = new GameOptions() { Difficulty = (GameDifficulty)RandomOption(settings.GameDifficultyTickets, random), Speed = (GameSpeed)RandomOption(settings.GameSpeedTickets, random), ResourceRate = (GameResourceRate)RandomOption(settings.ResourceRateTickets, random), StartingResources = (GameStartResource)RandomOption(settings.StartResourceTickets, random) } }; info.Rules.Add(settings.Rules[random.Next(settings.Rules.Count)]); var matchup = new Matchup(map, info); if (settings.Teams != null) { // TODO generate the team compositions } return(matchup); }
private static List <Point> CityLikeSpread(GenerationSettings settings) { var startX = (int)settings.StartX; var startY = (int)settings.StartY; var width = (int)settings.Width; var length = (int)settings.Length; var offset = 0.20; //amount of points will be divided over both generations settings.Amount = (int)Math.Floor(settings.Amount * 0.3); //generate outer points var points = SimpleSpread(settings); //calculate new start point and bounds settings.StartX = startX + (width * offset); settings.StartY = startY + (length * offset); offset *= 2; settings.Width = width * (1 - offset); settings.Length = length * (1 - offset); //generate inner points settings.Amount = (int)Math.Floor(settings.Amount * 0.7); points.AddRange(SimpleSpread(settings)); return(points); }
public OperationResult <Dictionary <string, IProviderModel> > Get(GenerationSettings settings, Template template, List <string> includeTheseEntitiesOnly, List <string> excludeTheseEntities) { //this call won't recreate the SQLServerInfo over multiple calls try { var sqlServerInfo = _sqlServerInfoFactory.Create(_dataProviderSettings); var tables = TableInfoFactory.Create(sqlServerInfo, settings, includeTheseEntitiesOnly, excludeTheseEntities); var sqlTables = SQLTableFactory.Create(template.Namespace, template.Language, tables); var providerModels = new Dictionary <string, IProviderModel>(); foreach (var sqlTable in sqlTables) { var sqlModel = SQLModelFactory.Create(sqlTable, settings); providerModels.Add(sqlTable.UniqueName, sqlModel); } return(OperationResult <Dictionary <string, IProviderModel> > .Ok(providerModels)); } catch (System.Exception ex) { return(new OperationResult <Dictionary <string, IProviderModel> > { Failure = true, Message = $"SQL Database Data Provider had a failure: { ex.Message }\r\n{ ex.StackTrace }", }); } }
public OperationResult <Dictionary <string, IProviderModel> > Get(GenerationSettings settings, Template template, List <string> includeTheseEntitiesOnly, List <string> excludeTheseEntities) { Assembly assembly; try { assembly = Assembly.LoadFile(_dataProviderSettings.DataSource); } catch (Exception ex) { return(new OperationResult <Dictionary <string, IProviderModel> >(OperationResult.Fail($"Could not load dll: { _dataProviderSettings.DataSource }\r\n\t{ ex.Message }"))); } if (assembly == null) { return(new OperationResult <Dictionary <string, IProviderModel> >(OperationResult.Fail($"Could not load dll: { _dataProviderSettings.DataSource }"))); } var result = new Dictionary <string, IProviderModel>(); foreach (var ns in _dataProviderSettings.Namespaces) { var types = assembly.GetTypes().Where(t => String.Equals(t.Namespace, ns, StringComparison.Ordinal)); if (types != null && types.Any()) { foreach (var type in types) { if (!result.ContainsKey(type.FullName)) { var model = convert(template, type); result.Add(type.FullName, model); } } } } return(OperationResult <Dictionary <string, IProviderModel> > .Ok(result)); }
public void ProcessProject(SpecFlowProject specFlowProject, bool forceGenerate) { traceListener.WriteToolOutput("Processing project: " + specFlowProject.ProjectSettings.ProjectName); GenerationSettings generationSettings = GetGenerationSettings(forceGenerate); using (var generator = CreateGenerator(specFlowProject)) { foreach (var featureFile in specFlowProject.FeatureFiles) { var featureFileInput = CreateFeatureFileInput(featureFile, generator, specFlowProject); var generationResult = GenerateTestFile(generator, featureFileInput, generationSettings); if (!generationResult.Success) { traceListener.WriteToolOutput("{0} -> test generation failed", featureFile.ProjectRelativePath); } else if (generationResult.IsUpToDate) { traceListener.WriteToolOutput("{0} -> test up-to-date", featureFile.ProjectRelativePath); } else { traceListener.WriteToolOutput("{0} -> test updated", featureFile.ProjectRelativePath); } } } }
/// <summary> /// set required data for generating the terrain /// </summary> public void InitializeSettings(TerrainSettings terrainSettings, GenerationSettings voronoiSettings, GameObject parent, CitySettings citySettings) { //store settings _terrainSettings = terrainSettings; _voronoiSettings = voronoiSettings; _citySettings = citySettings; _parentGameObject = parent; //initialize noise //if no seed is specified generate a random one if (!terrainSettings.UseSeed) { _terrainSettings.GroundSeed = Random.Range(int.MinValue, int.MaxValue); _terrainSettings.MountainSeed = Random.Range(int.MinValue, int.MaxValue); _terrainSettings.TreeSeed = Random.Range(int.MinValue, int.MaxValue); _terrainSettings.DetailSeed = Random.Range(int.MinValue, int.MaxValue); } //create noise _groundNoise = new PerlinNoise(_terrainSettings.GroundSeed); _treeNoise = new PerlinNoise(_terrainSettings.TreeSeed); _detailNoise = new PerlinNoise(_terrainSettings.DetailSeed); //calculate total size of 1 terrain tile based on the city bounds _terrainSize = (int)(_voronoiSettings.Width * 2f); _grassLayers = 0; _meshLayers = 0; //create the prototypes used by the generator CreatePrototypes(); }
public OperationResult <Dictionary <string, IProviderModel> > Get(GenerationSettings settings, Template template, List <string> includeTheseEntitiesOnly, List <string> excludeTheseEntities) { Assembly assembly; try { assembly = Assembly.LoadFile(_dataProviderSettings.DataSource); } catch (Exception ex) { return(new OperationResult <Dictionary <string, IProviderModel> >(OperationResult.Fail($"Could not load dll: { _dataProviderSettings.DataSource }\r\n\t{ ex.Message }"))); } if (assembly == null) { return(new OperationResult <Dictionary <string, IProviderModel> >(OperationResult.Fail($"Could not load dll: { _dataProviderSettings.DataSource }"))); } var result = new Dictionary <string, IProviderModel>(); foreach (var ns in _dataProviderSettings.Namespaces) { // types here are maybe a controller and we're not interested in its properties, we're interested in the // types that its methods are returning var types = assembly .GetExportedTypes() .Where(t => String.Equals(t.Namespace, ns, StringComparison.Ordinal)); foreach (var type in types) { var model = convert(template, type); result.Add(type.FullName, model); } } return(OperationResult <Dictionary <string, IProviderModel> > .Ok(result)); }
private string prepareOutputDirectory(GenerationSettings settings, Template template) { // cleanup the output directory var destinationPath = Path.Join(settings.OutputDirectory, template.OutputRelativePath); if (template.IsStub && !settings.ProcessTemplateStubs) { // don't clean the directory if we're not going to ProcessTemplateStubs // this way, we can be sneaky and still generate stubs that don't already exist return(destinationPath); } if (!template.DeleteAllItemsInOutputDirectory) { // don't clean the directory if DeleteAllItemsInOutputDirectory is set to false // this way a directory may contain elements that shouldn't be deleted. // This is not preferred, but it gives us flexibility. return(destinationPath); } var destinationDirectory = Path.GetDirectoryName(destinationPath); if (template.DeleteAllItemsInOutputDirectory) { var cleanupResult = _templateOutputEngine.CleanupOutputDirectory(destinationDirectory); } return(destinationPath); }
public OperationResult GenerateOne(GenerationSettings settings, Template template) { var getResult = getDataItems(settings, template); if (getResult.Failure) { return(getResult); } var destinationPath = prepareOutputDirectory(settings, template); var items = getResult.Result; var groupProviderModel = new GroupModel { Models = items.Select(a => a.Value), Namespace = template.Namespace, Imports = template.Imports }; var output = _renderEngine.Render(template, groupProviderModel); var result = _templateOutputEngine.Write(destinationPath, output, template.IsStub, settings.ProcessTemplateStubs); if (result.Failure) { return(result); } return(OperationResult.Ok()); }
//Applies the generation settings to the fields. public void applyGenerationSettingsToFields(GenerationSettings genSettings) { lacunarityText.text = genSettings.lacunarity.ToString(); persistanceText.text = genSettings.persistance.ToString(); octavesText.text = genSettings.octaves.ToString(); noiseText.text = genSettings.noiseScale.ToString(); }
public void setSliderValues(GenerationSettings genSettings) { lacunaritySlider.value = genSettings.lacunarity; persistanceSlider.value = genSettings.persistance; noiseSlider.value = genSettings.noiseScale; octavesSlider.value = genSettings.octaves; }
/// <summary> /// The buttons for generating, building and resetting /// </summary> private void GenerationButtons() { GUILayout.BeginHorizontal(); //Generate a terrain and a voronoi diagram on the terrain if (GUILayout.Button("Generate")) { //Use custom settings or a preset _generationSettings = _showAdvancedSettings ? _generationSettings : GetSettingsFromPreset(_cityType); //Store district information _citySettings.DistrictSettings = MakeDistrictSettings(); _townGenerator.PrefabsPerZone = MakePrefabList(); _townGenerator.Generate(_generationSettings, _citySettings, _terrainEditor.GetSettings()); } ////Using the voronoi data, create a city and build it //if (GUILayout.Button("Build")) //{ // _townGenerator.Build(); //} //Clear all generated data if (GUILayout.Button("Clear")) { _townGenerator.Clear(); } GUILayout.EndHorizontal(); }
public override void Initialize(ContentManager content) { base.Initialize(content); networkSettings = new NetworkSettings(); generationSettings = new GenerationSettings(); mainPanel = BuildMainPanel(); worldSelectPanel = BuildWorldSelectPanel(); newWorldPanel = BuildNewWorldPanel(); multiplayerPanel = BuildMultiplayerPanel(); joinGamePanel = BuildJoinPanel(); if (!startFromWorldSelect) { mainPanel.Visible = true; worldSelectPanel.Visible = false; newWorldPanel.Visible = false; multiplayerPanel.Visible = false; joinGamePanel.Visible = false; } else { mainPanel.Visible = false; worldSelectPanel.Visible = true; newWorldPanel.Visible = false; multiplayerPanel.Visible = false; joinGamePanel.Visible = false; RefreshWorldSelectList(); } }
public string Generate(string projectFolder, string configFilePath, string targetExtension, string featureFilePath, string targetNamespace, string projectDefaultNamespace, bool saveResultToFile) { using (var generator = CreateGenerator(projectFolder, configFilePath, targetExtension, projectDefaultNamespace)) { var featureFileInput = new FeatureFileInput(FileSystemHelper.GetRelativePath(featureFilePath, projectFolder)) { CustomNamespace = targetNamespace }; var generationSettings = new GenerationSettings { CheckUpToDate = false, WriteResultToFile = saveResultToFile }; var result = generator.GenerateTestFile(featureFileInput, generationSettings); var connectorResult = new GenerationResult(); if (result.Success) { connectorResult.FeatureFileCodeBehind = new FeatureFileCodeBehind { FeatureFilePath = featureFilePath, Content = result.GeneratedTestCode }; } else { connectorResult.ErrorMessage = string.Join(Environment.NewLine, result.Errors.Select(e => e.Message)); } var resultJson = JsonSerialization.SerializeObject(connectorResult); return(resultJson); } }
public static void OpenWindow(GenerationSettings genSetts) { EditSettingsWindow window = (EditSettingsWindow)GetWindow(typeof(EditSettingsWindow)); window.serializedObject = new SerializedObject(genSetts); window.minSize = new Vector2(450, 300); window.Show(); }
public ScheduleGenWindow() { GenerationSettings = new GenerationSettings(); InitializeComponent(); ScheduleGenerator.Instance.Window = this; }
//An overload for the method above, not resetting the seed for various uses. public void modifyGenerationSettings(GenerationSettings genSettings, float lacunarity, float persistance, float noiseScale, int octaves) { genSettings.lacunarity = lacunarity; genSettings.noiseScale = noiseScale; genSettings.octaves = octaves; genSettings.noiseScale = noiseScale; genSettings.persistance = persistance; }
/// <summary> /// Get the weight value of scheduling the item /// </summary> /// <param name="item">Item to potentially schedule</param> /// <returns>weight that the item should be scheduled</returns> private static int EvaluateWidth(GenerationSettings settings, ProductMasterItem item, string line) { if (ScheduleGenerator.Instance.GenerationData.LastWidth.ContainsKey(line) && ScheduleGenerator.Instance.GenerationData.LastWidth[line] != 0) { // Linear progression of weight with the dif in current working width. return(settings.WidthWeight - (int)Math.Abs(ScheduleGenerator.Instance.GenerationData.LastWidth[line] - item.Width)); } return(0); }
/// <summary> /// Get the weight value of scheduling the item /// </summary> /// <param name="item">Item to potentially schedule</param> /// <returns>weight that the item should be scheduled</returns> private static int EvaluateProjection(GenerationSettings settings, ProductMasterItem item) { if (ScheduleGenerator.Instance.GenerationData.PredictionList == null) { return(0); } return(ScheduleGenerator.Instance.GenerationData.PredictionList.Any(p => p.MasterID == item.MasterID) ? settings.ProjectionWeight : 0); }
public override async Task <GroupedDomoData> GetDataAsync(Report report, GenerationSettings settings) { var header = await GetDataHeadersAsync(report); var response = await domoRepository.GetDataAsync(report); var data = new DomoCSVParser().Parse(response, report, header, settings); return(domoDataGroupingService.Group(data, report, settings)); }
private static int EvaluateThickness(GenerationSettings settings, ProductMasterItem item, string line) { if (ScheduleGenerator.Instance.GenerationData.LastWidth.ContainsKey(line) && ScheduleGenerator.Instance.GenerationData.LastWidth[line] != 0) { return(settings.ThicknessWeight - ((int)Math.Abs(ScheduleGenerator.Instance.GenerationData.LastThickness[line] - item.Thickness) * 8)); // 2*.25 = 8*1 } return(0); }
private GenerationSettings GetGenerationSettings() { GenerationSettings settings = new GenerationSettings(this.languageCombx.Text, this.templateEngineCombox.Text, this.packageTxtBox.Text, this.tablePrefixTxtBox.Text, this.authorTxtBox.Text, this.versionTxtBox.Text, this.templateListBox.SelectedItems.Cast <TemplateListBoxItem>().Select(x => x.Name).ToArray(), this.codeFileEncodingCombox.Text, this.isOmitTablePrefixChkbox.Checked, this.isStandardizeNameChkbox.Checked); return(settings); }
public static CSharpCompilation Run( CSharpCompilation compilation, ImmutableArray <SyntaxTree> trees, Dictionary <string, SyntaxTree> sourceMap, List <Diagnostic> diagnostic, GenerationSettings settings, List <CodeGeneration.GeneratedCsFile> generatedFiles, Action <string>?logTime = null ) { // return compilation; var referencedAssemblies = compilation.Assembly.GetReferencedAssembliesAndSelf(); var maybeMacrosAssembly = referencedAssemblies.FirstOrDefault(_ => _.Name == "Macros"); if (maybeMacrosAssembly == null) // skip this step if macros dll is not referenced { return(compilation); } var macrosAssembly = maybeMacrosAssembly; // GetTypeByMetadataName searches in assembly and its direct references only var macrosClass = macrosAssembly.GetTypeByMetadataName(typeof(Macros).FullName !); if (macrosClass == null) { diagnostic.Add(Diagnostic.Create(new DiagnosticDescriptor( "ER0003", "Error", "Macros.dll assembly must be referenced directly.", "Error", DiagnosticSeverity.Error, true ), compilation.Assembly.Locations[0])); return(compilation); } // var ss = Stopwatch.StartNew(); // compilation.Emit(new MemoryStream()); // Console.Out.WriteLine("ss " + ss.Elapsed); var helper = new MacroHelper(macrosAssembly, diagnostic, referencedAssemblies, trees, compilation); var simpleMethodMacroType = helper.getTypeSymbol <SimpleMethodMacro>(); var statementMethodMacroType = helper.getTypeSymbol <StatementMethodMacro>(); var varMethodMacroType = helper.getTypeSymbol <VarMethodMacro>(); #pragma warning disable 618 var inlineType = helper.getTypeSymbol <Inline>(); #pragma warning restore 618 var lazyPropertyType = helper.getTypeSymbol <LazyProperty>(); logTime?.Invoke("a1"); ISymbol macroSymbol(string name) => macrosClass.GetMembers(name).First(); helper.builderInvocations.Add( macroSymbol(nameof(Macros.className)), (ctx, op) => { var enclosingSymbol = ctx.Model.GetEnclosingSymbol(op.Syntax.SpanStart); ctx.ChangedNodes.Add(op.Syntax, enclosingSymbol !.ContainingType.ToDisplayString().StringLiteral()); });
public async Task SellBallotAsync_PicksRandomBallotRegistersAsSold() { // Arrange int expectedRandomNumber = 2; var expectedRandomNumbers = new List <int> { expectedRandomNumber }; int expectedBallotNumber = 123456789; DateTime expectedSellDate = new DateTime(2017, 12, 25); SystemTime.SetDateTime(expectedSellDate); var expectedBallots = new List <Ballot> { new Ballot(), new Ballot(), new Ballot() { Number = expectedBallotNumber } }; int?lastNumber = null; var expectedDraw = new Draw { SellUntilDate = new DateTime(2018, 1, 1), Ballots = expectedBallots }; GenerationSettings actualGenerationSettings = null; RandomGeneratorMock .Setup(mock => mock.GenerateRandomNumbersAsync(It.IsAny <GenerationSettings>())) .Callback((GenerationSettings generationSettings) => { actualGenerationSettings = generationSettings; }) .ReturnsAsync(expectedRandomNumbers); // Act Ballot result = await Lottery.SellBallotAsync(expectedDraw, lastNumber); // Assert result.Should().NotBeNull(); result.Number.Should().Be(expectedBallotNumber); result.SellDate.Should().Be(expectedSellDate); actualGenerationSettings.Should().NotBeNull(); actualGenerationSettings.NumberOfIntegers.Should().Be(1); actualGenerationSettings.MinimalIntValue.Should().Be(0); actualGenerationSettings.MaximumIntValue.Should().Be(2); RandomGeneratorMock.VerifyAll(); }
public static GenerationSettings Open(Window mainWindow, GenerationSettings settings) { var window = new OpenCreateSettingsView(mainWindow, settings); if (window.ShowDialog() ?? false) { return(window._viewModel.Result); } return(null); }
private GenerationSettings GetGenerationSettings() { GenerationSettings settings = new GenerationSettings(this.languageCombx.Text, this.templateEngineCombox.Text, this.packageTxtBox.Text, this.tablePrefixTxtBox.Text, this.authorTxtBox.Text, this.versionTxtBox.Text, this.templateListBox.SelectedItems.Cast<TemplateListBoxItem>().Select(x=>x.Name).ToArray(), this.codeFileEncodingCombox.Text, this.isOmitTablePrefixChkbox.Checked, this.isStandardizeNameChkbox.Checked); return settings; }
/// <summary> /// Generates the business object assembly. /// </summary> /// <param name="process">The process.</param> /// <param name="assemblyType">Type of the assembly.</param> /// <param name="pubInfo">The pub information.</param> /// <param name="settings">The settings.</param> /// <returns>IList{ErrorInfo}.</returns> public IList<ErrorInfo> GenerateBusinessObjectAssembly(IProcessDefinition process, AssemblyType assemblyType, PublisherInformation pubInfo = null, GenerationSettings settings = GenerationSettings.GenerateAndCompile) { var errors = new List<ErrorInfo>(); foreach ( var errorList in AssemblyGenerators.Where(a => a.Metadata.GeneratorType == assemblyType && (assemblyType == AssemblyType.Client || a.Metadata.DatabaseType == DatabaseType)) .Select(generator => generator.Value.GenerateBusinessObjectAssembly(new AssemblyGeneratorContext(process, assemblyType, pubInfo))) .Where(errorList => errorList != null && errorList.Count > 0)) errors.AddRange(errorList); return errors; }