private void _scanTokens() { foreach (Match m in Regex.Matches(TemplateText, _token_pattern)) { string token = m.Groups[1].Value.ToLower(); _token_replacements[token] = new TokenReplacement(); } }
public void TestTokenDictionaryBackwardResolution() { var tokens = new TokenDictionary(); tokens.Set("anotherName", Token.FromString(TokenReplacement.TokenPlaceHolder("name"))); tokens.Set("name", Token.FromString("testName")); Assert.AreEqual(expected: "testName", actual: tokens.GetString("anotherName")); }
string ReplaceTokens(string file, string token, string newValue) { string processedFile = file + ".clone"; File.Copy(file, processedFile, overwrite: true); TokenReplacement.ReplaceTokenInFile(new FileInfo(processedFile), new Dictionary <string, string> { { token, newValue } }); return(processedFile); }
public void TestResolvingReferencedToken() { var tokens = new Dictionary <string, Token>() { { "name", Token.FromString("testName") }, { "anotherName", Token.FromString(TokenReplacement.TokenPlaceHolder("name")) } }; var resolved = TokenReplacement.ResolveTokens(tokens); Assert.AreEqual(expected: "testName", actual: resolved["anotherName"].Value); }
private string _build() { return(Regex.Replace(TemplateText, _token_pattern, x => { string token = x.Groups[1].Value.ToLower(); TokenReplacement replacement = _token_replacements[token]; if (!replacement.IsSet) { throw new Exception(string.Format("No replacement provided for token \"{0}\".", token)); } return replacement.Value; })); }
public override void LoadRuntimeSettings() { var obj = (TextBoxParameterSettings)(Serialization.DeserializeObject(Settings.ParameterConfig, typeof(TextBoxParameterSettings))); txtParameter.Text = TokenReplacement.ReplaceTokens(obj.Default, null, null); if (obj.Rows > 1) { txtParameter.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine; txtParameter.Columns = obj.Columns; txtParameter.Rows = obj.Rows; } //Dim requiredControl As String = String.Format("<asp:RequiredFieldValidator id=""{0}_Required"" runat=""server"" ControlToValidate=""{0}"" Display=""Dynamic"" ErrorMessage=""<br />{1} is required"" />", "txtParameter", Settings.ParameterName) //Controls.Add(ParseControl(requiredControl)) }
public static Result ReplaceToken( this _Application app, TokenReplacement tokenReplace, WdReplace wordReplace = WdReplace.wdReplaceAll, Action <ReplaceOptions> configureOptions = null) { Find findObject = app.Selection.Find; findObject.ClearFormatting(); findObject.Text = tokenReplace.Token; findObject.Replacement.ClearFormatting(); findObject.Replacement.Text = tokenReplace.Replacement; return(findObject.Replace(wordReplace, configureOptions)); }
void SetBinding(EffectiveBinding binding) { var serviceName = binding.Service.ToUpper(); var configName = ""; var envName = ""; if (string.IsNullOrEmpty(binding.Name)) { configName = serviceName; envName = serviceName; } else { configName = $"{serviceName.ToUpper()}__{binding.Name.ToUpper()}"; envName = $"{serviceName.ToUpper()}_{binding.Name.ToUpper()}"; } if (!string.IsNullOrEmpty(binding.ConnectionString)) { // Special case for connection strings var connectionString = TokenReplacement.ReplaceValues(binding.ConnectionString, binding, bindings); set($"CONNECTIONSTRINGS__{configName}", connectionString); return; } if (!string.IsNullOrEmpty(binding.Protocol)) { // IConfiguration specific (double underscore ends up telling the configuration provider to use it as a separator) set($"SERVICE__{configName}__PROTOCOL", binding.Protocol); set($"{envName}_SERVICE_PROTOCOL", binding.Protocol); } if (binding.Port != null) { set($"SERVICE__{configName}__PORT", binding.Port.Value.ToString(CultureInfo.InvariantCulture)); set($"{envName}_SERVICE_PORT", binding.Port.Value.ToString(CultureInfo.InvariantCulture)); } set($"SERVICE__{configName}__HOST", binding.Host); set($"{envName}_SERVICE_HOST", binding.Host); if (!String.IsNullOrEmpty(binding.Protocol) && !String.IsNullOrEmpty(binding.Host) && binding.Port != null) { set($"{envName}_SERVICE_ENDPOINT", $"{binding.Protocol}://{binding.Host}:{binding.Port}"); } }
private string ReplaceOptionTokens(string s) { return(TokenReplacement.ReplaceTokens(s, null, null)); }
public override void LoadRuntimeSettings() { txtMobiscroll.Text = TokenReplacement.ReplaceTokens(MobiscrollSettings().Default, null, null); }
public override void LoadRuntimeSettings() { var obj = (DefaultParameterSettings)(Serialization.DeserializeObject(Settings.ParameterConfig, typeof(DefaultParameterSettings))); txtParameter.Text = TokenReplacement.ReplaceTokens(obj.Default, null, null); }
Encoding EncodingFor(string path) { return(TokenReplacement.GetFileEncoding(path)); }
public override void LoadRuntimeSettings() { Values = new List <string>(new string[] { TokenReplacement.ReplaceTokens(CalendarSettings().Default, null, null) }); }