public static void Main() { Console.WriteLine("***String Interpolation Demo***"); StringInterpolation obj = new StringInterpolation("Eric", null); Console.WriteLine($"{nameof(obj)} {obj.FullName}"); }
public void MI_334_Invalid_Train_AncorTrim() { var str = "xxx$"; var result = new StringInterpolation().Interpolate(str, new{ x = 1 }); Assert.AreEqual(str, result); }
public static string Interpolate(this string str, object ctx, IDictionary <string, object> ctx2 = null, string controlKey = null, Action <StringInterpolation> setup = null) { var si = new StringInterpolation(); if (null != setup) { setup(si); } return(si.Interpolate(str, ctx, ctx2, controlKey)); }
public void Format_Is_CultureSensitive() { // Shorter syntax is harder to read. // $ hides internationalization and has no overload for it. var money = 2600; var result = StringInterpolation.Format(money); // implemented as $"{money:N}"; var expected = string.Format(CultureInfo.CurrentCulture, "{0:N}", money); Assert.AreNotEqual(expected, result); }
public TaskBase() { Name = GetType().Name; Before = new List <ITask>(); After = new List <ITask>(); Fallback = new List <ITask>(); PlainConfig = new Dictionary <string, string>(); Interpolator = new StringInterpolation { AncorSymbol = '@' }; }
/// <inheritdoc /> protected override void Format(IScriptToken token, StringBuilder resulttext, IFormatterCollection formatters, int depth = 0) { StringInterpolation interpolation = (StringInterpolation)token; resulttext.Append("$\""); foreach (IScriptToken child in interpolation.Children) { if (child is ScriptValue value && value.Value is string stringvalue) { FormatString(stringvalue, resulttext); }
//[TestMethod] public bool StringInterpolationGreetingValid() { var source = "have a nice day"; var firstName = "yo"; var lastName = "dude"; var expected = $"Hello {firstName} {lastName}"; var actual = StringInterpolation.Greeting(firstName, lastName); return(expected == actual); //Assert.AreEqual(expected, actual); }
protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.OpenInterpolation) { var interpolation = itemFactory.CreateSpecific<StringInterpolation>(this, text, stream); if (interpolation.Parse(itemFactory, text, stream)) { Interpolation = interpolation; Children.Add(interpolation); } } return Children.Count > 0; }
protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.OpenInterpolation) { var interpolation = itemFactory.CreateSpecific <StringInterpolation>(this, text, stream); if (interpolation.Parse(itemFactory, text, stream)) { Interpolation = interpolation; Children.Add(interpolation); } } return(Children.Count > 0); }
static void Main(string[] args) { UsingStatic.Execute(); NameOf.Execute(); AutoPropertyInitializer.Execute(); ExpressionBodiedMember.Execute(); DictionaryInitializer.Execute(); ExceptionFilter.Execute(); PropertyConstructorInitializer.Execute(); StringInterpolation.Execute(); AsyncCathFinally.Execute(); NullConditional.Execute(); DelegateNull.Execute(); }
public void stringDemo() { var StrinInterfoplationclass = new StringInterpolation(); Assert.AreEqual("Full Name is: Steve Jobs", StrinInterfoplationclass.StringDemo("Steve", "Jobs")); }
public void SetUp() { _si = new StringInterpolation(); }
public void ReturnNames() { var result = StringInterpolation.GetNames("foo {bar} baz {qux} waldo").ToList(); CollectionAssert.AreEqual(new[] { "bar", "qux" }, result); }
public void ReturnsEmptyCollectionWhenNoNames() { var result = StringInterpolation.GetNames("foo bar baz").ToList(); CollectionAssert.AreEqual(new string[] { }, result); }
public void MI_334_Invalid_Train_AncorTrim(){ var str = "xxx$"; var result = new StringInterpolation().Interpolate(str, new{x = 1}); Assert.AreEqual(str,result); }
public void SetUp() { _si = new StringInterpolation(); }