public void ConfigInheritance_CronjobOverridesEverythingElse() { var template = new ConfigTemplate("") { Auth = new TokenAuth { Scope = "templatescope", TokenEndpoint = "templateendpoint" } }; var project = new Project("") { Template = template, Auth = new TokenAuth { Scope = "projectscope", } }; var cronjob = new Cronjob(project) { Auth = new TokenAuth { Scope = "cronjobscope" } }; Assert.Equal("cronjobscope", cronjob.EffectiveAuth.Scope); Assert.Equal("templateendpoint", cronjob.EffectiveAuth.TokenEndpoint); }
void GenerateFile() { string filePath = "Assets/Resources/GamingCloud.txt"; if (!System.IO.Directory.Exists(Application.dataPath + "/Resources/")) { try { System.IO.Directory.CreateDirectory(Application.dataPath + "/Resources"); } catch (System.Exception) { Debug.LogError("Create 'Resources' in Assets directory!"); } } if (!System.IO.File.Exists(Application.dataPath + "/Resources/GamingCloud.txt")) { System.IO.File.WriteAllText(Application.dataPath + "/Resources/GamingCloud.txt", ""); } StreamWriter outStream = System.IO.File.CreateText(filePath); ConfigTemplate sd = new ConfigTemplate(); sd.PrivateKey = PrivateKey; sd.PrivateMap = PrivateMap; sd.ServiceToken = ServiceToken; outStream.WriteLine(JsonConvert.SerializeObject(sd)); outStream.Close(); Debug.Log("Saved Successfully"); }
public void ConfigInheritance_CronjobHasNoAuthConfiguration() { var template = new ConfigTemplate("") { Auth = new TokenAuth { Scope = "templatescope", TokenEndpoint = "templateendpoint" } }; var project = new Project("") { Template = template, Auth = new TokenAuth { Scope = "projectscope", } }; var cronjob = new Cronjob(project) { }; Assert.Equal("projectscope", cronjob.EffectiveAuth.Scope); Assert.Equal("templateendpoint", cronjob.EffectiveAuth.TokenEndpoint); }
void GenerateFile() { string filePath = "Assets/Resources/GamingCloud.txt"; StreamWriter outStream = System.IO.File.CreateText(filePath); ConfigTemplate sd = new ConfigTemplate(); sd.PrivateKey = PrivateKey; sd.PrivateMap = PrivateMap; sd.ServiceToken = ServiceToken; outStream.WriteLine(JsonConvert.SerializeObject(sd)); outStream.Close(); Debug.Log("Saved Successfully"); }
private void LoadSettings() { ConfigTemplate ct = ConfigUtils.ReadConfig(); Session.SaveInSession("Prefix", ct.StoredProceduresPrefix); Session.SaveInSession("AuthorName", ct.AuthorName); Session.SaveInSession("NullParamDefaultValues", ct.PassNullAsDefaultParamaeterValue); Session.SaveInSession("GenerateWrapperClass", ct.GenerateWrapperClass); Session.SaveInSession("WrapperClass_GenerateStaticMethods", ct.WrapperClass_GenerateStaticMethods); Session.SaveInSession("WrapperClass_NameSpace", ct.WrapperClass_NameSpace); Session.SaveInSession("AutoSaveWrapperClass", ct.AutoSaveWrapperClass); Session.SaveInSession("AutoSaveScript", ct.AutoSaveScript); Session.SaveInSession("GenerateDeleteRowProc", ct.GenerateDeleteRowProc); Session.SaveInSession("GenerateInsertProc", ct.GenerateInsertProc); Session.SaveInSession("GenerateSelectAllProc", ct.GenerateSelectAllProc); Session.SaveInSession("GenerateSelectRowProc", ct.GenerateSelectRowProc); Session.SaveInSession("GenerateUpdateProc", ct.GenerateUpdateProc); }
/// <summary> /// Write the Application config file /// </summary> /// <param name="session">installer session for log</param> /// <param name="assembly">assembly to use to get embedded resources</param> private static void WriteAppConfig(Session session, System.Reflection.Assembly assembly) { try { string resourceName = typeof(CustomActions).Namespace + ".appconfig-template.txt"; var textStreamReader = new StreamReader(assembly.GetManifestResourceStream(resourceName)); ConfigTemplate = textStreamReader.ReadToEnd(); session.Log("Value of RABBITMQ_IP_PROP: {0}", session.CustomActionData["RABBITMQ_IP_PROP"]); session.Log("Value of MGT API_IP_PROP: {0}", session.CustomActionData["API_IP_PROP"]); session.Log("Value of MGT API_PORT_PROP: {0}", session.CustomActionData["API_PORT_PROP"]); File.WriteAllText(session.CustomActionData["CONFIG_DIR"] + ConfigFileName, ConfigTemplate.Replace("^^RABBITMQ_IP^^", session.CustomActionData["RABBITMQ_IP_PROP"]) .Replace("^^API_IP^^", session.CustomActionData["API_IP_PROP"]) .Replace("^^API_PORT^^", session.CustomActionData["API_PORT_PROP"])); } catch (Exception ex) { session.Log("The WriteAppConfiguration custom action got an exception during execution: {0}", ex.ToString()); } }
public frmOptions() { InitializeComponent(); ConfigTemplate ct = ConfigUtils.ReadConfig(); txtAuthorName.Text = ct.AuthorName; txtPrefix.Text = ct.StoredProceduresPrefix; chkNullParamDefaultValues.Checked = ct.PassNullAsDefaultParamaeterValue; chkGenerateWrapperClass.Checked = ct.GenerateWrapperClass; txtNamespace.Text = ct.WrapperClass_NameSpace; chkStaticMethods.Checked = ct.WrapperClass_GenerateStaticMethods; chkAutosaveSqlScript.Checked = ct.AutoSaveScript; chkAutosaveWrapperClass.Checked = ct.AutoSaveWrapperClass; cbDelete.Checked = ct.GenerateDeleteRowProc; cbInsert.Checked = ct.GenerateInsertProc; cbSelectAll.Checked = ct.GenerateSelectAllProc; cbSelectRow.Checked = ct.GenerateSelectRowProc; cbUpdate.Checked = ct.GenerateUpdateProc; }
private void btnOK_Click(object sender, EventArgs e) { ConfigTemplate ct = ConfigUtils.ReadConfig(); ct.AuthorName = txtAuthorName.Text; ct.StoredProceduresPrefix = txtPrefix.Text; ct.PassNullAsDefaultParamaeterValue = chkNullParamDefaultValues.Checked; ct.GenerateWrapperClass = chkGenerateWrapperClass.Checked; ct.WrapperClass_NameSpace = txtNamespace.Text; ct.WrapperClass_GenerateStaticMethods = chkStaticMethods.Checked; ct.AutoSaveScript = chkAutosaveSqlScript.Checked; ct.AutoSaveWrapperClass = chkAutosaveWrapperClass.Checked; ct.GenerateDeleteRowProc = cbDelete.Checked; ct.GenerateInsertProc = cbInsert.Checked; ct.GenerateSelectAllProc = cbSelectAll.Checked; ct.GenerateSelectRowProc = cbSelectRow.Checked; ct.GenerateUpdateProc = cbUpdate.Checked; ConfigUtils.WriteConfig(ct); Close(); }
/// <summary> /// Fill in the template, replace identifiers in the template in angular brackets by $(identifier). /// Flatten the arrays in the data to simple identifiers /// </summary> /// <param name="timeZoneId"></param> /// <param name="template"></param> /// <param name="locale"></param> /// <param name="typedData"></param> /// <returns></returns> private static string FillInTemplate(string locale, string timeZoneId, string template, string typedData) { if (String.IsNullOrEmpty(template)) return String.Empty; //template = _rxTemplateParameter.Replace(template, @"$$($1)"); template = template.Replace("<br>", "\r\n").Replace(" ", " "); var culture = new CultureInfo(locale); var mfi = new MeasurementFormatInfo(culture.NumberFormat); var ifp = new ImardaFormatProvider(culture, mfi, TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)); IDictionary args = EAHelper.MakeFormattedValues(typedData, ifp); string msg = new ConfigTemplate(template).Instantiate(args); return msg; }
//private Regex _rxTemplateParameter = new Regex(@"<([A-Za-z_]\w*)>", RegexOptions.Compiled); /// <summary> /// Fill in the template, replace identifiers in the template in angular brackets by $(identifier). /// Flatten the arrays in the data to simple identifiers, DRV#1 becomes DRV11, DRV21, DRV31 /// </summary> /// <param name="template"></param> /// <param name="kvpairs"></param> /// <returns></returns> private string FillInTemplate(Guid personID, Guid companyID, string timeZoneId, string template, string typedData, bool forceDefaultDateFormat) { if (string.IsNullOrEmpty(template)) return string.Empty; //template = _rxTemplateParameter.Replace(template, @"$$($1)"); // changes, e.g. <DRV1> to $(DRV1) template = template.Replace("<br>", "\r\n").Replace(" ", " "); if (template.Contains("$(")) { var ifp = GetFormatter(personID, companyID, TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)); ifp.ForceDefaultDateFormat = forceDefaultDateFormat; IDictionary args = EAHelper.MakeFormattedValues(typedData, ifp); string msg = new ConfigTemplate(template).Instantiate(args); return msg; } else { return template; } }
public void ProjectFinishedGenerating(Project project) { DTE dte = project.DTE; var solItems = dte.Solution.Projects.Cast <Project>().FirstOrDefault(p => p.Name == "Solution Items" || p.Kind == EnvDTE.Constants.vsProjectItemKindSolutionItems); if (solItems == null) { Solution2 sol2 = (Solution2)dte.Solution; solItems = sol2.AddSolutionFolder("Solution Items"); string solDir = Path.GetDirectoryName(sol2.FullName); if (outputRepoFile) { RepositoryTemplate repositoryTemplate = new RepositoryTemplate { Session = templateParameters }; repositoryTemplate.Initialize(); string repositoryTemplateContent = repositoryTemplate.TransformText(); string repositoryFilePath = $"{solDir}\\repository.json"; File.WriteAllText(repositoryFilePath, repositoryTemplateContent); solItems.ProjectItems.AddFromFile(repositoryFilePath); } ConfigTemplate configTemplate = new ConfigTemplate { Session = templateParameters }; configTemplate.Initialize(); string configTemplateContent = configTemplate.TransformText(); string configFilePath = $"{solDir}\\config.json"; File.WriteAllText(configFilePath, configTemplateContent); solItems.ProjectItems.AddFromFile(configFilePath); string runtimePath = Directory.GetCurrentDirectory(); solItems.ProjectItems.AddFromFileCopy(runtimePath + "\\.gitignore"); solItems.ProjectItems.AddFromFileCopy(runtimePath + "\\pre_build.ps1"); solItems.ProjectItems.AddFromFileCopy(runtimePath + "\\post_build.ps1"); solItems.ProjectItems.AddFromFileCopy(runtimePath + "\\launch_game.ps1"); // pre-copy references Directory.CreateDirectory($"{solDir}\\references"); string referencesGitIgnorePath = $"{solDir}\\references\\.gitignore"; File.WriteAllText(referencesGitIgnorePath, "*\n!.gitignore"); string pre_build = $@"{solDir.Replace(@"\", @"\\")}\\pre_build.ps1"; string argument = $@"-ExecutionPolicy Unrestricted -File ""{pre_build}"" -SolutionDir ""{solDir.Replace(@"\", @"\\")}\\"""; if ((bool)templateParameters["UseModMenu"]) { argument += @" -ModAssemblyReferences ""blendermf.XLShredMenu\\XLShredLib.dll"""; } var process = new System.Diagnostics.Process { StartInfo = new System.Diagnostics.ProcessStartInfo { FileName = "powershell", Arguments = argument, UseShellExecute = false, RedirectStandardOutput = false, CreateNoWindow = true } }; process.Start(); process.WaitForExit(); } else { var repo = solItems.ProjectItems.Cast <ProjectItem>().FirstOrDefault(p => p.Name == "repository.json"); } (project.Object as VSProject)?.Refresh(); foreach (Configuration config in project.ConfigurationManager) { config.Properties.Item("StartAction").Value = 1; // Launch external program config.Properties.Item("StartProgram").Value = @"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"; config.Properties.Item("StartArguments").Value = @"-ExecutionPolicy Unrestricted -File ""./launch_game.ps1"""; config.Properties.Item("StartWorkingDirectory").Value = @"../../../"; } project.Save(project.FileName); }
//private Regex _rxTemplateParameter = new Regex(@"<([A-Za-z_]\w*)>", RegexOptions.Compiled); /// <summary> /// Fill in the template, replace identifiers in the template in angular brackets by $(identifier). /// Flatten the arrays in the data to simple identifiers, DRV#1 becomes DRV11, DRV21, DRV31 /// </summary> /// <returns></returns> private string FillInTemplate(Guid companyID, Guid personID, string timeZoneId, string template, string typedData) { if (string.IsNullOrEmpty(template)) return string.Empty; template = template.Replace("<br>", "\r\n").Replace(" ", " "); var ifp = GetFormatter(companyID, personID, TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)); IDictionary args = EAHelper.MakeFormattedValues(typedData, ifp); string msg = new ConfigTemplate(template).Instantiate(args); return msg; }