private float GenerateNextYPosition(GeneratorConfig curConfig, float curX, float lastY) { //1 - 100 int randomNumber = UnityEngine.Random.Range(1, 101); if (randomNumber <= curConfig.skipThreshold) { return(0); } if (randomNumber <= curConfig.verticalUpThreshold) { return(lastY + curConfig.verticalDifference); } if (randomNumber <= curConfig.verticalKeepThreshold) { return(lastY); } if (lastY >= curConfig.verticalDifference) { return(lastY - curConfig.verticalDifference); } return(lastY); }
void GenerateNextPlatform(GeneratorConfig curConfig, float x, float y, GameObject greenPlatformParent, GameObject redPlatformParent) { int randomNumber = UnityEngine.Random.Range(0, 2); if (y == 0) { return; } GameObject prefabObj = null; // Generate Green Platform if (randomNumber == 1) { prefabObj = GetRandomPlatformPrefab(curConfig.platformPrefabs); if (prefabObj == null) { return; } GenerateGameObject(x, y, prefabObj, greenPlatformParent); return; } prefabObj = GetRandomPlatformPrefab(curConfig.platformPrefabs); if (prefabObj == null) { return; } GenerateGameObject(x, y, prefabObj, redPlatformParent); }
public void TimeStampCultureValidationTest() { GeneratorConfig uut = GetValidConfig(); uut.TimeStampCulture = null; Assert.AreEqual(1, uut.TryValidate().Count); }
public GeneratorModel(string fileSchematic, string fileTemplates) { Configuration = new GeneratorConfig() { datafile = fileSchematic, templatefile = fileTemplates }; }
public DataBaseReadTest(DatabaseFixture fixture) { if (TestConstants.IsMyMachine) { fixture.DBPath = string.Format(@"{0}\AppData\CodeGeneratorTest.mdf", Directory.GetCurrentDirectory()); fixture.DBServer = @"(LocalDB)\ProjectsV13"; Fixture = fixture; var config = new GeneratorConfig { DataBase = new DataBaseConfig { ConnectionString = string.Format(@"Data Source={0};AttachDbFilename={1};Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True", Fixture.DBServer, Fixture.DBPath), SchemasExclude = new List <string> { "dbo" } }, CSharp = new CSharpConfig { } }; var generator = new Generator(config); var dataBaseRead = Kernel.Resolve <IDataBaseRead>(); DataBase = dataBaseRead.Read(); } }
/// <summary> /// 対象コードを生成する /// </summary> /// <param name="config"></param> /// <param name="context"></param> public void DoGenerae(GeneratorConfig config, GenerationContext context) { logger.Info($"コード生成開始"); foreach (var templateConfig in config.TemplateFiles) { logger.Info($"テンプレートファイルの準備を開始"); // テンプレート用文字列 var templateString = Helper.General.ReadTemplate(templateConfig); // コードの出力対象パスを生成する var outPath = MakeOutputDirectory(config, templateConfig); // テンプレートの生成 foreach (var s in context.Sites) { logger.Info($"テンプレート生成 : {s.SiteDefinition.SiteVariableName}"); // 全体のテンプレートデータを参照できるようにする s.AllTemplateFilesConfig = config.TemplateFiles.ToDictionary(x => x.EndPrefix); // サービス用定義を生成 Helper.Generation.DoCodeGeneration(templateConfig, templateString, outPath, s); } } }
public static Task <string> RenderPage(IServiceScopeFactory scopeFactory, GeneratorConfig config, Site site) { using (var serviceScope = scopeFactory.CreateScope()) { var helper = RenderHelper.GetRendererHelper(serviceScope); var model = new SitePage { GeneratorConfig = config, Breadcrumbs = new List <(string href, string text, bool current)> { ("/", "Home", true), ("/site/", "Sites", true) }, CurrentSection = "Site", Site = site, Title = StringHelpers.RemoveHTMLTags(String.Format("{0} - Special Areas of Conservation", site.Name)), MetaDescription = String.Format("SAC selection criteria for site {0}, EU Code {1}, Unitary Authority {2}, {3}", StringHelpers.RemoveHTMLTags(site.Name), site.EUCode, site.LocalAuthority, site.CountryFull), MetaKeywords = new List <string> { site.Name, site.EUCode, site.LocalAuthority } }; return(helper.RenderViewToStringAsync("Views/Site.cshtml", model)); } } }
private void AddRemoteStruct(CefStructType s) { if (remoteStructs.ContainsKey(s.Name)) { return; } remoteStructs.Add(s.Name, s); foreach (var f in s.ClassBuilder.ExportFunctions) { if (!GeneratorConfig.IsBrowserProcessOnly(f.Name)) { AnalyzeSignature(f.Signature); } } foreach (var sm in s.ClassBuilder.StructMembers) { if (!GeneratorConfig.IsBrowserProcessOnly(s.Name + "::" + sm.Name)) { if (sm.MemberType.IsCefStructType) { AddRemoteStruct(sm.MemberType.AsCefStructType); } else if (sm.MemberType.IsCefStructPtrType) { AddRemoteStruct(sm.MemberType.AsCefStructPtrType.Struct); } else if (sm.MemberType.IsCefCallbackType) { AnalyzeSignature(sm.MemberType.AsCefCallbackType.Signature); } } } }
public static void startExecute(GeneratorConfig allConfig) { // GeneratorConfig配置处理 var db = new MySqlSchema(allConfig.dbConfig); var tableList = db.GetTablesList(); if (!string.IsNullOrEmpty(allConfig.inputTables)) { tableList = tableList.Where(c => allConfig.inputTables.Split(',').Contains(c)).ToList(); } if (tableList.Count == 0) { Console.WriteLine("表名不存在"); return; } allConfig.tableList = tableList; try { GenerateTemplate_Model(allConfig); GenerateTemplate_Rep(allConfig); GenerateTemplate_IRep(allConfig); Pause(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw ex; } }
private static void GenerateTemplate_Rep(GeneratorConfig allConfig) { Console.WriteLine("===============生成Repositories=================="); DisplayTemplateName(allConfig.repTemplate); var templateText = TemplateHelper.ReadTemplate(allConfig.repTemplate); foreach (var tableName in allConfig.tableList) { if (!string.IsNullOrEmpty(allConfig.trimTablePre)) { allConfig.tableName = TrimPre(tableName, allConfig.trimTablePre); } var className = allConfig.tableName + "Repository"; allConfig.repClassName = className; allConfig.repInterfaceName = "I" + className; var outputText = TemplateHelper.Parse(TemplateKey.Dao, templateText, allConfig); outputText = TemplateHelper.Clean(outputText, RegexPub.H1()); var path = allConfig.repSavePath + "\\Repositories\\" + allConfig.moduleName; Console.WriteLine("生成Repositories表名:" + className); FileHelper.Save(string.Format(@"{0}\{1}.cs", path, className), outputText); } Console.WriteLine("===============生成Repositories完成==============="); }
public IEnumerable <SiteInfos> DoLoad(GeneratorConfig config) { // サイト一覧定義を読み込む var sites = LoadCsv <SiteDefinition, SiteDefinitionMap>(config, config.InputFiles.SiteDefinitionFile) .Where(e => e.IsTarget == true) .ToList(); // 項目名別一覧定義を読み込む var interfaces = LoadCsv <InterfaceDefinition, InterfaceDefinitionMap>(config, config.InputFiles.InterfaceDefinitionFile) .Where(e => true == e.IsTarget) .ToList(); // サイト単位でデータを整理する var rl = sites .Select(e => { var r = new SiteInfos { SiteDefinition = e, RawInterfaceDefinition = interfaces.Where(i => i.SiteId == e.SiteId).ToList() }; r.ClassifiedInterface = ClassifiedInterface.Generate(r.RawInterfaceDefinition); // ChoicesTextを独自形式に変換する ChoicesTextAdjustment(r.ClassifiedInterface); return(r); }) .ToList(); return(rl); }
public override void EmitRemoteCalls(CodeBuilder b, List <string> callIds) { b.AppendLine(); foreach (var f in ExportFunctions) { if (!GeneratorConfig.IsBrowserProcessOnly(f.Name)) { if (!f.PrivateWrapper) { b.BeginRemoteCallClass(ClassName + f.PublicName, callIds); f.Signature.EmitRemoteCallClassBody(b, ApiClassName, f.CfxApiFunctionName); b.EndBlock(); b.AppendLine(); } } } foreach (var cb in CallbackFunctions) { if (!GeneratorConfig.IsBrowserProcessOnly(CefStruct.Name + "::" + cb.Name)) { b.BeginRemoteCallClass(ClassName + cb.RemoteCallClassName, callIds); cb.Signature.EmitRemoteCallClassBody(b, ApiClassName, cb.CfxApiFunctionName); b.EndBlock(); b.AppendLine(); } } }
public static Task <string> RenderPage(IServiceScopeFactory scopeFactory, GeneratorConfig config, InterestFeature feature) { using (var serviceScope = scopeFactory.CreateScope()) { var helper = RenderHelper.GetRendererHelper(serviceScope); var model = new InterestFeaturePage { GeneratorConfig = config, Breadcrumbs = new List <(string href, string text, bool current)> { ("/", "Home", true), ("/species/", "Species", true) }, CurrentSection = "Species", InterestFeature = feature, Title = StringHelpers.RemoveHTMLTags(String.Format("{0} ({1}) - {2}", feature.LayTitle, feature.Name, Page.DefaultTitle)), MetaDescription = String.Format("Species account of Habitats Directive feature {0}, {1}, {2}. The Habitats Directive: selection of Special Areas of Conservation in the UK, second edition, JNCC (2002)", feature.Code, feature.LayTitle, feature.Name), MetaKeywords = new List <string> { feature.Code, feature.LayTitle, feature.Name } }; return(helper.RenderViewToStringAsync("Views/SpeciesInterestFeature.cshtml", model)); } } }
/// <summary> /// 出力先のディレクトリを生成する /// </summary> private OutputPathInfo MakeOutputDirectory(GeneratorConfig config, GeneratorConfig.Definition.TemplateFiles template) { var r = new OutputPathInfo(); // コード全体の出力パス if (false == Directory.Exists(config.OutputConfig.OutputDirectory)) { // 出力パスが存在しなければディレクトを生成する Directory.CreateDirectory(config.OutputConfig.OutputDirectory); } // サービスコードの出力パス { var sp = Path.Combine(config.OutputConfig.OutputDirectory, template.OutputSubdirectoryName); r.ServicePath = sp; if (false == Directory.Exists(sp)) { logger.Info($"生成結果出力先パスを作成 : ${sp}"); // 出力パスが存在しなければディレクトを生成する Directory.CreateDirectory(sp); } } return(r); }
public void ValidateTemplateTest() { GeneratorConfig uut = GetValidConfig(); uut.TemplatePath = null; // XML should validate with a null, no others should. foreach (MeetingNotesGeneratorType type in Enum.GetValues(typeof(MeetingNotesGeneratorType))) { uut.Type = type; if (type != MeetingNotesGeneratorType.xml) { Assert.AreEqual(1, uut.TryValidate().Count); } else { Assert.AreEqual(0, uut.TryValidate().Count); } } // Meanwhile, if a template IS specified, but is not found, // it should not validate. uut.Type = MeetingNotesGeneratorType.html; uut.TemplatePath = "lol.cshtml"; Assert.AreEqual(1, uut.TryValidate().Count); }
public AzurePersistence(GeneratorConfig gCfg) : base(gCfg) { if ((bool)!gCfg.PersistenceConfig?.ContainsKey(typeof(AzureConfig))) { return; } _config = (AzureConfig)gCfg.PersistenceConfig[typeof(AzureConfig)]; if (_config.Storage?.AccountKey == null || _config.Storage?.AccountName == null || _config.Storage?.Blob?.ContainerName == null) { return; } _act = _config.Storage.AccountName; _key = _config.Storage.AccountKey; _cnt = _config.Storage.Blob.ContainerName; _blobContainer = new CloudStorageAccount(new StorageCredentials(_act, _key), true) .CreateCloudBlobClient().GetContainerReference(_cnt); Status = PersistenceStatus.Configured; Console.WriteLine($"{this} enabled"); }
public ActionResult Post([FromBody] GeneratorConfig config) { var exDict = new Dictionary <string, string[]>() { { "validationErrors", new string[] { "Unknown error" } } }; try { return(new JsonResult(StartGeneration(config, true))); } catch (ArgumentException e) { exDict = new Dictionary <string, string[]>() { { e.ParamName ?? "validationErrors", new string[] { e.Message } } }; } catch (AggregateException ae) { exDict = ae.InnerExceptions .Where(ie => ie is ArgumentException) .ToDictionary(ks => ((ArgumentException)ks).ParamName ?? "unknownParameter", vs => new string[] { vs.Message }); } return(ValidationProblem(new ValidationProblemDetails(exDict))); }
public static List <string> ProcessRemapSchema(this DataBaseTable item, GeneratorConfig config, bool isEF) { var result = new List <string>(); if (config.CSharp.EntityFramework.Remap == null) { return(result); } var remap = config.CSharp.EntityFramework.Remap.Where( c => c.Schema == item.Schema && c.Table == item.Name ); if (remap != null) { result.AddRange(remap.Select(c => c.NameSpace)); } var applicationClass = config.CSharp.ApplicationClasses.Where(c => item.RelationShips.Any(x => x.SchemaPK == c.Schema && x.TablePK == c.Name)); if (config.CSharp.UsingApplicationBase && applicationClass != null) { if (isEF) { result.AddRange(applicationClass.Select(c => c.NamespaceContext)); } else { result.AddRange(applicationClass.Select(c => c.NamespaceEntity)); } } return(result); }
public void ParseMeetbotConfig1Test() { const string xml = @" <meetbotconfig xmlns=""https://files.shendrick.net/projects/chaskis/schemas/meetbot/2020/MeetBotConfig.xsd""> <commandconfig>{%meetbotroot%}/Commands.xml</commandconfig> <enablebackups>true</enablebackups> <generators> <generator type=""xml""> </generator> </generators> </meetbotconfig> "; XmlLoader uut = new XmlLoader(null); MeetBotConfig parsedConfig = uut.ParseConfigAsString(xml, meetbotPath); Assert.AreEqual("{%meetbotroot%}/Commands.xml", parsedConfig.CommandConfigPath); Assert.AreEqual($"{meetbotPath}/Commands.xml", parsedConfig.GetCommandConfigPath()); Assert.IsTrue(parsedConfig.EnableBackups); Assert.AreEqual(1, parsedConfig.Generators.Count); GeneratorConfig parsedGeneratorConfig = parsedConfig.Generators[0]; // Everything else should be defaulted. GeneratorConfig defaultConfig = new GeneratorConfig(meetbotPath); defaultConfig.Type = MeetingNotesGeneratorType.xml; CompareGeneratorConfig(defaultConfig, parsedGeneratorConfig); }
public CefApiDeclarations GetRemoteDeclarations() { remoteFuncs = new SortedDictionary <string, CefExportFunction>(); remoteStructs = new SortedDictionary <string, CefStructType>(); foreach (var f in ExportFunctions) { if (!GeneratorConfig.IsBrowserProcessOnly(f.Name)) { AddRemoteFunc(f); } } foreach (var t in CefStructTypes) { if (t.ClassBuilder.ExportFunctions != null) { foreach (var f in t.ClassBuilder.ExportFunctions) { if (!GeneratorConfig.IsBrowserProcessOnly(f.Name)) { AnalyzeSignature(f.Signature); } } } } return(new CefApiDeclarations(remoteFuncs.Values.ToArray(), remoteStructs.Values.ToArray(), CefEnumTypes, null, null)); }
public string Generate(GeneratorConfig dto) { var result = ""; if (dto.UseLowerCase) { result += LowerCaseCharacters; } if (dto.UseUpperCase) { result += UpperCaseCharacters; } if (dto.UseNumerical) { result += NumericalCharacters; } if (dto.UseSpecial) { result += SpecialCharacters; } if (dto.UseSpace) { result += SpaceCharacter; } return(result); }
public StreamSink(GeneratorConfig gCfg) : base(gCfg) { if (!gCfg.Extra.ContainsKey("streamId") || !(gCfg.Extra["streamId"] is string)) { throw new ArgumentException("StreamSink requires 'streamId' (string) in 'extra' configuration field."); } if ((bool)!gCfg.PersistenceConfig?.ContainsKey(typeof(StreamConfig))) { throw new ArgumentException("StreamSink is not correctly configured for use."); } _streamId = (string)gCfg.Extra["streamId"]; try { _cm = ConnectionMultiplexer.Connect(((StreamConfig)gCfg.PersistenceConfig[typeof(StreamConfig)]).ConnectionString); _activeDb = _cm.GetDatabase(0); } catch (RedisConnectionException rde) { throw new ArgumentException($"Incorrect streaming service configuration. Underlying failure message: '{rde.Message}'"); } Console.WriteLine($"StreamSink publishing to streamId={_streamId}"); }
public override void Initialize(CodeFileGenerator codeFileGenerator) { var nodeConfig = InvertApplication.Container.GetNodeConfig <TData>(); if (!nodeConfig.TypeGeneratorConfigs.ContainsKey(this.GetType())) { return; } GeneratorConfig = nodeConfig.TypeGeneratorConfigs[this.GetType()] as NodeGeneratorConfig <TData>; if (GeneratorConfig == null) { return; } if (GeneratorConfig.Condition != null && !GeneratorConfig.Condition(Data)) { return; } base.Initialize(codeFileGenerator); Decleration = new CodeTypeDeclaration(IsDesignerFile ? NameAsDesignerClass : NameAsClass) { IsPartial = true }; Compose(); }
public override void EmitRemotePostCallStatements(CodeBuilder b, string var) { base.EmitRemotePostCallStatements(b, var); if (GeneratorConfig.UseStrongHandleFor(Struct.Name)) { b.AppendLine($"GC.KeepAlive({var});"); } }
public CodeGenerator(TemplateLoader templateLoader, DocumentContext context, GeneratorConfig config, DirectoryInfo outputFolder) { this.outputFolder = outputFolder; this.templateLoader = templateLoader; this.contextGenerator = context.TemplateContextGenerator; this.config = config; }
protected CodeGenerator(TemplateLoader templateLoader, DocumentContext context, GeneratorConfig config, DirectoryInfo outputFolder) { _outputFolder = outputFolder; _templateLoader = templateLoader; _contextGenerator = context.TemplateContextGenerator; _config = config; }
static GeneratorConfig LoadConfig(string path, ILogger logger) { var config = new GeneratorConfig(path, new BasicModel.Templates.CS.TaskFactory(logger)); //config.AddTypeTask(new OutputTask<TypeDescriptor>(new TypeTask(CreateTaskInput(@"D:\work\2012\ConsoleApplication1\Composite.stg")))); //config.AddTypeTask(new OutputTask<TypeDescriptor>(new TypeTask(CreateTaskInput(@"D:\work\2012\ConsoleApplication1\Primitive.stg")))); return(config); }
public OCDocumentContext(Uri uri, string @namespace, GeneratorConfig generatorConfig, TypeRegistry typeRegistry) : base(uri, @namespace, generatorConfig, typeRegistry, new OCTypeMangler()) { TypeConverter.RegisterConverter(new OCBaseConverter()); TypeConverter.RegisterConverter(new OCIdentifierConverter(TypeConverter)); TypeConverter.RegisterConverter(new OCListConverter(TypeConverter)); TypeConverter.RegisterConverter(new OCMapConverter(TypeConverter)); }
public CSharpDocumentContext(Uri uri, string @namespace, GeneratorConfig generatorConfig, TypeRegistry typeRegistry) : base(uri, @namespace, generatorConfig, typeRegistry, new CSharpTypeMangler()) { TypeConverter.RegisterConverter(new CSharpBaseConverter()); TypeConverter.RegisterConverter(new CSharpIdentifierConverter(TypeConverter)); TypeConverter.RegisterConverter(new CSharpListConverter(TypeConverter)); TypeConverter.RegisterConverter(new CSharpMapConverter(TypeConverter)); }
public CefExportFunction(CefType parent, Parser.FunctionNode fd, ApiTypeBuilder api, CefPlatform platform) { this.Name = fd.Name; this.Comments = fd.Comments; this.Signature = Signature.Create(SignatureType.LibraryCall, CefName, CefConfig, CallMode, fd.Signature, api); this.PrivateWrapper = GeneratorConfig.HasPrivateWrapper(this.Name); this.Parent = parent; this.Platform = platform; }
static void Main(string[] args) { inputFile = "config.xml"; outputFile = "mxml.xml"; if (args.Length == 1 && args[0] == "help") { Console.WriteLine("Usage:"); Console.WriteLine(" MXMLCompletionBuilder [<configuration file> [<output file>]]"); return; } if (args.Length > 0) { inputFile = args[0]; outputFile = Path.Combine(Path.GetDirectoryName(inputFile), outputFile); } if (args.Length > 1) outputFile = args[1]; // read config file if (File.Exists(inputFile)) { try { config = GeneratorConfig.Deserialize(inputFile); } catch (Exception ex) { Console.WriteLine("Unable to load configuration:\n" + ex.Message); } } // write default config file if (config == null) { config = new GeneratorConfig(); config.FlexFrameworkSWCs = new string[] { @"C:\flex_sdk_3\frameworks\libs", @"C:\flex_sdk_3\frameworks\libs\air" }; config.Classpath = new string[] { @"C:\Program Files\FlashDevelop\Library\AS3\intrinsic", @"C:\flex_sdk_3\frameworks\projects\rpc\src", @"C:\flex_sdk_3\frameworks\projects\framework\src", @"C:\flex_sdk_3\frameworks\projects\airframework\src" }; config.IncludePackage = new SerializableDictionary<string, string>(); config.IncludePackage.Add("flash.display", "display"); config.IncludePackage.Add("flash.errors", "errors"); config.IncludePackage.Add("flash.events", "events"); config.IncludePackage.Add("flash.external", "external"); config.IncludePackage.Add("flash.filters", "filters"); config.IncludePackage.Add("flash.geom", "geom"); config.IncludePackage.Add("flash.media", "media"); config.IncludePackage.Add("flash.net", "net"); config.IncludePackage.Add("flash.printing", "printing"); //config.IncludePackage.Add("flash.system", "system"); config.IncludePackage.Add("flash.text", "text"); config.IncludePackage.Add("flash.ui", "ui"); config.IncludePackage.Add("flash.utils", "utils"); config.IncludePackage.Add("flash.xml", "xml"); config.BuiltInTags = new SerializableDictionary<string, string>(); config.BuiltInTags.Add("arguments", ""); config.BuiltInTags.Add("Array", ""); config.BuiltInTags.Add("Binding", "source,destination"); config.BuiltInTags.Add("Boolean", ""); config.BuiltInTags.Add("Component", "className:s"); config.BuiltInTags.Add("Metadata", ""); config.BuiltInTags.Add("method", "name,concurrency,result:e,resultFormat,fault:e"); config.BuiltInTags.Add("Model", "source"); config.BuiltInTags.Add("Number", ""); config.BuiltInTags.Add("Object", ""); config.BuiltInTags.Add("operation", "name,concurrency,makeObjectsBindable,result:e,resultFormat,fault:e"); config.BuiltInTags.Add("request", ""); config.BuiltInTags.Add("Script", "source"); config.BuiltInTags.Add("String", ""); config.BuiltInTags.Add("Style", "source"); config.BuiltInTags.Add("XML", "format,source"); config.BuiltInTags.Add("XMLList", ""); config.ForceMxNamespace = new string[] { "Sprite", "Matrix", "Point", "BevelFilter", "BlurFilter", "ColorMatrixFilter", "DisplacementFilter", "DropShadowFilter", "GlowFilter", "GradientBevelFilter", "GradientGlowFilter" }; config.LeafTags = new string[] { "UIComponent" }; config.ContainerTags = new string[] { "Container", "IContainer" }; GeneratorConfig.Serialize(inputFile, config); } log = File.CreateText(Path.Combine(Path.GetDirectoryName(inputFile), "log.txt")); output = File.CreateText(outputFile); // mx tags declared in SWCs mxTags = new HashSet<string>(); foreach (string swcPath in config.FlexFrameworkSWCs) { string[] libs = Directory.GetFiles(swcPath, "*.swc"); foreach (string lib in libs) ReadCatalog(lib); } // explore classpath context = new AS3Context.Context(new AS3Context.AS3Settings()); groups = new Dictionary<string, TypeInfos>(); ExploreNext(); Console.ReadLine(); }